20191111 集成android sdk,华为手机基本都启动报错,如下:
W/System.err: java.security.NoSuchProviderException: no such provider: Crypto
W/System.err: at sun.security.jca.GetInstance.getService(GetInstance.java:83)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:206)
at java.security.SecureRandom.getInstance(SecureRandom.java:382)
W/System.err: at io.dcloud.common.adapter.util.DCloudTrustManager.createSecureRandom(DCloudTrustManager.java:46)
at io.dcloud.common.util.NetTool.createConnection(NetTool.java:215)
W/System.err: at io.dcloud.common.util.NetTool.request(NetTool.java:78)
at io.dcloud.common.util.NetTool.httpGet(NetTool.java:34)
at io.dcloud.common.util.NetTool.httpGet(NetTool.java:42)
at io.dcloud.common.b.a$1.run(Core.java:202)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
W/System.err: at java.lang.Thread.run(Thread.java:784)
E/NativeLoader: loadException
java.lang.UnsatisfiedLinkError: dlopen failed: "/data/data/com.ynhtbank.beta.htbank/files/libs/libBaiduMapSDK_base_v4_3_1.so" is 32-bit instead of 64-bit
at java.lang.Runtime.load0(Runtime.java:928)
at java.lang.System.load(System.java:1624)
at com.baidu.platform.comapi.NativeLoader.f(Unknown Source:13)
at com.baidu.platform.comapi.NativeLoader.a(Unknown Source:13)
at com.baidu.platform.comapi.NativeLoader.c(Unknown Source:8)
at com.baidu.platform.comapi.NativeLoader.loadCustomizeNativeLibrary(Unknown Source:51)
at com.baidu.platform.comapi.NativeLoader.loadLibrary(Unknown Source:40)
at com.baidu.platform.comapi.a.<clinit>(Unknown Source:20)
at com.baidu.platform.comapi.a.a(Unknown Source:0)
at com.baidu.platform.comapi.c.a(Unknown Source:16)
at com.baidu.mapapi.SDKInitializer.initialize(Unknown Source:0)
at com.baidu.mapapi.SDKInitializer.initialize(Unknown Source:1)
at io.dcloud.js.map.MapInitImpl.onStart(MapInitImpl.java:25)
at io.dcloud.common.b.a.a(Core.java:449)
at io.dcloud.common.b.a.a(Core.java:151)
at io.dcloud.common.b.b.a(PandoraEntryProxy.java:52)
at io.dcloud.EntryProxy.onCreate(EntryProxy.java:96)
at com.ynhtbank.MainActivity.onCreate(MainActivity.java:67)
at android.app.Activity.performCreate(Activity.java:7372)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3147)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3302)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7425)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
E/NativeLoader: BaiduMapSDK_base_v4_3_1 Failed to load.
E/zygote64: No implementation found for int com.baidu.platform.comjni.tools.JNITools.initClass(java.lang.Object, int) (tried Java_com_baidu_platform_comjni_tools_JNITools_initClass and Java_com_baidu_platform_comjni_tools_JNITools_initClass__Ljava_lang_Object_2I)
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.ynhtbank.beta.htbank, PID: 24657
java.lang.UnsatisfiedLinkError: No implementation found for int com.baidu.platform.comjni.tools.JNITools.initClass(java.lang.Object, int) (tried Java_com_baidu_platform_comjni_tools_JNITools_initClass and Java_com_baidu_platform_comjni_tools_JNITools_initClass__Ljava_lang_Object_2I)
at com.baidu.platform.comjni.tools.JNITools.initClass(Native Method)
at com.baidu.platform.comjni.tools.a.b(Unknown Source:6)
at com.baidu.platform.comapi.a.<clinit>(Unknown Source:23)
at com.baidu.platform.comapi.a.a(Unknown Source:0)
at com.baidu.platform.comapi.c.a(Unknown Source:16)
at com.baidu.mapapi.SDKInitializer.initialize(Unknown Source:0)
at com.baidu.mapapi.SDKInitializer.initialize(Unknown Source:1)
at io.dcloud.js.map.MapInitImpl.onStart(MapInitImpl.java:25)
at io.dcloud.common.b.a.a(Core.java:449)
at io.dcloud.common.b.a.a(Core.java:151)
at io.dcloud.common.b.b.a(PandoraEntryProxy.java:52)
at io.dcloud.EntryProxy.onCreate(EntryProxy.java:96)
at com.ynhtbank.MainActivity.onCreate(MainActivity.java:67)
at android.app.Activity.performCreate(Activity.java:7372)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3147)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3302)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7425)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
I/zygote64: Compiler allocated 5MB to compile boolean io.dcloud.common.a.d.a(java.io.InputStream, java.lang.String, org.json.JSONObject)
W/System.err: java.io.FileNotFoundException: /storage/emulated/0/.imei.txt (Permission denied)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:200)
at java.io.FileInputStream.<init>(FileInputStream.java:150)
at io.dcloud.common.util.TelephonyUtil.getIMEI(TelephonyUtil.java:243)
W/System.err: at io.dcloud.common.util.TelephonyUtil.getIMEI(TelephonyUtil.java:33)
at io.dcloud.common.adapter.util.UEH.commitBaseUncatchInfo(UEH.java:139)
at io.dcloud.common.adapter.util.UEH.commitUncatchException(UEH.java:168)
at io.dcloud.common.adapter.util.UEH.access$100(UEH.java:35)
at io.dcloud.common.adapter.util.UEH$1.uncaughtException(UEH.java:52)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1063)
at java.lang.Thread.dispatchUncaughtException(Thread.java:1973)
I/zygote64: Do full code cache collection, code=124KB, data=93KB
I/zygote64: After code cache collection, code=96KB, data=62KB
W/System.err: java.lang.UnsatisfiedLinkError: No implementation found for int com.baidu.platform.comjni.tools.JNITools.initClass(java.lang.Object, int) (tried Java_com_baidu_platform_comjni_tools_JNITools_initClass and Java_com_baidu_platform_comjni_tools_JNITools_initClass__Ljava_lang_Object_2I)
at com.baidu.platform.comjni.tools.JNITools.initClass(Native Method)
at com.baidu.platform.comjni.tools.a.b(Unknown Source:6)
=============================================================================================================
百度地图 libBaiduMapSDK_base_v4_2_1.so" is 32-bit instead of 64-bit错误
有的手机默认支持64位,启动的时候会尝试加载64位的so。不过包却不一定对64位做出支持。当系统无法加载到理想的包,就会抛出以下异常。
libBaiduMapSDK_base_v4_2_1.so" is 32-bit instead of 64-bit
不过,Android 64位是可以向下兼容32位程序的,apk只需要在budil.gradle中明确支持的指令集,以此适配手机即可。
defaultConfig {
ndk {
abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
}
}
————————————————
原文链接:https://blog.csdn.net/cao2884388/article/details/89478113
参考2:https://blog.csdn.net/yangbin0513/article/details/78212874
相关参考:
Android项目针对libs(armeabi,armeabi-v7a,x86)进行平台兼容
1.Android设备如何加载.so文件?
不同CPU架构的Android手机加载时会在libs下找自己对应的目录,从对应的目录下寻找需要的.so文件;如果没有对应的目录,就会去armeabi下去寻找,如果已经有对应的目录,但是如果没有找到对应的.so文件,也不会去armeabi下去寻找了。
以x86设备为例,x86设备会在项目中的 libs文件夹寻找是否含有x86文件夹,如果含有x86文件夹,则默认为该项目有x86对应的so可运行文件,只有x86文件夹而文件夹下没有so,程序运行也是会出现find library returned null的错误的;如果工程本身不含有x86文件夹,则会寻找armeabi或者armeabi-v7a文件夹,兼容运行。以armeabi-v7a设备为例,该Android设备当然优先寻找libs目录下的armeabi-v7a文件夹,同样,如果只有armeabi-v7a文件夹而没有 so也是会报错的;如果找不到armeabi-v7a文件夹,则寻找armeabi文件夹,兼容运行该文件夹下的so,但是不能兼容运行x86的so。所以项目中如果只含有x86的so,在armeabi和armeabi-v7a也是无法运行的。以上就是不同CPU架构运行时加载so的策略。
2.对于不同的平台,我们应该怎么去进行适配?
目前主流的Android设备肯定是armeabi-v7a架构的,然后就是x86和armeabi了。如果同时包含了 armeabi, armeabi-v7a和x86,所有设备都可以运行,程序在运行的时候去加载不同平台对应的so,这是较为完美的一种解决方案,但是同时也会导致包变大。
armeabi-v7a是可以兼容armeabi的,而v7a的CPU支持硬件浮点运算,目前绝大对数设备已经是armeabi-v7a了,所以为了性能上的更优,就不要为了兼容放到armeabi下了。x86也是可以兼容armeabi平台运行的,另外需要指出的是,打出包的x86的so,总会比armeabi平台的体积更小,对于性能有洁癖的童鞋们,还是建议在打包so的时候支持x86。
3.如果第三方没有提供对应平台的.so文件怎么办?
有一些第三方的类库只提供了armeabi下的.so文件,如果我们项目里适配了armeabi-v7a和x86,如果不在对应的文件下放对应的.so文件,就可能导致某些Android设备会出一些问题,我们可以复制armeabi下得.so文件到不同的文件夹下。如果第三方提供了不同平台的.so文件,则复制不同平台的.so文件到项目中对应的文件夹下即可。