Proguard 告诉我“请先纠正上述警告。”。如何解决外部 jar 的引用?
我该如何解决这些警告?
日志说
[proguard] Note: duplicate definition of library class...
...
[proguard] Note: there were 370 duplicate class definitions.
[proguard] Initializing...
[proguard] Warning: abc.cba..: can't find superclass or interface xyz.zyx....
...
[proguard] Note: the configuration refers to the unknown class 'android.app.backup.BackupAgentHelper'...
...
[proguard] Warning: library class android.content.IntentFilter depends on program class org.xmlpull.v1.XmlSerializer...
...
proguard.cfg
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-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 * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keep public class !testAppH23.** { *; }
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
这是 Android Ant Build with Proguard Enabled 控制台日志。请查看链接 ant 构建控制台日志
这是我的 build.xml (基本上是 android 原始的 ant 脚本)。请查看链接 启用 Proguard 的 TestAppH23 Android Ant 构建
local.properties
sdk.dir=C:\\androiddev\\android-sdk-windows
build.properties
proguard.config=proguard.cfg
key.store=testapph23-release.keystore
key.alias=alisname
key.store.password=storepassword
key.alias.password=aliaspassword
default.properties
target=android-7
我对长帖子表示歉意。任何关于正确方向的指导都值得赞赏。
更新1 AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="testAppH23.activity"
android:versionCode="1"
android:versionName="1.0">
<application
android:icon="@drawable/home"
android:theme="@android:style/Theme.NoTitleBar"
android:label="@string/app_name"
>
<activity
android:name=".start.StartActivity"
android:label="@string/app_name"
android:theme="@style/Theme.Translucent"
android:screenOrientation="portrait"
android:launchMode="singleTask"
>
<intent-filter>
<action
android:name="android.intent.action.MAIN"
>
</action>
<category
android:name="android.intent.category.LAUNCHER"
>
</category>
</intent-filter>
</activity>
.....
<service android:name="com.abc.myjar.papi.PIntentService"></service>
<service android:name=".service.XyzService"></service>
</application>
<uses-library android:name="org.apache.http.entity"/>
<uses-library android:name="org.apache.http.james.mime4j"/>
<uses-permission android:name="android.permission...."/>
<uses-sdk android:minSdkVersion="7" />
</manifest>
How can I address the warnings?
Log says
[proguard] Note: duplicate definition of library class...
...
[proguard] Note: there were 370 duplicate class definitions.
[proguard] Initializing...
[proguard] Warning: abc.cba..: can't find superclass or interface xyz.zyx....
...
[proguard] Note: the configuration refers to the unknown class 'android.app.backup.BackupAgentHelper'...
...
[proguard] Warning: library class android.content.IntentFilter depends on program class org.xmlpull.v1.XmlSerializer...
...
proguard.cfg
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-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 * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keep public class !testAppH23.** { *; }
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
Here is the
Android Ant Build with Proguard Enabled console log. Please see the link
ant build console log
Here is my build.xml (basically its the android original ant script). Please see the link
TestAppH23 Android Ant Build With Proguard Enabled
local.properties
sdk.dir=C:\\androiddev\\android-sdk-windows
build.properties
proguard.config=proguard.cfg
key.store=testapph23-release.keystore
key.alias=alisname
key.store.password=storepassword
key.alias.password=aliaspassword
default.properties
target=android-7
My apology for long post. Any guidance on the right direction is appreciated.
UPDATES1
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="testAppH23.activity"
android:versionCode="1"
android:versionName="1.0">
<application
android:icon="@drawable/home"
android:theme="@android:style/Theme.NoTitleBar"
android:label="@string/app_name"
>
<activity
android:name=".start.StartActivity"
android:label="@string/app_name"
android:theme="@style/Theme.Translucent"
android:screenOrientation="portrait"
android:launchMode="singleTask"
>
<intent-filter>
<action
android:name="android.intent.action.MAIN"
>
</action>
<category
android:name="android.intent.category.LAUNCHER"
>
</category>
</intent-filter>
</activity>
.....
<service android:name="com.abc.myjar.papi.PIntentService"></service>
<service android:name=".service.XyzService"></service>
</application>
<uses-library android:name="org.apache.http.entity"/>
<uses-library android:name="org.apache.http.james.mime4j"/>
<uses-permission android:name="android.permission...."/>
<uses-sdk android:minSdkVersion="7" />
</manifest>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须向 ProGuard 保证输入 jar 中的一些可疑结构是正常的。
您的程序代码包含 org.xmlpull.v1 包中 Android 运行时类的副本或更好版本。如果没问题:
您的程序代码包含 org.apache.http 中 Android 运行时类的副本。如果没问题:
包示例中的程序代码引用了 AWT,而 Android 中不存在 AWT。如果没问题:
您的 PostgreSQL 驱动程序引用了许多 Android 中不存在的 javax 类。如果可以的话:
依此类推...
Cfr。 ProGuard手册> 故障排除
最后,您的配置指定
-keep public class !testAppH23.** { *;},它可以防止除
testAppH23
中的公共类及其公共/受保护/私有类成员之外的所有公共类被缩小/优化/混淆。这可能会导致一些有关描述符类的(无害的)注释。为了保持一致性,您可能需要删除类的“public”,或为类成员添加“public protected”。You have to reassure ProGuard that some suspicious constructs in the input jars are ok.
Your program code contains copies or better versions of Android runtime classes in the package org.xmlpull.v1. If that's ok:
Your program code contains copies of Android runtime classes in org.apache.http. If that's ok:
Your program code in the package examples refers to AWT, which doesn't exist in Android. If that's ok:
Your PostgreSQL driver refers to many javax classes that don't exist in Android. If that's ok:
And so on...
Cfr. ProGuard manual > Troubleshooting
Finally, your configuration specifies
-keep public class !testAppH23.** { *;}
, which keeps all public classes except those intestAppH23
, and their public/protected/private class members, from being shrunk/optimized/obfuscated. This may cause some (harmless) notes about descriptor classes. For consistency, you may want to remove "public" for the classes, or add "public protected" for the class members.您可以尝试解决:
You can try to resolve it:
您应该检查您的 strings.xml 资源并使其相等(如果存在)或添加 translatable="false"
You should check your strings.xml resources and make equal if exist or add translatable="false"