问题
I'm using the native map CN1Lib for my project. I followed the instructions from here and added the required build hints. In simulator the map looks fine but when I export it to android (debug on android studio), the map only shows as a gray rectangle with "Google" on the left bottom.
I thought it was a problem about google api so I created a few new api keys at google console. All keys were not limited. Google Maps Android API was also enabled, but the problem persists. I've also checked that in the AndroidManifest.xml in the exported apk the correct api is contained.
Below are the build hints (part of api key censored):
codename1.android.keystore=
codename1.android.keystoreAlias=
codename1.android.keystorePassword=
codename1.arg.android.playService.maps=true
codename1.arg.android.xapplication=<meta-data android\:name\="com.google.android.maps.v2.API_KEY" android\:value\="AIza__________________________________"/>
codename1.arg.build.incSources=1
codename1.arg.ios.add_libs=SystemConfiguration.framework
codename1.arg.ios.afterFinishLaunching=[GMSServices provideAPIKey\:@"AIza__________________________________"];
codename1.arg.ios.locationUsageDescription=To provide near-by stores info to the user
codename1.arg.ios.newStorageLocation=true
codename1.arg.ios.objC=true
codename1.arg.java.version=8
codename1.arg.javascript.googlemaps.key=AIza__________________________________
codename1.displayName=Medi
codename1.icon=icon.png
codename1.ios.certificate=
codename1.ios.certificatePassword=
codename1.ios.provision=
codename1.j2me.nativeTheme=nativej2me.res
codename1.languageLevel=5
codename1.mainName=Medi
codename1.packageName=com.my.medi
codename1.rim.certificatePassword=
codename1.rim.signtoolCsk=
codename1.rim.signtoolDb=
codename1.secondaryTitle=Medi
codename1.vendor=CodenameOne
codename1.version=1.0
libVersion=203
I'm not sure how to proceed now. Please advice.
EDIT: The Logcat output is as follows:
01-23 01:37:13.051 6001-6018/com.my.medi D/CN1 Maps: Initializing maps
01-23 01:37:13.099 6001-6001/com.my.medi I/zzy: Making Creator dynamically
01-23 01:37:13.114 6001-6001/com.my.medi I/zygote: The ClassLoaderContext is a special shared library.
01-23 01:37:13.118 6001-6001/com.my.medi I/chatty: uid=10081(com.my.medi) identical 1 line
01-23 01:37:13.122 6001-6001/com.my.medi I/zygote: The ClassLoaderContext is a special shared library.
01-23 01:37:13.260 6001-6006/com.my.medi I/zygote: Do partial code cache collection, code=114KB, data=93KB
01-23 01:37:13.263 6001-6006/com.my.medi I/zygote: After code cache collection, code=114KB, data=93KB
01-23 01:37:13.263 6001-6006/com.my.medi I/zygote: Increasing code cache capacity to 512KB
01-23 01:37:13.274 6001-6001/com.my.medi W/zygote: Unsupported class loader
01-23 01:37:13.326 6001-6001/com.my.medi W/zygote: Skipping duplicate class check due to unsupported classloader
01-23 01:37:13.412 6001-6001/com.my.medi I/Google Maps Android API: Google Play services client version: 8298000
01-23 01:37:13.429 6001-6001/com.my.medi I/Google Maps Android API: Google Play services package version: 11580470
01-23 01:37:13.551 6001-6001/com.my.medi E/Google Maps Android API: Google Maps Android API v2 only supports devices with OpenGL ES 2.0 and above
01-23 01:37:13.750 6001-6001/com.my.medi I/Google Maps Android API: Google Play services package version: 11580470
01-23 01:37:13.809 6001-6001/com.my.medi I/Choreographer: Skipped 42 frames! The application may be doing too much work on its main thread.
01-23 01:37:13.851 6001-6001/com.my.medi I/Google Maps Android API: Google Play services package version: 11580470
01-23 01:37:13.957 6001-6018/com.my.medi I/System.out: SQL Query: SELECT * FROM AspTable WHERE (Lat BETWEEN 0.0 AND 0.0) AND (Lnt BETWEEN 0.0 AND 0.0)
01-23 01:37:14.085 6001-6018/com.my.medi I/System.out: SQL Query: SELECT * FROM AspTable WHERE (Lat BETWEEN 0.0 AND 0.0) AND (Lnt BETWEEN 0.0 AND 0.0)
01-23 01:37:14.366 6001-6071/com.my.medi D/EGL_emulation: eglCreateContext: 0x966589e0: maj 1 min 0 rcv 1
01-23 01:37:14.874 6001-6071/com.my.medi D/EGL_emulation: eglMakeCurrent: 0x966589e0: ver 1 0 (tinfo 0x96663380)
01-23 01:37:15.151 6001-6001/com.my.medi I/Choreographer: Skipped 55 frames! The application may be doing too much work on its main thread.
[ 01-23 01:37:15.170 6001: 6064 D/ ]
HostConnection::get() New Host Connection established 0x8d2d2740, tid 6064
01-23 01:37:15.182 6001-6064/com.my.medi D/EGL_emulation: eglCreateContext: 0x8ce859e0: maj 1 min 0 rcv 1
01-23 01:37:15.492 6001-6064/com.my.medi D/EGL_emulation: eglMakeCurrent: 0x8ce859e0: ver 1 0 (tinfo 0x96663630)
01-23 01:37:15.730 6001-6059/com.my.medi W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
01-23 01:37:15.731 6001-6059/com.my.medi W/DynamiteModule: Failed to load module via V2: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.dynamite.DynamiteModule$DynamiteLoaderClassLoader" on path: DexPathList[[zip file "/data/app/com.my.medi-Sd9oSMBfGaQ8_lajDB7WUA==/base.apk"],nativeLibraryDirectories=[/data/app/com.my.medi-Sd9oSMBfGaQ8_lajDB7WUA==/lib/x86, /system/lib, /vendor/lib]]
01-23 01:37:15.746 6001-6059/com.my.medi I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:4
01-23 01:37:15.746 6001-6059/com.my.medi I/DynamiteModule: Selected remote version of com.google.android.gms.googlecertificates, version >= 4
01-23 01:37:15.770 6001-6059/com.my.medi W/zygote: Unsupported class loader
01-23 01:37:15.817 6001-6059/com.my.medi W/zygote: Skipping duplicate class check due to unsupported classloader
01-23 01:37:16.310 6001-6066/com.my.medi W/zygote: Long monitor contention with owner androidmapsapi-ula-1 (6059) at int java.io.UnixFileSystem.getBooleanAttributes0(java.lang.String)(UnixFileSystem.java:-2) waiters=0 in boolean in.a() for 474ms
01-23 01:38:05.450 6001-6018/com.my.medi D/Codename One: native focus gain
I'm not sure if the "missing class loader part" is related though. Thanks in advance
EDIT EDIT
As it turns out it is just another way Android studio manifest the won't run unless you update the Google Play Service bug, where using API version 21 (Android 5.0) solves the issue. Will need to do on device testing tho
回答1:
This problem occurs if the native configuration doesn't match the JavaScript configuration or failed to initialize. One of the tricks to debugging this is connecting a cable and using DDMS/logcat to look at the output. Google usually prints out an error when things don't work correctly.
Notice that the AIza__________________________________
values you used must be 3 different values. One for a native Android app, one for a native iOS app and the last one for the web.
来源:https://stackoverflow.com/questions/48369441/codename-one-native-map-not-showing