[英]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 inandroidx.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.