我正在使用LayoutInflater.inflate(int resourceId,ViewGroup group)在我的应用程序中放大一些视图。但是当我在使用proguard进行混淆之后运行app时,我得到了这个错误:
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);问题消失了。但我需要第一个案子。你能帮我找到解决这个问题的办法吗?
发布于 2011-10-07 04:24:44
最有可能的是,问题是由选项-ignorewarnings引起的。您应该查看警告并尝试解决它们。如果有必要,您仍然可以为特定的类指定-dontwarn,您可以确定这些类在程序的执行过程中实际上不会被使用。
发布于 2011-10-12 06:31:10
该proguard配置是使用旧版本的android SDK生成的。更新到最新版本的构建工具,并从命令行导航到项目的根目录(其中包含AndroidManifest.xml的目录),然后键入以下内容:
安卓更新项目-p。
它应该会为你生成一个新的proguard配置文件--你可以检查并确保"keepclasseswithmembers“的实例更改为”keepclasseswithmembers“(我认为还有其他更改,但不确定)。看看能不能修好它。
发布于 2011-11-06 22:56:36
升级到最新的ProGuard 4.6。当我使用Android SDK自带的ProGuard (即使是最新的)时,我也遇到了类似的错误,但它不是最新的ProGuard版本。下载并替换为ANDROID_SDK/tool/proguard下的proguard文件夹。这为我解决了这个问题。不确定它是否也适用于你的情况,我的与增压泵无关,然而,我得到了一个错误,它就是没有任何意义(对于旧的ProGuard版本)。
https://stackoverflow.com/questions/7654549
复制相似问题