Android 更新后应用程序运行时崩溃 gradle 插件 3.6
Android App runtime crash after update gradle plugin 3.6
Android 应用程序没有崩溃,在将 Gradle 插件 更新到版本 3.6 后面临下面的运行时崩溃:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: my.package.app, PID: 9420
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/appcompat/R$drawable;
at androidx.appcompat.widget.AppCompatDrawableManager.<clinit>(AppCompatDrawableManager.java:113)
at androidx.appcompat.widget.AppCompatDrawableManager.get(Unknown Source:0)
at androidx.appcompat.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:86)
at androidx.appcompat.app.AppCompatDelegateImpl.<init>(AppCompatDelegateImpl.java:260)
at androidx.appcompat.app.AppCompatDelegate.create(AppCompatDelegate.java:182)
at androidx.appcompat.app.AppCompatActivity.getDelegate(AppCompatActivity.java:520)
at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
at my.package.app.abstracts.BaseActivity.onCreate(BaseActivity.java:94)
at my.package.app.ui.activity_splash.SplashActivity.onCreate(SplashActivity.java:48)
at android.app.Activity.performCreate(Activity.java:7335)
at android.app.Activity.performCreate(Activity.java:7326)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1275)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3119)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3282)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1970)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7156)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.appcompat.R$drawable" on path: DexPathList[[zip file "/data/app/my.package.app-ubNE5Y0S9Ec7hNJGohi9Sw==/base.apk"],nativeLibraryDirectories=[/data/app/my.package.app-ubNE5Y0S9Ec7hNJGohi9Sw==/lib/arm, /data/app/my.package.app-ubNE5Y0S9Ec7hNJGohi9Sw==/base.apk!/lib/armeabi-v7a, /system/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at androidx.appcompat.widget.AppCompatDrawableManager.<clinit>(AppCompatDrawableManager.java:113)
at androidx.appcompat.widget.AppCompatDrawableManager.get(Unknown Source:0)
at androidx.appcompat.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:86)
at androidx.appcompat.app.AppCompatDelegateImpl.<init>(AppCompatDelegateImpl.java:260)
at androidx.appcompat.app.AppCompatDelegate.create(AppCompatDelegate.java:182)
at androidx.appcompat.app.AppCompatActivity.getDelegate(AppCompatActivity.java:520)
at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
at my.package.app.abstracts.BaseActivity.onCreate(BaseActivity.java:94)
at my.package.app.ui.activity_splash.SplashActivity.onCreate(SplashActivity.java:48)
at android.app.Activity.performCreate(Activity.java:7335)
at android.app.Activity.performCreate(Activity.java:7326)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1275)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3119)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3282)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1970)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7156)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
ext.gradlVersion = '3.6.0'
...
classpath "com.android.tools.build:gradle:$gradlVersion"
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
在 AndroidX
中迁移您的项目后,首先对您的项目进行备份
- 转到工具栏进入重构
- 转到底部选项并select迁移到androidX
并迁移它。检查错误是否仍然发生。
首先将 实施到您的项目中,然后重新启动 android studio
和 运行 您的应用程序。
如果你仍然遇到这个问题,那么你需要降级你的 android studio's
稳定版本 3.5.3
低于 Android Studio 3.5
禁用即时 运行:
Android Studio --> File --> Setting --> Build, execution, deploy --> Instant run.
问题:Click Me ,
希望本文对您有所帮助
Android 应用程序没有崩溃,在将 Gradle 插件 更新到版本 3.6 后面临下面的运行时崩溃:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: my.package.app, PID: 9420
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/appcompat/R$drawable;
at androidx.appcompat.widget.AppCompatDrawableManager.<clinit>(AppCompatDrawableManager.java:113)
at androidx.appcompat.widget.AppCompatDrawableManager.get(Unknown Source:0)
at androidx.appcompat.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:86)
at androidx.appcompat.app.AppCompatDelegateImpl.<init>(AppCompatDelegateImpl.java:260)
at androidx.appcompat.app.AppCompatDelegate.create(AppCompatDelegate.java:182)
at androidx.appcompat.app.AppCompatActivity.getDelegate(AppCompatActivity.java:520)
at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
at my.package.app.abstracts.BaseActivity.onCreate(BaseActivity.java:94)
at my.package.app.ui.activity_splash.SplashActivity.onCreate(SplashActivity.java:48)
at android.app.Activity.performCreate(Activity.java:7335)
at android.app.Activity.performCreate(Activity.java:7326)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1275)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3119)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3282)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1970)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7156)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.appcompat.R$drawable" on path: DexPathList[[zip file "/data/app/my.package.app-ubNE5Y0S9Ec7hNJGohi9Sw==/base.apk"],nativeLibraryDirectories=[/data/app/my.package.app-ubNE5Y0S9Ec7hNJGohi9Sw==/lib/arm, /data/app/my.package.app-ubNE5Y0S9Ec7hNJGohi9Sw==/base.apk!/lib/armeabi-v7a, /system/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at androidx.appcompat.widget.AppCompatDrawableManager.<clinit>(AppCompatDrawableManager.java:113)
at androidx.appcompat.widget.AppCompatDrawableManager.get(Unknown Source:0)
at androidx.appcompat.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:86)
at androidx.appcompat.app.AppCompatDelegateImpl.<init>(AppCompatDelegateImpl.java:260)
at androidx.appcompat.app.AppCompatDelegate.create(AppCompatDelegate.java:182)
at androidx.appcompat.app.AppCompatActivity.getDelegate(AppCompatActivity.java:520)
at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
at my.package.app.abstracts.BaseActivity.onCreate(BaseActivity.java:94)
at my.package.app.ui.activity_splash.SplashActivity.onCreate(SplashActivity.java:48)
at android.app.Activity.performCreate(Activity.java:7335)
at android.app.Activity.performCreate(Activity.java:7326)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1275)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3119)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3282)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1970)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7156)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
ext.gradlVersion = '3.6.0'
...
classpath "com.android.tools.build:gradle:$gradlVersion"
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
在 AndroidX
- 转到工具栏进入重构
- 转到底部选项并select迁移到androidX
并迁移它。检查错误是否仍然发生。
首先将 android studio
和 运行 您的应用程序。
如果你仍然遇到这个问题,那么你需要降级你的 android studio's
稳定版本 3.5.3
低于 Android Studio 3.5
禁用即时 运行:
Android Studio --> File --> Setting --> Build, execution, deploy --> Instant run.
问题:Click Me ,
希望本文对您有所帮助