OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to integrate google location api with flutter

  • Thread starter Thread starter Anamika Singh
  • Start date Start date
A

Anamika Singh

Guest
I'm trying to connect google location api with flutter and I'm getting below error:

D/MapsInitializer(15510): preferredRenderer: null D/zzcc (15510): preferredRenderer: null I/zzcc (15510): Making Creator dynamically W/ziparchive(15510): Unable to open '/data/user_de/0/com.google.android.gms/app_chimera/m/000001ad/DynamiteLoader.uncompressed.dm': No such file or directory W/ziparchive(15510): Unable to open '/data/user_de/0/com.google.android.gms/app_chimera/m/000001ad/DynamiteLoader.uncompressed.dm': No such file or directory I/DynamiteModule(15510): Considering local module com.google.android.gms.maps_core_dynamite:0 and remote module com.google.android.gms.maps_core_dynamite:241610202 I/DynamiteModule(15510): Selected remote version of com.google.android.gms.maps_core_dynamite, version >= 241610202 V/DynamiteModule(15510): Dynamite loader version >= 2, using loadModule2NoCrashUtils W/System (15510): ClassLoader referenced unknown path: D/nativeloader(15510): Configuring clns-6 for other apk . target_sdk_version=34, uses_libraries=, library_path=/data/app/~~aDJz21s4KF00HrE2fHyMrw==/com.google.android.gms-ok87zpsyyDDP-MOdQOTVYA==/lib/arm64:/data/app/~~aDJz21s4KF00HrE2fHyMrw==/com.google.android.gms-ok87zpsyyDDP-MOdQOTVYA==/base.apk!/lib/arm64-v8a, permitted_path=/data:/mnt/expand:/data/user/0/com.google.android.gms W/obile.asset.tns(15510): Accessing hidden method Ldalvik/system/VMStack;->getStackClass2()Ljava/lang/Class; (unsupported, reflection, allowed) D/nativeloader(15510): Configuring clns-7 for other apk . target_sdk_version=33, uses_libraries=ALL, library_path=/data/user_de/0/com.google.android.gms/app_chimera/m/00000197/dl-MapsCoreDynamite.integ_241610202100400.apk!/lib/arm64-v8a, permitted_path=/data:/mnt/expand I/native (15510): I0000 00:00:1719357308.066152 15510 jni_init.cc:8] Initializing JNI... Caused by: java.lang.SecurityException: GoogleCertificatesRslt: not allowed: pkg=com.apptricity.mobile.asset.tns, sha256=[7090f01d4f12a801e1ecf56b2a8ca456decdf75a240426b2aa316f57bb08ba20], atk=false, ver=242334038.true (go/gsrlt)

I have added this in my AndroidManifest.xml under src/main in the application tag.:

Code:
<meta-data android:name="com.google.android.geo.API_KEY" android:value="Key"/>

here is my code:

Code:
class AssetLocationScreen extends StatefulWidget {
  final String displayLabel;
  final double? longitude;
  final double? latitude;

  AssetLocationScreen(
      {required this.displayLabel, this.longitude, this.latitude});

  @override
  State<AssetLocationScreen> createState() => _AssetLocationScreenState();
}

class _AssetLocationScreenState extends State<AssetLocationScreen> {
  late GoogleMapController mapController;
  bool _locationPermissionGranted = false;

