![](/img/trans.png)
[英]Java.Lang.NoClassDefFoundError: 'Failed resolution of: Landroidx/arch/core/executor/ArchTaskExecutor;'
[英]java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/arch/core/util/Cancellable
我將我的應用程序項目拆分為其他模塊,並在實現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)
然后,我檢查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 {
看完軟件包后,我決定添加此依賴項:
implementation "androidx.core:core:1.1.0-alpha05"
但是,它仍然失敗。
然后,我在StackOverflow中檢查了一些建議使用Multidex的問題,因此,我在build.gradle
文件中啟用了mutlidex,但仍然失敗
我這樣添加了Multidex:
implementation "androidx.multidex:multidex:2.0.0"
的build.gradle
defaultConfig {
// Config stuff
multiDexEnabled = true
}
並使我的Application
類擴展MultiDexApplication
類,但是,它仍然失敗
好像我在這里缺少依賴項,但我找不到它。 :C
由於缺少可組合的基礎結構,並且已從
androidx.activity 1.0.0-alpha07
公共API中刪除了該接口,因此不推薦使用Cancellable
接口。 ( aosp / 945461 )
因此,您應該升級到Activity 1.0.0-alpha07或更高版本,以刪除ComponentActivity對Cancellable
的依賴。 當您升級到Fragments 1.1.0-alpha07或更高版本時,將自動完成此操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.