问题描述
- [Android地图sdk] 同样的app为什么在小米手机上闪退,在华为手机没问题。
-
刚接触百度地图api,今天用eclipse连真机调试,正常定位,但是用别人的小米打开app的时候闪退。我分别换了4.4和5.0都是一样。这是用小米调试时的错误信息:04-27 18:22:29.038: E/AndroidRuntime(20471): FATAL EXCEPTION: main
04-27 18:22:29.038: E/AndroidRuntime(20471): Process: com.example.routebaidumap, PID: 20471
04-27 18:22:29.038: E/AndroidRuntime(20471): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.routebaidumap/com.example.routebaidumap.MainActivity}: java.lang.NullPointerException
04-27 18:22:29.038: E/AndroidRuntime(20471): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2192)
04-27 18:22:29.038: E/AndroidRuntime(20471): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2241)
04-27 18:22:29.038: E/AndroidRuntime(20471): at android.app.ActivityThread.access$800(ActivityThread.java:141)
04-27 18:22:29.038: E/AndroidRuntime(20471): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1204)
04-27 18:22:29.038: E/AndroidRuntime(20471): at android.os.Handler.dispatchMessage(Handler.java:102)
04-27 18:22:29.038: E/AndroidRuntime(20471): at android.os.Looper.loop(Looper.java:136)
04-27 18:22:29.038: E/AndroidRuntime(20471): at android.app.ActivityThread.main(ActivityThread.java:5049)
04-27 18:22:29.038: E/AndroidRuntime(20471): at java.lang.reflect.Method.invokeNative(Native Method)
04-27 18:22:29.038: E/AndroidRuntime(20471): at java.lang.reflect.Method.invoke(Method.java:515)
04-27 18:22:29.038: E/AndroidRuntime(20471): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-27 18:22:29.038: E/AndroidRuntime(20471): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
04-27 18:22:29.038: E/AndroidRuntime(20471): at dalvik.system.NativeStart.main(Native Method)
04-27 18:22:29.038: E/AndroidRuntime(20471): Caused by: java.lang.NullPointerException
04-27 18:22:29.038: E/AndroidRuntime(20471): at com.example.routebaidumap.MainActivity.onCreate(MainActivity.java:40)
04-27 18:22:29.038: E/AndroidRuntime(20471): at android.app.Activity.performCreate(Activity.java:5249)
04-27 18:22:29.038: E/AndroidRuntime(20471): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-27 18:22:29.038: E/AndroidRuntime(20471): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2156)
04-27 18:22:29.038: E/AndroidRuntime(20471): ... 11 more
解决方案
如果代码完全一样的话,在不同手机上运行结果不一样,你要考虑下是否有可能是芯片架构不一样造成的,既然报空指针异常,应该是某个参数
没有初始化成功,而且这个参数应该和底层联系比较紧密,重点排查下jni调用,lib 库的预置是否做了适配,芯片有armeabi,x86等不同架构,
要放到不同的文件夹下
解决方案二:
MainActivity.onCreate(MainActivity.java:40)
这个地方空指针了。
解决方案三:
Android很多系统activity都被小米篡改了,不能直接调用
解决方案四:
应该是动态库的问题 你把libs里带有64的文件夹都删掉看看