项目在真机运行正常,但是在模拟器上运行时有黑屏现象。
此种现象基本都是jni问题导致:
1.未添加x86的so库;(大部分模拟器是x86的架构);
方案:补充添加so库
2.将so库放到了libs里,但是未设置jniLibs的路径;
方案:build.gradle中添加
sourceSets { main { jniLibs.srcDirs = ['libs'] } }
3. 报错提示so文件太小(0bytes)
10-13 16:17:22.678 5456-5676/com.yt.driver E/art: dlopen("/data/app/com.yt.driver-1/lib/x86/libAMapSDK_MAP_v7_4_0.so", RTLD_LAZY) failed: dlopen failed: "/data/app/com.yt.driver-1/lib/x86/libAMapSDK_MAP_v7_4_0.so" is too small to be an ELF executable: only found 0 bytes
解决方案:从官网重新下载so替换(我就是遇到的这个问题,哪个同事拷包的时候出错了没注意,所以包大小是0bytes)
4.高版本模拟器(Android 8.0)运行地图出现黑屏,首次进入地图还会弹出”xx.xo has invalid ELF header”的警告;
解决方案:换低版本模拟器,(请参考官方解释:https://lbs.amap.com/faq/android/location-sdk/position/46672/)