我正在使用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
您可以发布整个事情吗? –