发布后 Kitkat 4.4 ANR 错误
Kitkat 4.4 ANR errors after publish
伙计们,我有两个问题:
1) 如何在我设置的 minSDK 版本的每个 api 上测试完整的应用程序(我的意思是 运行 测试,而不是单元)。这是任何自动过程吗?
2) 发布我的应用程序后,我的应用程序发布控制台出现 ANR 错误(系统 运行 4.4 Kitkat):
java.lang.RuntimeException:
at android.app.ActivityThread.installProvider(ActivityThread.java:5011)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4582)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4522)
at android.app.ActivityThread.access00(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method:0)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method:0)
Caused by: java.lang.ClassNotFoundException:
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.ActivityThread.installProvider(ActivityThread.java:4996)
我在我的 android 工作室中设置了具有类似配置的 avd 模拟器,我在编译后出现以下异常:
1829-2839/com.google.android.gms.persistent E/LoadManifestTask: Can't find Chimera operation impl class com.google.android.location.copresence.GcmRegistrationChimeraReceiver dropping operation
java.lang.ClassNotFoundException: Didn't find class "com.google.android.location.copresence.GcmRegistrationChimeraReceiver" on path: DexPathList[[zip file "/system/framework/com.android.media.remotedisplay.jar", zip file "/system/framework/com.android.location.provider.jar", zip file "/system/priv-app/PrebuiltGmsCore.apk", zip file "/data/data/com.google.android.gms/code_cache/secondary-dexes/PrebuiltGmsCore.apk.classes2.zip", zip file "/data/data/com.google.android.gms/code_cache/secondary-dexes/PrebuiltGmsCore.apk.classes3.zip", zip file "/data/data/com.google.android.gms/code_cache/secondary-dexes/PrebuiltGmsCore.apk.classes4.zip", zip file "/data/data/com.google.android.gms/code_cache/secondary-dexes/PrebuiltGmsCore.apk.classes5.zip"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at bws.<init>(:com.google.android.gms:799)
at bwt.run(:com.google.android.gms:2049)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
[ 05-25 03:04:16.195 1623: 1638 D/ ]
HostConnection::get() New Host Connection established 0xb9183a30, tid 1638
知道是什么导致了这个问题吗?
我的应用程序在 Lollipop 和 Nugat 上运行良好。
我也粘贴了我的 gradle:
应用插件:'com.android.application'
应用插件:'realm-android'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId 'com.fff.hhh'
minSdkVersion 15
targetSdkVersion 25
versionCode 8
versionName '4.0'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.google.android.gms:play-services:10.2.6'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.github.bumptech.glide:glide:3.8.0'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.jakewharton:butterknife:8.5.1'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
}
如官方所述docs:
You are strongly encouraged to use the GoogleApiClient
class to
access Google Play services features. This approach allows you to
attach an OnConnectionFailedListener
object to your client. To
detect if the device has the appropriate version of the Google Play
services APK, implement the onConnectionFailed()
callback method. If
the connection fails due to a missing or out-of-date version of the
Google Play APK, the callback receives an error code such as
SERVICE_MISSING
, SERVICE_VERSION_UPDATE_REQUIRED
, or
SERVICE_DISABLED
. ... Another approach is to use the
isGooglePlayServicesAvailable()
method. You get a reference to the
singleton object that provides this method using
GoogleApiAvailability.getInstance()
. You might call this method in
the onResume()
method of the main activity. If the result code is
SUCCESS
, then the Google Play services APK is up-to-date and you can
continue to make a connection.
请确保您遵守这些规则。
针对特定版本测试应用程序:
1. Write espresso test
2. run those tests on the device with desired api level
解决gcm问题添加
apply plugin: 'com.google.gms.google-services'
在上面粘贴的 build.gradle 末尾。
伙计们,我有两个问题: 1) 如何在我设置的 minSDK 版本的每个 api 上测试完整的应用程序(我的意思是 运行 测试,而不是单元)。这是任何自动过程吗? 2) 发布我的应用程序后,我的应用程序发布控制台出现 ANR 错误(系统 运行 4.4 Kitkat):
java.lang.RuntimeException:
at android.app.ActivityThread.installProvider(ActivityThread.java:5011)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4582)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4522)
at android.app.ActivityThread.access00(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method:0)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method:0)
Caused by: java.lang.ClassNotFoundException:
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.ActivityThread.installProvider(ActivityThread.java:4996)
我在我的 android 工作室中设置了具有类似配置的 avd 模拟器,我在编译后出现以下异常:
1829-2839/com.google.android.gms.persistent E/LoadManifestTask: Can't find Chimera operation impl class com.google.android.location.copresence.GcmRegistrationChimeraReceiver dropping operation
java.lang.ClassNotFoundException: Didn't find class "com.google.android.location.copresence.GcmRegistrationChimeraReceiver" on path: DexPathList[[zip file "/system/framework/com.android.media.remotedisplay.jar", zip file "/system/framework/com.android.location.provider.jar", zip file "/system/priv-app/PrebuiltGmsCore.apk", zip file "/data/data/com.google.android.gms/code_cache/secondary-dexes/PrebuiltGmsCore.apk.classes2.zip", zip file "/data/data/com.google.android.gms/code_cache/secondary-dexes/PrebuiltGmsCore.apk.classes3.zip", zip file "/data/data/com.google.android.gms/code_cache/secondary-dexes/PrebuiltGmsCore.apk.classes4.zip", zip file "/data/data/com.google.android.gms/code_cache/secondary-dexes/PrebuiltGmsCore.apk.classes5.zip"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at bws.<init>(:com.google.android.gms:799)
at bwt.run(:com.google.android.gms:2049)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
[ 05-25 03:04:16.195 1623: 1638 D/ ]
HostConnection::get() New Host Connection established 0xb9183a30, tid 1638
知道是什么导致了这个问题吗? 我的应用程序在 Lollipop 和 Nugat 上运行良好。 我也粘贴了我的 gradle: 应用插件:'com.android.application' 应用插件:'realm-android'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId 'com.fff.hhh'
minSdkVersion 15
targetSdkVersion 25
versionCode 8
versionName '4.0'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.google.android.gms:play-services:10.2.6'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.github.bumptech.glide:glide:3.8.0'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.jakewharton:butterknife:8.5.1'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
}
如官方所述docs:
You are strongly encouraged to use the
GoogleApiClient
class to access Google Play services features. This approach allows you to attach anOnConnectionFailedListener
object to your client. To detect if the device has the appropriate version of the Google Play services APK, implement theonConnectionFailed()
callback method. If the connection fails due to a missing or out-of-date version of the Google Play APK, the callback receives an error code such asSERVICE_MISSING
,SERVICE_VERSION_UPDATE_REQUIRED
, orSERVICE_DISABLED
. ... Another approach is to use theisGooglePlayServicesAvailable()
method. You get a reference to the singleton object that provides this method usingGoogleApiAvailability.getInstance()
. You might call this method in theonResume()
method of the main activity. If the result code isSUCCESS
, then the Google Play services APK is up-to-date and you can continue to make a connection.
请确保您遵守这些规则。
针对特定版本测试应用程序:
1. Write espresso test
2. run those tests on the device with desired api level
解决gcm问题添加
apply plugin: 'com.google.gms.google-services'
在上面粘贴的 build.gradle 末尾。