gpt4 book ai didi

android - 如何修复 'NoClassDefFoundError: Failed resolution of: ActivityName'

转载 作者:行者123 更新时间:2023-12-03 05:41:49 24 4
gpt4 key购买 nike

我的应用在开始时崩溃,并产生以下错误。

The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.



因此,为了纠正错误,我将build.gradle(project level)从
    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.



但是上面的更改发生了另一个错误,当我们将 Activity 从一个调用到另一个我无法解决的错误时,会在运行时创建该错误,如下所示。

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/..../insta/InstaSplashActivity;



在这里, InstaSplashActivity是将从第一个 Activity (将导致崩溃的 Activity )中调用的 Activity 。

最佳答案

根据documentation抛出:

If the Java Virtual Machine or a ClassLoader instance tries to load inthe definition of a class (as part of a normal method call or as partof creating a new instance using the new expression) and no definitionof 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 yourproject and for all other library projects you are using.

关于android - 如何修复 'NoClassDefFoundError: Failed resolution of: ActivityName',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52503992/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com