Android版本一直在更新,当前在市面上还没有Android Q(10)机子的时候,在一些应用市场上都要求要适配最新的版本了。怎么测试呢,有些云测试平台就有相应的机型可以测试。
今天要说的是,明明9以下可以运行的APP,为什么在更新之后,上传到市场会报崩溃呢?当然是有原因的,这个篇日志以后会一直更新下去,遇到问题,我会追加在这里。
Crash 1 ClassNotFoundException
问题
在8上,7上都正常运行的app,在9上就崩溃了
1
2
3
4
5
6
7
8
9
10E/AndroidRuntime: FATAL EXCEPTION: Thread-7
Process: com.xxx.xxx, PID: 27859
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/impl/client/DefaultHttpClient;
at com.xx.utils.HttpClientUtils.getResponse(HttpClientUtils.java:77)
at com.xx.xx.client.xxx.toQueryVioltionByCarAction(WeizhangApiClient.java:133)
at com.xx.xx.activity.XXX$4.run(WeizhangResult.java:175)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.impl.client.DefaultHttpClient" on path: DexPathList[[zip file "/data/app/com.xx.xxx-x4rPsfE4-lIkyVKxOSYlXA==/base.apk"],nativeLibraryDirectories=[/data/app/com.xx.xxx-x4rPsfE4-lIkyVKxOSYlXA==/lib/arm64, /data/app/com.xx.xxx-x4rPsfE4-lIkyVKxOSYlXA==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /system/product/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:195)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
看看项目,这个类是存在的,但有一个细节:
1
2
3@Deprecated
public class DefaultHttpClient extends AbstractHttpClient{
}
已经不建议用了。
解决方法
很简单见链接
Specify requirement for Apache HTTP Legacy library
If you are using com.google.android.gms:play-services-maps:16.0.0 or below and your app is targeting API level 28 (Android 9.0) or above, you must include the following declaration within the element ofAndroidManifest.xml.
1
2
3
android:name="org.apache.http.legacy"
android:required="false" />