简体   繁体   English

java.lang.NoClassDefFoundError:无法解决以下问题:Landroidx / arch / core / util / Cancellable

[英]java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/arch/core/util/Cancellable

I split my app project into other modules and after implementing DI and splitting the dependencies across the modules, I get this exception: 我将我的应用程序项目拆分为其他模块,并在实现DI并拆分了模块之间的依赖关系后,遇到了以下异常:

java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/arch/core/util/Cancellable;
        at androidx.activity.ComponentActivity.<init>(ComponentActivity.java:69)
        at androidx.fragment.app.FragmentActivity.<init>(FragmentActivity.java:118)
        at androidx.appcompat.app.AppCompatActivity.<init>(AppCompatActivity.java:77)

Then, I check the ComponentActivity class and, yes, said class can´t find the Cancellable class. 然后,我检查ComponentActivity类,是的,说该类找不到Cancellable类。

package androidx.activity;  

import static android.os.Build.VERSION.SDK_INT;  

import android.os.Build;  
import android.os.Bundle;  
import android.view.View;  
import android.view.Window;  

import androidx.annotation.CallSuper;  
import androidx.annotation.ContentView;  
import androidx.annotation.LayoutRes;  
import androidx.annotation.NonNull;  
import androidx.annotation.Nullable;  
import androidx.arch.core.util.Cancellable; // <---- This class can't be found!
import androidx.lifecycle.GenericLifecycleObserver;  
import androidx.lifecycle.Lifecycle;  
import androidx.lifecycle.LifecycleOwner;  
import androidx.lifecycle.LifecycleRegistry;  
import androidx.lifecycle.ReportFragment;  
import androidx.lifecycle.ViewModelStore;  
import androidx.lifecycle.ViewModelStoreOwner;  
import androidx.savedstate.SavedStateRegistry;  
import androidx.savedstate.SavedStateRegistryController;  
import androidx.savedstate.SavedStateRegistryOwner;  

import java.util.WeakHashMap;  

/**  
 * Base class for activities that enables composition of higher level components. * <p>  
  * Rather than all functionality being built directly into this class, only the minimal set of  
 * lower level building blocks are included. Higher level components can then be used as needed * without enforcing a deep Activity class hierarchy or strong coupling between components. */public class ComponentActivity extends androidx.core.app.ComponentActivity implements  
  LifecycleOwner,  
  ViewModelStoreOwner,  
  SavedStateRegistryOwner {

After taking a look at the package, I decided to add this dependency: 看完软件包后,我决定添加此依赖项:

implementation "androidx.core:core:1.1.0-alpha05"

yet, it still fails. 但是,它仍然失败。

Then I checked some questions here in StackOverflow that recommended use Multidex, so, I enabled mutlidex in my build.gradle file but yet, it still fails 然后,我在StackOverflow中检查了一些建议使用Multidex的问题,因此,我在build.gradle文件中启用了mutlidex,但仍然失败

I added Multidex like this: 我这样添加了Multidex:

implementation "androidx.multidex:multidex:2.0.0"

build.gradle 的build.gradle

defaultConfig {  
// Config stuff
  multiDexEnabled = true  
}

and making my Application class extend the MultiDexApplication class, yet, it still fails 并使我的Application类扩展MultiDexApplication类,但是,它仍然失败

Seems like im missing a dependency here, but I can't find it. 好像我在这里缺少依赖项,但我找不到它。 :c :C

As per the androidx.arch.core release notes : 根据androidx.arch.core发行说明

The Cancellable interface has been deprecated due to a lack of composable infrastructure and its removal from public API in androidx.activity 1.0.0-alpha07 . 由于缺少可组合的基础结构,并且已从androidx.activity 1.0.0-alpha07公共API中删除了该接口,因此不推荐使用Cancellable接口。 ( aosp/945461 ) aosp / 945461

Therefore you should upgrade to Activity 1.0.0-alpha07 or higher to remove ComponentActivity's dependency on Cancellable . 因此,您应该升级到Activity 1.0.0-alpha07或更高版本,以删除ComponentActivity对Cancellable的依赖。 This is automatically done when you upgrade to Fragments 1.1.0-alpha07 or higher. 当您升级到Fragments 1.1.0-alpha07或更高版本时,将自动完成此操作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java.Lang.NoClassDefFoundError: '解析失败: Landroidx/arch/core/executor/ArchTaskExecutor;' - Java.Lang.NoClassDefFoundError: 'Failed resolution of: Landroidx/arch/core/executor/ArchTaskExecutor;' java.lang.NoClassDefFoundError:解析失败:Landroidx / core / app / ActivityManagerCompat - java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/app/ActivityManagerCompat java.lang.NoClassDefFoundError:解析失败:Landroidx/core/view/MenuHost; - java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/view/MenuHost; java.lang.NoClassDefFoundError:解析失败:Landroidx/appcompat/app/AppCompatActivity - java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/appcompat/app/AppCompatActivity java.lang.NoClassDefFoundError:解析失败:Landroidx/appcompat/app/AppCompatActivity; - java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/appcompat/app/AppCompatActivity; java.lang.NoClassDefFoundError:更新 Gradle Android 插件时失败的解析:Landroidx/work/R - java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/work/R when updating Gradle Android Plugin Android Espresso:java.lang.NoClassDefFoundError:解析失败:Landroidx/test/platform/io/FileTestStorage; - Android Espresso: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/test/platform/io/FileTestStorage; Xamarin.Android 绑定 Java.Lang.NoClassDefFoundError: '解析失败: Landroidx/viewbinding/ViewBinding;' - Xamarin.Android binding Java.Lang.NoClassDefFoundError: 'Failed resolution of: Landroidx/viewbinding/ViewBinding;' 将 androidx.room 打包到 aar 库中的项目导致 java.lang.NoClassDefFoundError:解析失败:Landroidx/room/RoomDatabase - Project with androidx.room packed into aar library causes java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/room/RoomDatabase java.lang.NoClassDefFoundError:解析失败:MyClass - java.lang.NoClassDefFoundError: Failed resolution of: MyClass
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM