解决 Android 百度地图 SDK 升级出现的问题(v5.4.4 -> v7.0.0)

一、百度地图SDK升级

升级操作很简单,将libs目录下面的文件全部删除,将升级后的新文件拷贝进libs即可。

升级后,百度地图手势操作的流畅度,和动画效果明显好于之前的版本。但是,不可避免的也会带来一些问题。

二、解决升级后出现的问题

升级后的一些接口的变化,需要修改适应,在这里就不赘述了,只简单的说说下面两个问题。

1. 错误一

More than one file was found with OS independent path 'lib/armeabi-v7a/libgnustl_shared.so'  

   方法一:

         将相应libs的所有目录下的libgnustl_shared.so文件删除,问题解决!!!

   方法二: 

         在 app 的 build.gradle 下添加如下代码,问题解决!!!

android {
    packagingOptions {
        pickFirst 'lib/armeabi/libgnustl_shared.so'
        pickFirst 'lib/armeabi-v7a/libgnustl_shared.so'
    }
}

//注意:上述要与 abiFilters 相对应,我的 abiFilters 配置如下
ndk {
    abiFilters 'armeabi', 'armeabi-v7a'
}

2. 错误二

2020-09-15 20:29:02.289 18025-18025/com.xxx.xxx E/x_log:d.inject(L:111): Binary XML file line #12: Binary XML file line #12: Error inflating class com.baidu.mapapi.map.TextureMapView
    android.view.InflateException: Binary XML file line #12: Binary XML file line #12: Error inflating class com.baidu.mapapi.map.TextureMapView
    Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class com.baidu.mapapi.map.TextureMapView
    Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
        at android.view.LayoutInflater.createView(LayoutInflater.java:656)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:798)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:738)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:869)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:832)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
        at org.xutils.view.d.inject(ViewInjectorImpl.java:107)
        at xxx.xxx.xxx.BaseFragment.onCreateView(BaseFragment.java:38)
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:2354)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419)
        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809)
        at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799)
        at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580)
        at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367)
        at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322)
        at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229)
        at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:700)
        at android.os.Handler.handleCallback(Handler.java:761)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:156)
        at android.app.ActivityThread.main(ActivityThread.java:6623)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
     Caused by: java.lang.ExceptionInInitializerError
        at com.baidu.platform.comapi.b.c(Unknown Source)
        at com.baidu.mapsdkplatform.comapi.map.i.a(Unknown Source)
        at com.baidu.mapapi.map.TextureMapView.a(Unknown Source)
        at com.baidu.mapapi.map.TextureMapView.<init>(Unknown Source)
        at java.lang.reflect.Constructor.newInstance0(Native Method) 
        at java.lang.reflect.Constructor.newInstance(Constructor.java:430) 
        at android.view.LayoutInflater.createView(LayoutInflater.java:656) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:798) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:738) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:869) 
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:832) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:518) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:426) 
        at org.xutils.view.d.inject(ViewInjectorImpl.java:107) 
        at com.xxx.xxxcommonlibrary.base.BaseFragment.onCreateView(BaseFragment.java:38) 
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:2354) 
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419) 
        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740) 
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809) 
        at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799) 
        at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580) 
        at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367) 
        at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322) 
        at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229) 
        at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:700) 
        at android.os.Handler.handleCallback(Handler.java:761) 
        at android.os.Handler.dispatchMessage(Handler.java:98) 
        at android.os.Looper.loop(Looper.java:156) 
        at android.app.ActivityThread.main(ActivityThread.java:6623) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832) 
     Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: res.json
        at com.baidu.platform.comapi.c.c.<init>(Unknown Source)
        at com.baidu.platform.comapi.c.b.<init>(Unknown Source)
        at com.baidu.platform.comapi.c.b.<clinit>(Unknown Source)
        at com.baidu.platform.comapi.b.c(Unknown Source) 
        at com.baidu.mapsdkplatform.comapi.map.i.a(Unknown Source) 
        at com.baidu.mapapi.map.TextureMapView.a(Unknown Source) 
        at com.baidu.mapapi.map.TextureMapView.<init>(Unknown Source) 
        at java.lang.reflect.Constructor.newInstance0(Native Method) 
        at java.lang.reflect.Constructor.newInstance(Constructor.java:430) 
        at android.view.LayoutInflater.createView(LayoutInflater.java:656) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:798) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:738) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:869) 
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:832) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:518) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:426) 
        at org.xutils.view.d.inject(ViewInjectorImpl.java:107) 
        at com.xxx.xxxcommonlibrary.base.BaseFragment.onCreateView(BaseFragment.java:38) 
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:2354) 
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419) 
        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740) 
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809) 
        at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799) 
        at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580) 
        at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367) 
        at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322) 
        at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229) 
        at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:700) 
        at android.os.Handler.handleCallback(Handler.java:761) 
        at android.os.Handler.dispatchMessage(Handler.java:98) 
        at android.os.Looper.loop(Looper.java:156) 
        at android.app.ActivityThread.main(ActivityThread.java:6623) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832) 
     Caused by: java.io.FileNotFoundException: res.json
        at android.content.res.AssetManager.openAsset(Native Method)
        at android.content.res.AssetManager.open(AssetManager.java:682)
        at android.content.res.AssetManager.open(AssetManager.java:656)
        at com.baidu.platform.comapi.c.c.<init>(Unknown Source) 
        at com.baidu.platform.comapi.c.b.<init>(Unknown Source) 
        at com.baidu.platform.comapi.c.b.<clinit>(Unknown Source) 
        at com.baidu.platform.comapi.b.c(Unknown Source) 
        at com.baidu.mapsdkplatform.comapi.map.i.a(Unknown Source) 
        at com.baidu.mapapi.map.TextureMapView.a(Unknown Source) 
        at com.baidu.mapapi.map.TextureMapView.<init>(Unknown Source) 
        at java.lang.reflect.Constructor.newInstance0(Native Method) 
        at java.lang.reflect.Constructor.newInstance(Constructor.java:430) 
        at android.view.LayoutInflater.createView(LayoutInflater.java:656) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:798) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:738) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:869) 
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:832) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:518) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:426) 
        at org.xutils.view.d.inject(ViewInjectorImpl.java:107) 
        at com.xxx.xxxcommonlibrary.base.BaseFragment.onCreateView(BaseFragment.java:38) 
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:2354) 
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419) 
        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740) 
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809) 
        at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799) 
        at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580) 
        at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367) 
        at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322) 
        at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229) 
        at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:700) 
        at android.os.Handler.handleCallback(Handler.java:761) 
        at android.os.Handler.dispatchMessage(Handler.java:98) 
        at android.os.Looper.loop(Looper.java:156) 
        at android.app.ActivityThread.main(ActivityThread.java:6623) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832) 
2020-09-15 20:29:02.293 18025-18025/com.xxx.xxx E/x_log:d.a(L:170): Invalid @ViewInject for MonitorFragment.A
    java.lang.RuntimeException: Invalid @ViewInject for MonitorFragment.A
        at org.xutils.view.d.a(ViewInjectorImpl.java:167)
        at org.xutils.view.d.inject(ViewInjectorImpl.java:115)
        at com.xxx.xxxcommonlibrary.base.BaseFragment.onCreateView(BaseFragment.java:38)
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:2354)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419)
        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809)
        at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799)
        at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580)
        at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367)
        at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322)
        at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229)
        at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:700)
        at android.os.Handler.handleCallback(Handler.java:761)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:156)
        at android.app.ActivityThread.main(ActivityThread.java:6623)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832) 

   删除所有 build 文件夹,重新编译运行,完美解决。。。

   这个问题坑了我大半天,写下来记录一下问题的排查过程,若能为广大开发者节约一点宝贵的时间,那也算我做了一点有意义的事情。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hgxydn

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值