在我迁移到androidX之后,开始获取RuntimeException。从这里https://developer.android.com/jetpack/androidx/migrate开始按照指示进行 和这里 https://developer.android.com/jetpack/androidx/migrate#migrate 迁移现有项目 在我构建.apk(用于发布)并将其安装在本地之后,一切都很好。但是,当我将.apk上传到Google Play并在首次启动应用程序时从GP下载/安装它后,出现此错误
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"/>
清单的其余部分仅是活动列表。
我不明白为什么只在应用程序的第一顿午餐会发生这种情况,所以每隔一个午餐都很好。一些建议??
答案 0 :(得分:0)
使用
com.google.android.gms:play-services-ads:17.2.1