我有相同的代碼:NoClassDefFoundError的設備上
public static void clearCacheWithoutMainActivity()
{
try
{
viewModelForClass.entrySet().removeIf(e -> !e.getKey().equals(className));
}
catch(NoClassDefFoundError e)
{
int k = 0;
}
}
private static Map<String, Pair<BaseObservable, Date>> viewModelForClass = new LinkedHashMap<>();
private static final String className = MainActivity.class.getName();
在仿真機器人。我不明白錯誤的NoClassDefFoundError。但在我的設備這個Android 5.1我抓住了這個錯誤。
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "ca.amikash.cashback"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
dexOptions {
preDexLibraries = false
jumboMode = false
maxProcessCount 4
javaMaxHeapSize "6g"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
我的build.gradle文件。這可能是錯誤的?
java.lang.NoClassDefFoundError:ca.amikash.cashback.ViewModelProvider $$ LAMBDA $ 1只是這個錯誤。擴展MultiDexApplication - 沒有幫助我 –
您是否正在使用具有ca.amikash.cashback.ViewModelProvider類的庫項目? –
在類TheApplication擴展MultiDexApplication我使用ViewModelProvider.clearCacheWithoutMainActivity(); –