dji-sdk / Mobile-SDK-Android-V5

MSDK V5 Sample
Other
247 stars 127 forks source link

Crash when trying to use Google maps #294

Closed borisengler closed 3 months ago

borisengler commented 3 months ago

Hello I am using latest version of Sample app and when I try to use initGoogleMap, app crashes. My only changes are:

  1. Added API keys (DJI and Google) in manifest (meta-data of google maps had to be moved into application tag)
  2. In DefaultLayoutActivity.java I changed mapWidget.initAMap to mapWidget.initGoogleMap

I get this error in LogCat:

FATAL EXCEPTION: Thread-25
Process: com.ginasystem.drone, PID: 24386
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion;
at m.dn.b(:com.google.android.gms.dynamite_mapsdynamite@240812031@24.08.12 (150400-0):5)
at m.dm.a(:com.google.android.gms.dynamite_mapsdynamite@240812031@24.08.12 (150400-0):3)
at m.ct.a(:com.google.android.gms.dynamite_mapsdynamite@240812031@24.08.12 (150400-0):193)
at m.ct.run(:com.google.android.gms.dynamite_mapsdynamite@240812031@24.08.12 (150400-0):6)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.ProtocolVersion" on path: DexPathList[[zip file "/data/app/~~OsU1vGYdSydy23ebshZBug==/com.google.android.gms-DruVgcFPa4VVfFRUfeYYHA==/split_MapsDynamite.apk"],nativeLibraryDirectories=[/data/app/~~OsU1vGYdSydy23ebshZBug==/com.google.android.gms-DruVgcFPa4VVfFRUfeYYHA==/split_MapsDynamite.apk!/lib/arm64-v8a, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at dalvik.system.DelegateLastClassLoader.loadClass(DelegateLastClassLoader.java:137)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at m.dn.b(:com.google.android.gms.dynamite_mapsdynamite@240812031@24.08.12 (150400-0):5) 
at m.dm.a(:com.google.android.gms.dynamite_mapsdynamite@240812031@24.08.12 (150400-0):3) 
at m.ct.a(:com.google.android.gms.dynamite_mapsdynamite@240812031@24.08.12 (150400-0):193) 
at m.ct.run(:com.google.android.gms.dynamite_mapsdynamite@240812031@24.08.12 (150400-0):6) 
dji-lyt commented 3 months ago

Could you please let us know which version of Android the crash occurred on? Did you run the sample code of MSDK V5 directly, or did you integrate the map control into your own app? If you ran the sample code of MSDK directly, you can try filling in the API_KEY of Google Maps at the location shown in the image. image

borisengler commented 3 months ago

It happens on Android 11. I ran MSDK V5 sample directy, but I changed application ID so I could use my DJI Api key.

Now I changed GMAP_API_KEY variable in gradle.properties too, and I get:

FATAL EXCEPTION: main
Process: com.ginasystem.drone, PID: 18122
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ginasystem.drone/dji.v5.ux.sample.showcase.defaultlayout.DefaultLayoutActivity}: java.lang.RuntimeException: API key not found.  Check that <meta-data android:name="com.google.android.geo.API_KEY" android:value="your API key"/> is in the <application> element of AndroidManifest.xml
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3846)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4022)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2336)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8653)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Caused by: java.lang.RuntimeException: API key not found.  Check that <meta-data android:name="com.google.android.geo.API_KEY" android:value="your API key"/> is in the <application> element of AndroidManifest.xml

That's not problem to fix, I just moved <meta-data android:name="com.google.android.geo.API_KEY"... from <manifest> to <application.

But I still get error mentioned in issue when I try to use initGoogleMap instead of initAMap in DefaultLayoutActivity.java

dji-lyt commented 3 months ago

You can try adding in the AndroidManifest.xml file. image

Furthermore, if you only need to try using Google Maps on the V5 sample code, I do not recommend moving . The sample code has been configured to read the GMAP_API_KEY from gradle.properties.

borisengler commented 3 months ago

Thanks, adding that to manifest helped.

dji-dev commented 3 months ago

Agent comment from yating.liao in Zendesk ticket #103306:

I am glad to have been able to help you.

°°°