得到 java.lang.RuntimeException ... 原因:java.lang.ClassNotFoundException 从 Google Play 安装后首次启动应用程序
Got java.lang.RuntimeException ... Caused by: java.lang.ClassNotFoundException after first startup of app after install from GooglePlay
迁移到androidX后,开始出现RuntimeException。按照此处的说明进行操作 https://developer.android.com/jetpack/androidx/migrate
和这里
https://developer.android.com/jetpack/androidx/migrate#migrate
迁移现有项目
在我构建 .apk(用于发布)并在本地安装它之后,一切都很好。但是在我将 .apk 上传到 Google Play 并在首次启动应用程序时从 GP download/install 上传它后,我收到了这个错误
java.lang.RuntimeException:
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3785)
at android.app.ActivityThread.-wrap18 (Unknown Source)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2082)
at android.os.Handler.dispatchMessage (Handler.java:108)
at android.os.Looper.loop (Looper.java:166)
at android.app.ActivityThread.main (ActivityThread.java:7529)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:245)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:921)
Caused by: java.lang.ClassNotFoundException:
at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass (ClassLoader.java:379)
at java.lang.ClassLoader.loadClass (ClassLoader.java:312)
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3780)
关闭应用程序重新启动它,一切正常......我搜索了很多但找不到任何解决方案为什么会发生这种情况。只有从 GP 下载后,我才能在本地复制它。
这是我的build.gradle(Module: app),只是重要的部分
defaultConfig {
applicationId "com.xxxxxxxx not important xxxxxxxx"
minSdkVersion 19
targetSdkVersion 28
versionCode 3
versionName "1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.android.gms:play-services-ads:18.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'jp.wasabeef:picasso-transformations:2.2.1'
implementation 'com.android.support:palette-v7:28.0.0'
implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.0.2'
//recycleview library
implementation 'com.android.support:recyclerview-v7:28.0.0'
//cardview library
implementation 'com.android.support:cardview-v7:28.0.0'
//circle indicator
implementation 'me.relex:circleindicator:1.2.2'
implementation 'com.google.code.gson:gson:2.8.5'
}
这是我的manifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
<meta-data
tools:replace="android:value"
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="xxxxxxxxxxx"/>
清单的其余部分仅为活动列表。
我只是不明白为什么这种情况只发生在应用程序的第一顿午餐,接下来的每一顿午餐都很好。一些建议??
使用
com.google.android.gms:play-services-ads:17.2.1
迁移到androidX后,开始出现RuntimeException。按照此处的说明进行操作 https://developer.android.com/jetpack/androidx/migrate 和这里 https://developer.android.com/jetpack/androidx/migrate#migrate 迁移现有项目 在我构建 .apk(用于发布)并在本地安装它之后,一切都很好。但是在我将 .apk 上传到 Google Play 并在首次启动应用程序时从 GP download/install 上传它后,我收到了这个错误
java.lang.RuntimeException:
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3785)
at android.app.ActivityThread.-wrap18 (Unknown Source)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2082)
at android.os.Handler.dispatchMessage (Handler.java:108)
at android.os.Looper.loop (Looper.java:166)
at android.app.ActivityThread.main (ActivityThread.java:7529)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:245)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:921)
Caused by: java.lang.ClassNotFoundException:
at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass (ClassLoader.java:379)
at java.lang.ClassLoader.loadClass (ClassLoader.java:312)
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3780)
关闭应用程序重新启动它,一切正常......我搜索了很多但找不到任何解决方案为什么会发生这种情况。只有从 GP 下载后,我才能在本地复制它。 这是我的build.gradle(Module: app),只是重要的部分
defaultConfig {
applicationId "com.xxxxxxxx not important xxxxxxxx"
minSdkVersion 19
targetSdkVersion 28
versionCode 3
versionName "1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.android.gms:play-services-ads:18.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'jp.wasabeef:picasso-transformations:2.2.1'
implementation 'com.android.support:palette-v7:28.0.0'
implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.0.2'
//recycleview library
implementation 'com.android.support:recyclerview-v7:28.0.0'
//cardview library
implementation 'com.android.support:cardview-v7:28.0.0'
//circle indicator
implementation 'me.relex:circleindicator:1.2.2'
implementation 'com.google.code.gson:gson:2.8.5'
}
这是我的manifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
<meta-data
tools:replace="android:value"
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="xxxxxxxxxxx"/>
清单的其余部分仅为活动列表。
我只是不明白为什么这种情况只发生在应用程序的第一顿午餐,接下来的每一顿午餐都很好。一些建议??
使用
com.google.android.gms:play-services-ads:17.2.1