how to fix 'NoClassDefFoundError: Failed resolution of: ActivityName'
how to fix 'NoClassDefFoundError: Failed resolution of: ActivityName'
我的应用程序在开始时崩溃并生成以下错误。
The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
因此,为了修复错误,我将 build.gradle(项目级别)从
更改为
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'io.fabric.tools:gradle:1.25.4'`
到
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.1.0'
classpath 'io.fabric.tools:gradle:1.25.4'
和build.gradle(应用级别)
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.android.gms:play-services-gcm:11.8.0'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-crash:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.3'
至
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-crash:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
更改以上 gradle 代码后,我的项目 运行 很好,没有出现以下错误。
The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
但是上面的 gradle 更改产生了另一个错误,当我们从一个调用到另一个我无法解决的 activity 时,它是在运行时创建的,如下所示。
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/..../insta/InstaSplashActivity;
这里,InstaSplashActivity
是一个 activity,将从第一个 activity 开始调用,这会造成崩溃。
基于 documentation,这是抛出的:
If the Java Virtual Machine or a ClassLoader instance tries to load in
the definition of a class (as part of a normal method call or as part
of creating a new instance using the new expression) and no definition
of the class could be found.
这里提供了解决方案 SO post:
- Go to "Properties" of the project.
- Select "Java Build Path"
- Select "Order and Export" Tab
- You should see the selected project's "src" and "gen" paths and dependencies here.
- The order how they listed were first "src" and then "gen" path
- I switch them, so that "gen" folder is build before the "src"
gen - automated code in project (from dependencies and references)
src - source code in project
or
Try going to Project -> Properties -> Java Build Path -> Order &
Export and ensure Android Private Libraries are checked for your
project and for all other library projects you are using.
删除你的行
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
构建项目
添加这一行
implementation 'com.google.android.gms:play-services:3.2.+'
重新构建
还是不行,通过模块设置中的依赖添加你的行
只需卸载 quick-heal 即可解决此问题。
quick-heal 不允许 运行 dex 文件,在 运行ning 时它会自动修复 android 工作室的一些后端文件所以,android studio 无法正确获取文件,所以我完全删除了 quick-heal,现在我的项目运行良好:)
我的应用程序在开始时崩溃并生成以下错误。
The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
因此,为了修复错误,我将 build.gradle(项目级别)从
更改为 classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'io.fabric.tools:gradle:1.25.4'`
到
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.1.0'
classpath 'io.fabric.tools:gradle:1.25.4'
和build.gradle(应用级别)
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.android.gms:play-services-gcm:11.8.0'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-crash:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.3'
至
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-crash:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
更改以上 gradle 代码后,我的项目 运行 很好,没有出现以下错误。
The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
但是上面的 gradle 更改产生了另一个错误,当我们从一个调用到另一个我无法解决的 activity 时,它是在运行时创建的,如下所示。
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/..../insta/InstaSplashActivity;
这里,InstaSplashActivity
是一个 activity,将从第一个 activity 开始调用,这会造成崩溃。
基于 documentation,这是抛出的:
If the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.
这里提供了解决方案 SO post:
- Go to "Properties" of the project.
- Select "Java Build Path"
- Select "Order and Export" Tab
- You should see the selected project's "src" and "gen" paths and dependencies here.
- The order how they listed were first "src" and then "gen" path
- I switch them, so that "gen" folder is build before the "src"
gen - automated code in project (from dependencies and references)
src - source code in project
or
Try going to Project -> Properties -> Java Build Path -> Order & Export and ensure Android Private Libraries are checked for your project and for all other library projects you are using.
删除你的行
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
构建项目
添加这一行
implementation 'com.google.android.gms:play-services:3.2.+'
重新构建
还是不行,通过模块设置中的依赖添加你的行
只需卸载 quick-heal 即可解决此问题。
quick-heal 不允许 运行 dex 文件,在 运行ning 时它会自动修复 android 工作室的一些后端文件所以,android studio 无法正确获取文件,所以我完全删除了 quick-heal,现在我的项目运行良好:)