我正在使用LayoutInflater.inflate(int resourceId,ViewGroup組)來誇大我的應用程序中的一些視圖。但是,當我困惑後運行的應用程序使用ProGuard我得到這個錯誤:混淆錯誤 - NoSuchMethodError:android.view.LayoutInflater.inflate
ERROR/AndroidRuntime(30511): java.lang.NoSuchMethodError: android.view.LayoutInflater.inflate
這是我的ProGuard配置:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-ignorewarnings
-libraryjars ...
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class com.android.vending.licensing.ILicensingService
-keep public class ...
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
我意識到,在這條線是應用程序崩潰:
setContentView(mLayoutInflator.inflate(mUiResources.getLayout(mUiResources.getIdentifier("main", "layout", mUiPackage)), null));
全貌:
String mUiPackage = mSettings.getString(mResources.getString(R.string.ui_package), getPackageName());
try {
mUiResources = getPackageManager().getResourcesForApplication(mUiPackage);
} catch (NameNotFoundException e) {}
try {
mUiContext = getApplicationContext().createPackageContext(mUiPackage, Context.CONTEXT_IGNORE_SECURITY | Context.CONTEXT_INCLUDE_CODE);
mLayoutInflator = (LayoutInflater) mUiContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
} catch (NameNotFoundException e) {}
setContentView(mLayoutInflator.inflate(mUiResources.getLayout(mUiResources.getIdentifier("main", "layout", mUiPackage)), null));
如果我改變問題字符串
setContentView(R.layout.main);
問題消失。但我需要第一個案例。你能幫我找到解決這個問題的辦法嗎?
您是否使用android工具自動生成的cfg文件? –
是的。我正在使用自動生成的cfg文件,對我的庫和一些類進行了一些更改,以便公開他們的字段和方法 – MistaGreen
您可以發佈整個事情嗎? –