Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

百度地图sdk初始化异常 #28

Closed
onlylikews opened this issue Jul 3, 2019 · 9 comments
Closed

百度地图sdk初始化异常 #28

onlylikews opened this issue Jul 3, 2019 · 9 comments

Comments

@onlylikews
Copy link

你好,我今天发现百度地图sdk初始化异常,是so加载存在兼容问题吗?百度地图sdk版本是v3.7.3,具体错误堆栈如下:
com.tencent.shadow.sample.host E/zygote64: No implementation found for long com.baidu.platform.comjni.map.commonmemcache.JNICommonMemCache.Create() (tried Java_com_baidu_platform_comjni_map_commonmemcache_JNICommonMemCache_Create and Java_com_baidu_platform_comjni_map_commonmemcache_JNICommonMemCache_Create__)
2019-07-03 16:58:17.755 21619-21619/com.tencent.shadow.sample.host E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.tencent.shadow.sample.host, PID: 21619
java.lang.UnsatisfiedLinkError: No implementation found for long com.baidu.platform.comjni.map.commonmemcache.JNICommonMemCache.Create() (tried Java_com_baidu_platform_comjni_map_commonmemcache_JNICommonMemCache_Create and Java_com_baidu_platform_comjni_map_commonmemcache_JNICommonMemCache_Create__)
at com.baidu.platform.comjni.map.commonmemcache.JNICommonMemCache.Create(Native Method)
at com.baidu.platform.comjni.map.commonmemcache.a.a(Unknown Source:2)
at com.baidu.platform.comapi.util.f.b(Unknown Source:6)
at com.baidu.platform.comapi.a.c(Unknown Source:23)
at com.baidu.platform.comapi.c.a(Unknown Source:21)
at com.baidu.mapapi.SDKInitializer.initialize(Unknown Source:0)
at com.baidu.mapapi.SDKInitializer.initialize(Unknown Source:1)

@shifujun
Copy link
Collaborator

shifujun commented Jul 3, 2019

如果只是测试一下接入百度地图SDK,那代码应该能公开吧?你可以把接入改在Shadow的sample里,让我们复现一下问题。这样Debug就方便了。单纯看堆栈看不出来原因,从异常上来看就是它的So没有加载。

@onlylikews
Copy link
Author

现在是放了一个比较复杂的应用作为插件,想试试这个框架的能力,哈哈。我试试只放百度地图sdk重现看看,再把示例公开给你们调一下

@shifujun
Copy link
Collaborator

shifujun commented Jul 3, 2019

复杂点的应用使用到的系统API,我们业务没用过,出问题也是很正常的。一般来说都比较容易支持的。

这个so没有正常加载的问题,估计也是很容易修复的。有代码就调试下看看吧。可能是百度地图SDK加载so的代码不是很常见。

@onlylikews
Copy link
Author

问题复现了,示例地址:
https://github.com/onlylikews/Shadow-1

@onlylikews
Copy link
Author

我这边看貌似只有 com.baidu.platform.comapi.a.c 里面有一个System.loadLibrary,加载的是BaiduMapSDK_base_v3_7_3.so,其他so库会不会通过其他方式(比如c语言里动态加载)跑去宿主的路径下找了?

@shifujun
Copy link
Collaborator

shifujun commented Jul 3, 2019

这个问题完全是因为文档不齐造成的。
按下面这个patch所示,在PluginManager中定义插件要使用ABI就可以了。

Index: projects/sample/sample-manager/src/main/java/com/tencent/shadow/sample/manager/SamplePluginManager.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- projects/sample/sample-manager/src/main/java/com/tencent/shadow/sample/manager/SamplePluginManager.java	(date 1562147281000)
+++ projects/sample/sample-manager/src/main/java/com/tencent/shadow/sample/manager/SamplePluginManager.java	(date 1561535539000)
@@ -56,7 +56,7 @@
      */
     @Override
     public String getAbi() {
-        return "";
+        return "armeabi-v7a";
     }
 
     /**

@onlylikews
Copy link
Author

onlylikews commented Jul 3, 2019

试了一下,还是不行,还是之前的错误提示

@shifujun
Copy link
Collaborator

shifujun commented Jul 4, 2019

这里还有一个一直没解决的问题,但是对我们业务来说不是那么重要,所以sample里漏了。

宿主如果没有带有任何so,那么它安装的时候,应该被系统以某种形式标记为手机的首选abi类型了,所以你的手机是64位的,应该就被标记为64位ABI的了。然后插件再去尝试加载32位so的时候就会出现is 32-bit instead of 64-bit异常。

这个异常被百度SDK吞了,所以你没看到。在这里:
com.baidu.platform.comapi.a

static {
        try {
            System.loadLibrary(VersionInfo.getKitName());
            AppEngine.InitClass();
        } catch (Error var1) {
            System.out.println(VersionInfo.getKitName() + " Failed to load.");
        }

    }

要解决这个问题,只需要在宿主中打包一个32位的so,应该还要加载它。这样系统就会认为这个宿主是32位ABI的应用了。之后插件就可以加载32位的so了。

对于我们业务来说这个问题并不紧急是因为我们的宿主都是用了so的,所以不需要特别处理这个问题。

@onlylikews
Copy link
Author

嗯,按照你说的方式解决了,哈哈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants