gpt4 book ai didi

android - 使用 AWS SDK 的 ProGuard

转载 作者:太空狗 更新时间:2023-10-29 16:18:56 25 4
gpt4 key购买 nike

由于 Amazon AWS SDK 的问题,当启用 ProGuard 时,我的 Android 应用无法从 Eclipse 导出。

我使用的是适用于 Android 的 AWS SDK 1.6.1 版。

记录到控制台的错误如下所示。

我遵循了 Amazon 提供的推荐 ProGuard 配置设置,但无济于事:https://mobile.awsblog.com/post/Tx2OC71PFCTC63E/Using-ProGuard-with-the-AWS-SDK-for-Android

我也试过在 ProGuard 配置中排除 Amazon 类,但这也不起作用。

无论其值(value)如何,我已经下载了 Amazon 自己的示例项目并按照他们的说明启用了 ProGuard,但在导出项目时我收到了相同的 ProGuard 错误。

谁能告诉我一个有效的 ProGuard 配置以用于 AWS SDK?

这些是我项目中的 jar :

Simpl3r-1.0.2.jar
aws-android-sdk-1.6.1-core.jar
androidplot-core-0.6.0-sources.jar
universal-image-loader-1.8.6-with-sources.jar
android_lvl.jar
androidplot-core-0.6.0-javadoc.jar
androidplot-core-0.6.0.jar
gson-2.2.4.jar
date4j.jar
crittercism_v3_0_3_sdkonly.jar
aws-android-sdk-1.6.1-s3.jar
android-support-v7-appcompat.jar
CWAC-AdapterWrapper.jar
cwac-endless-master.jar
android-support-v4.jar

我的 ProGuard 配置如下:

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-dontoptimize
-dontpreverify

-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService

# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}

# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}

# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}

# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

-keepclassmembers class **.R$* {
public static <fields>;
}

# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
-dontwarn android.support.**


# AWS:
-keep class org.apache.commons.logging.** { *; }
-keep class com.amazonaws.services.sqs.QueueUrlHandler { *; }
-keep class com.amazonaws.javax.xml.transform.sax.* { public *; }
-keep class com.amazonaws.javax.xml.stream.** { *; }
-keep class com.amazonaws.services.**.model.*Exception* { *; }
-keep class org.codehaus.** { *; }
-keepattributes Signature,*Annotation*

-dontwarn javax.xml.stream.events.**
-dontwarn org.codehaus.jackson.**
-dontwarn org.apache.commons.logging.impl.**
-dontwarn org.apache.http.conn.scheme.**
-dontwarn com.amazonaws.services.securitytoken.**

ProGuard 输出:

[2013-12-11 15:46:47 - iDukan] Proguard returned with error code 1. See console
[2013-12-11 15:46:47 - iDukan] Note: there were 1 duplicate class definitions.
[2013-12-11 15:46:47 - iDukan] Warning: com.amazonaws.org.apache.http.HttpHost: can't find referenced class org.apache.http.annotation.Immutable
[2013-12-11 15:46:47 - iDukan] Warning: com.amazonaws.org.apache.http.HttpVersion: can't find referenced class org.apache.http.annotation.Immutable
[2013-12-11 15:46:47 - iDukan] Warning: com.amazonaws.org.apache.http.ProtocolVersion: can't find referenced class org.apache.http.annotation.Immutable
[2013-12-11 15:46:47 - iDukan] Warning: com.amazonaws.org.apache.http.auth.AUTH: can't find referenced class org.apache.http.annotation.Immutable
[2013-12-11 15:46:47 - iDukan] Warning: com.amazonaws.org.apache.http.auth.AuthOption: can't find referenced class org.apache.http.annotation.Immutable
[2013-12-11 15:46:47 - iDukan] Warning: com.amazonaws.org.apache.http.auth.AuthSchemeRegistry: can't find referenced class org.apache.http.annotation.ThreadSafe
[2013-12-11 15:46:47 - iDukan] Warning: com.amazonaws.org.apache.http.auth.AuthScope: can't find referenced class org.apache.http.annotation.Immutable
[2013-12-11 15:46:47 - iDukan] Warning: com.amazonaws.org.apache.http.auth.AuthState: can't find referenced class org.apache.http.annotation.NotThreadSafe
[2013-12-11 15:46:47 - iDukan] Warning: com.amazonaws.org.apache.http.auth.AuthenticationException: can't find referenced class org.apache.http.annotation.Immutable
[2013-12-11 15:46:47 - iDukan] Warning: com.amazonaws.org.apache.http.auth.BasicUserPrincipal: can't find referenced class org.apache.http.annotation.Immutable
[2013-12-11 15:46:47 - iDukan] Warning: com.amazonaws.org.apache.http.auth.InvalidCredentialsException: can't find referenced class org.apache.http.annotation.Immutable
[2013-12-11 15:46:47 - iDukan] Warning: com.amazonaws.org.apache.http.auth.MalformedChallengeException: can't find referenced class org.apache.http.annotation.Immutable
[2013-12-11 15:46:47 - iDukan] Warning: com.amazonaws.org.apache.http.auth.NTCredentials: can't find referenced class org.apache.http.annotation.Immutable

...
[2013-12-11 15:46:47 - iDukan] Warning: there were 347 unresolved references to classes or interfaces.
[2013-12-11 15:46:47 - iDukan] You may need to add missing library jars or update their versions.
[2013-12-11 15:46:47 - iDukan] If your code works fine without the missing classes, you can suppress
[2013-12-11 15:46:47 - iDukan] the warnings with '-dontwarn' options.
[2013-12-11 15:46:47 - iDukan] (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
[2013-12-11 15:46:47 - iDukan] java.io.IOException: Please correct the above warnings first.
[2013-12-11 15:46:47 - iDukan] at proguard.Initializer.execute(Initializer.java:369)
[2013-12-11 15:46:47 - iDukan] at proguard.ProGuard.initialize(ProGuard.java:212)
[2013-12-11 15:46:47 - iDukan] at proguard.ProGuard.execute(ProGuard.java:87)
[2013-12-11 15:46:47 - iDukan] at proguard.ProGuard.main(ProGuard.java:484)

最佳答案

AmazonAWS 引用的缺失 Apache 注释可能是无害的。您可以告诉 ProGuard 忽略该问题:

-dontwarn org.apache.http.annotation.**

或更广泛地说,忽略库中任何 Unresolved 引用:

-dontwarn com.amazonaws.**

ProGuard's troubleshooting page 的链接中所述在控制台日志中,您可能可以对所有 347 个未解析的引用执行此操作,前提是您的应用程序的调试构建工作正常。

关于android - 使用 AWS SDK 的 ProGuard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20524273/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com