  void _onMapCreated(GoogleMapController controller) async {
    mapController = controller;

    var status = await Permission.location.status;
    if (!status.isGranted) {
      var result = await Permission.location.request();
      if (result.isGranted) {
        // Update the state to reflect permission status
        setState(() {
          _locationPermissionGranted = true;
        });
      }
    } else {
      setState(() {
        _locationPermissionGranted = true;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    LatLng position = LatLng(widget.latitude ?? 0.0, widget.longitude ?? 0.0);
    
    return Scaffold(
      body: Column(
        children: [
          Container(
            width: double.infinity,
            padding: EdgeInsets.only(
                top: 60.0, left: 60.0, right: 60.0, bottom: 20.0),
            decoration: BoxDecoration(
              color: Color.fromRGBO(2, 153, 204, 1),
              borderRadius: BorderRadius.only(
                bottomLeft: Radius.circular(20.0),
                bottomRight: Radius.circular(20.0),
              ),
            ),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Text(
                  'Inquiry',
                  style: TextStyle(
                    fontFamily: 'Poppins',
                    fontSize: 32,
                    fontWeight: FontWeight.w500,
                    color: Colors.white,
                  ),
                  textAlign: TextAlign.center,
                ),
                SizedBox(height: 4),
                Text(
                  widget.displayLabel,
                  style: TextStyle(
                    fontFamily: 'Poppins',
                    fontSize: 15,
                    fontWeight: FontWeight.w500,
                    color: Colors.white,
                  ),
                  textAlign: TextAlign.center,
                ),
                SizedBox(height: 8),
                Text(
                  'Location',
                  style: TextStyle(
                    fontFamily: 'Poppins',
                    fontSize: 20,
                    fontWeight: FontWeight.w500,
                    color: Colors.white,
                  ),
                  textAlign: TextAlign.center,
                ),
              ],
            ),
          ),
          Expanded(
            child: Stack(
              children: [
                GoogleMap(
                  mapType: MapType.normal,
                  initialCameraPosition: CameraPosition(
                    target: position,
                    zoom: 14.0,
                  ),
                  onMapCreated: _onMapCreated,
                  myLocationEnabled: _locationPermissionGranted,
                  myLocationButtonEnabled: _locationPermissionGranted,
                  /*    markers: Set<Marker>.of([
                    Marker(
                      markerId: MarkerId('assetLocation'),
                      position: position,
                    ),
                  ]),*/
                ),

                Container(
                  decoration: BoxDecoration(
                    gradient: LinearGradient(
                      begin: Alignment.topCenter,
                      end: Alignment.bottomCenter,
                      colors: [
                        Color.fromRGBO(70, 206, 252, 1),
                        Color.fromRGBO(0, 54, 120, 1),
                      ],
                      stops: [0.2486, 0.833],
                    ),
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
<p>I'm trying to connect google location api with flutter and I'm getting below error:</p>
<p><strong>D/MapsInitializer(15510): preferredRenderer: null
D/zzcc (15510): preferredRenderer: null
I/zzcc (15510): Making Creator dynamically
W/ziparchive(15510): Unable to open '/data/user_de/0/com.google.android.gms/app_chimera/m/000001ad/DynamiteLoader.uncompressed.dm': No such file or directory
W/ziparchive(15510): Unable to open '/data/user_de/0/com.google.android.gms/app_chimera/m/000001ad/DynamiteLoader.uncompressed.dm': No such file or directory
I/DynamiteModule(15510): Considering local module com.google.android.gms.maps_core_dynamite:0 and remote module com.google.android.gms.maps_core_dynamite:241610202
I/DynamiteModule(15510): Selected remote version of com.google.android.gms.maps_core_dynamite, version >= 241610202
V/DynamiteModule(15510): Dynamite loader version >= 2, using loadModule2NoCrashUtils
W/System (15510): ClassLoader referenced unknown path:
D/nativeloader(15510): Configuring clns-6 for other apk . target_sdk_version=34, uses_libraries=, library_path=/data/app/~~aDJz21s4KF00HrE2fHyMrw==/com.google.android.gms-ok87zpsyyDDP-MOdQOTVYA==/lib/arm64:/data/app/~~aDJz21s4KF00HrE2fHyMrw==/com.google.android.gms-ok87zpsyyDDP-MOdQOTVYA==/base.apk!/lib/arm64-v8a, permitted_path=/data:/mnt/expand:/data/user/0/com.google.android.gms
W/obile.asset.tns(15510): Accessing hidden method Ldalvik/system/VMStack;->getStackClass2()Ljava/lang/Class; (unsupported, reflection, allowed)
D/nativeloader(15510): Configuring clns-7 for other apk . target_sdk_version=33, uses_libraries=ALL, library_path=/data/user_de/0/com.google.android.gms/app_chimera/m/00000197/dl-MapsCoreDynamite.integ_241610202100400.apk!/lib/arm64-v8a, permitted_path=/data:/mnt/expand
I/native (15510): I0000 00:00:1719357308.066152 15510 jni_init.cc:8] Initializing JNI...
Caused by: java.lang.SecurityException: GoogleCertificatesRslt: not allowed: pkg=com.apptricity.mobile.asset.tns, sha256=[7090f01d4f12a801e1ecf56b2a8ca456decdf75a240426b2aa316f57bb08ba20], atk=false, ver=242334038.true (go/gsrlt)</strong></p>
<p>I have added this in my AndroidManifest.xml under src/main in the application tag.:</p>
<pre><code><meta-data android:name="com.google.android.geo.API_KEY" android:value="Key"/>
</code></pre>
<p>here is my code:</p>
<pre><code>class AssetLocationScreen extends StatefulWidget {
final String displayLabel;
final double? longitude;
final double? latitude;

AssetLocationScreen(
{required this.displayLabel, this.longitude, this.latitude});

@override
State<AssetLocationScreen> createState() => _AssetLocationScreenState();
}

class _AssetLocationScreenState extends State<AssetLocationScreen> {
late GoogleMapController mapController;
bool _locationPermissionGranted = false;

void _onMapCreated(GoogleMapController controller) async {
mapController = controller;

var status = await Permission.location.status;
if (!status.isGranted) {
var result = await Permission.location.request();
if (result.isGranted) {
// Update the state to reflect permission status
setState(() {
_locationPermissionGranted = true;
});
}
} else {
setState(() {
_locationPermissionGranted = true;
});
}
}

@override
Widget build(BuildContext context) {
LatLng position = LatLng(widget.latitude ?? 0.0, widget.longitude ?? 0.0);

return Scaffold(
body: Column(
children: [
Container(
width: double.infinity,
padding: EdgeInsets.only(
top: 60.0, left: 60.0, right: 60.0, bottom: 20.0),
decoration: BoxDecoration(
color: Color.fromRGBO(2, 153, 204, 1),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(20.0),
bottomRight: Radius.circular(20.0),
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'Inquiry',
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 32,
fontWeight: FontWeight.w500,
color: Colors.white,
),
textAlign: TextAlign.center,
),
SizedBox(height: 4),
Text(
widget.displayLabel,
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 15,
fontWeight: FontWeight.w500,
color: Colors.white,
),
textAlign: TextAlign.center,
),
SizedBox(height: 8),
Text(
'Location',
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 20,
fontWeight: FontWeight.w500,
color: Colors.white,
),
textAlign: TextAlign.center,
),
],
),
),
Expanded(
child: Stack(
children: [
GoogleMap(
mapType: MapType.normal,
initialCameraPosition: CameraPosition(
target: position,
zoom: 14.0,
),
onMapCreated: _onMapCreated,
myLocationEnabled: _locationPermissionGranted,
myLocationButtonEnabled: _locationPermissionGranted,
/* markers: Set<Marker>.of([
Marker(
markerId: MarkerId('assetLocation'),
position: position,
),
]),*/
),

Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color.fromRGBO(70, 206, 252, 1),
Color.fromRGBO(0, 54, 120, 1),
],
stops: [0.2486, 0.833],
),
),
),
],
),
),
],
),
);
}
}
</code></pre>
Continue reading...
 
Top