Im trying to implement Jetpack Compose Map on my project. In the emulator works fine but on physical devices doesn't.
This is NOT a API_KEY problem. I tried several times with different keys and doesn't work on my current project but works on my others projects.
Im using these versions (highest to compileSDK33)
implementation 'com.google.maps.android:maps-compose:2.15.0'
implementation 'com.google.android.gms:play-services-maps:18.2.0'
implementation 'com.google.android.gms:play-services-location:21.0.1'
The version is not a problem, I created a branch to update with compileSDK and still not work.
I create a basic screen only with a map.
val cameraPositionState = rememberCameraPositionState {
position = CameraPosition.fromLatLngZoom(LatLng(-17.1820972, 28.2918109), 10f)
}
GoogleMap(
modifier = Modifier
.fillMaxWidth()
.height(300.dp)
.padding(top = 40.dp),
cameraPositionState = cameraPositionState
)
And obviously I have a internet permission and
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="myapi" />
It's really weird I have several projects and only these fail. Maybe is for using Firebase? It's the only "bigger difference" I have. And I included sha1 and sha256 for debug and release.
You said that your map works fine on the emulator, but not on physical devices. This could be due to several reasons, such as:
• Your physical devices have a different version of Google Play Services than the emulator. You can check the version of Google Play Services on your devices by going to Settings > Apps > Google Play Services. You can also update Google Play Services by following the instructions here.
• Your physical devices have a different configuration or locale than the emulator. You can check the configuration and locale of your devices by going to Settings > System > Languages & input. You can also change the configuration and locale of your devices by following the instructions here.
• Your physical devices have a different network or firewall settings than the emulator. You can check the network and firewall settings of your devices by going to Settings > Network & internet. You can also change the network and firewall settings of your devices by following the instructions here.
To troubleshoot the issue, you can also enable the debug mode of Jetpack Compose Map by setting the configuration key maps.compose.debug to true. This will print more information about the map and the errors in the logcat.