Skobbler Maps on Android showing black screen

2019-06-25 09:25发布

问题:

I'm using Skobbler SDK 2.3.0, targeting Lollipop, testing on a Nexus 5 and Galaxy S4, building on Android Studio 1.0.2.

I've a single MainActivity with a navigation drawer and fragments. I initialize Skobbler in the MainActivity and load the fragment that displays the maps. However, I only get a black screen with the watermark "Powered by Scout OSM" at the bottom right. Single and double taps are registered, but if I pinch to zoom the app crashes.

I don't see any errors in logcat before the app crashes. Can anyone help?

Project structure:

  • app/libs/SKMaps.jar
  • app/src/main/assets/SKMaps.zip
  • app/src/main/jniLibs/armeabi/libngnative.so
  • app/src/main/jniLibs/armeabi-v7a/libngnative.so
  • app/src/main/jniLibs/x86/libngnative.so

build.grade:

dependencies {
...
...
compile files('libs/SKMaps.jar')
}

logcat

01-05 22:58:42.835 26785-26785/com.example.android I/MainActivity﹕ onCreate 01-05 22:58:42.869 26785-26785/com.example.android I/System.out﹕ Item selected in navigation drawer 01-05 22:58:42.895 26785-26785/com.example.android I/MainActivity﹕ Adding login fragment 01-05 22:58:42.895 26785-26785/com.example.android I/MainActivity﹕ Done 01-05 22:58:42.895 26785-26785/com.example.android I/MainActivity﹕ Initialising Skobbler 01-05 22:58:42.899 26785-26785/com.example.android I/MainActivity﹕ Start initializeLibrary() 01-05 22:58:42.899 26785-26785/com.example.android D/SKMaps﹕ SKMapInitSettings---- Map style [/storage/emulated/0/Android/data/com.example.android/files/SKMaps/daystyle/ , daystyle.json ,-1] 01-05 22:58:42.899 26785-26785/com.example.android D/SKMaps﹕ SKVersionManager----setMapUpdateListener - com.example.android.MainActivity@1c8a98bc 01-05 22:58:42.899 26785-26785/com.example.android I/MainActivity﹕ End initializeLibrary() 01-05 22:58:42.899 26785-26785/com.example.android I/MainActivity﹕ Skobbler initialised 01-05 22:58:42.899 26785-26785/com.example.android I/MainActivity﹕ onCreate end ... 01-05 22:58:55.790 26785-26785/com.example.android D/SKMaps﹕ SKMapSurfaceView----SKMapSurfaceView constructor 01-05 22:58:55.790 26785-26785/com.example.android D/SKMaps﹕ SKMapSurfaceView----os model Nexus 5 01-05 22:58:55.797 26785-26785/com.example.android D/SKMaps﹕ MapRenderer----Set map density 3.0 01-05 22:58:55.800 26785-26785/com.example.android D/SKMaps﹕ SKMapSurfaceView---- ON PAUSE 01-05 22:58:55.803 26785-26785/com.example.android D/SKMaps﹕ SKMapSurfaceView----Saved map cache state [ Map Region zoom=17.0 center= [13.385000228881836,52.51665115356445]] [Display mode=MODE_2D] [Follower mode=NONE] [Compass shown=false Position = [0.0 ,0.0] ] [Rotation=true ] [Panning=true][Zooming=true] [Bearing=0.0] [Annotations=0] 01-05 22:58:55.811 26785-26785/com.example.android E/BitmapFactory﹕ Unable to decode stream: java.io.FileNotFoundException: null/res/xhdpi/icon_map_popup_navigate.png: open failed: ENOENT (No such file or directory) 01-05 22:58:55.813 26785-26785/com.example.android E/BitmapFactory﹕ Unable to decode stream: java.io.FileNotFoundException: null/res/xhdpi/icon_map_popup_arrow.png: open failed: ENOENT (No such file or directory) 01-05 22:58:55.822 26785-26785/com.example.android D/SKMaps﹕ SKMapSurfaceView---- centerMapOnPosition [19.8171,41.3294]

回答1:

You're missing one statement after the map is initialized:

mapView.onResume();

If you have a look at the example from Skobbler you see they copy the textures in one Activity and show the map in a different one. The Activity that shows the map calls mapView.onResume() and mapView.onPause() in the Activity callbacks. If you want to load the textures and show the map in the same Activity, you'll have to call mapView.onResume() after the resources are copied and the map is initialized.