Ошибка ProGuard с AWS

Моему Android-приложению не удается экспортировать из Eclipse, когда ProGuard включен, из-за проблем с Amazon AWS SDK.

Я использую версию 1.7.0 AWS SDK для Android (core & s3). Ошибки, зарегистрированные в консоли, показаны ниже.

Я следовал рекомендованным настройкам ProGuard Config, предоставленным Amazon, но безрезультатно: https://mobile.awsblog.com/post/Tx2OC71PFCTC63E/Using-ProGuard-with-the-AWS-SDK-for-Android

Это банки в моем проекте:

aws-android-sdk-1.7.0-core.jar
aws-android-sdk-1.7.0-s3.jar

Project.properties:

proguard.config=proguard-project.txt

# Project target.
target=android-19
android.library.reference.1=../../../../../opt/ADT/sdk/extras/google/google_play_services/libproject/google-play-services_lib
android.library.reference.2=../../../../../opt/ADT/sdk/extras/android/support/v7/appcompat

Мой ProGuard Config выглядит следующим образом:

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose

# Otherwise return Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
-dontwarn com.fasterxml.jackson.databind.**

-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

# Preserve all fundamental application classes.
-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.view.View
-keep public class * extends android.preference.Preference
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider

# Preserve Android support libraries` classes and interfaces
-keep class android.support.** { *; }
-keep interface android.support.** { *; }

# Preserve all Jackson library classes
-keep class com.fasterxml.jackson.** { *; }

# Original
-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); 
}

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

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

-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}

-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

#To remove debug logs:
-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** v(...);
}



#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.**

Выход Proguard:

[2014-02-17 18:40:22 - Spream] Proguard returned with error code 1. See console
[2014-02-17 18:40:22 - Spream] Note: there were 1 duplicate class definitions.
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider: can't find referenced class com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider: can't find referenced class com.amazonaws.services.securitytoken.model.AssumeRoleRequest
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider: can't find referenced class com.amazonaws.services.securitytoken.AWSSecurityTokenService
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider: can't find referenced class com.amazonaws.services.securitytoken.model.AssumeRoleResult
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider: can't find referenced class com.amazonaws.services.securitytoken.model.Credentials
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider: can't find referenced class com.amazonaws.services.securitytoken.AWSSecurityTokenService
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.auth.STSSessionCredentials: can't find referenced class com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.auth.STSSessionCredentials: can't find referenced class com.amazonaws.services.securitytoken.model.Credentials
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.auth.STSSessionCredentials: can't find referenced class com.amazonaws.services.securitytoken.model.GetSessionTokenRequest
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.auth.STSSessionCredentials: can't find referenced class com.amazonaws.services.securitytoken.AWSSecurityTokenService
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.auth.STSSessionCredentials: can't find referenced class com.amazonaws.services.securitytoken.model.GetSessionTokenResult
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.auth.STSSessionCredentials: can't find referenced class com.amazonaws.services.securitytoken.model.Credentials
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.auth.STSSessionCredentials: can't find referenced class com.amazonaws.services.securitytoken.AWSSecurityTokenService
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.auth.STSSessionCredentials: can't find referenced class com.amazonaws.services.securitytoken.AWSSecurityTokenService
[more com.amazonaws...]
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.HttpHost: can't find referenced class org.apache.http.annotation.Immutable
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.HttpVersion: can't find referenced class org.apache.http.annotation.Immutable
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.ProtocolVersion: can't find referenced class org.apache.http.annotation.Immutable
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.auth.AUTH: can't find referenced class org.apache.http.annotation.Immutable
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.auth.AuthOption: can't find referenced class org.apache.http.annotation.Immutable
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.auth.AuthSchemeRegistry: can't find referenced class org.apache.http.annotation.ThreadSafe
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.auth.AuthScope: can't find referenced class org.apache.http.annotation.Immutable
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.auth.AuthState: can't find referenced class org.apache.http.annotation.NotThreadSafe
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.auth.AuthenticationException: can't find referenced class org.apache.http.annotation.Immutable
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.auth.BasicUserPrincipal: can't find referenced class org.apache.http.annotation.Immutable
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.auth.InvalidCredentialsException: can't find referenced class org.apache.http.annotation.Immutable
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.conn.params.ConnManagerParams: can't find referenced class org.apache.http.annotation.Immutable
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.conn.params.ConnPerRouteBean: can't find referenced class org.apache.http.annotation.ThreadSafe
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.conn.params.ConnRouteParamBean: can't find referenced class org.apache.http.annotation.NotThreadSafe
[more com.amazonaws.org.apache.http... can not find referenced org.apache.http.annotation...]
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.impl.auth.GGSSchemeBase: can't find referenced class org.ietf.jgss.GSSManager
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.impl.auth.GGSSchemeBase: can't find referenced class org.ietf.jgss.GSSManager
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.impl.auth.GGSSchemeBase: can't find referenced class org.ietf.jgss.GSSException
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.message.AbstractHttpMessage: can't find referenced class org.apache.http.annotation.NotThreadSafe
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.message.BasicHeader: can't find referenced class org.apache.http.annotation.Immutable
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.message.BasicHeaderElement: can't find referenced class org.apache.http.annotation.NotThreadSafe
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.org.apache.http.message.BasicHeaderElementIterator: can't find referenced class org.apache.http.annotation.NotThreadSafe
[more com.amazonaws.org.apache.http...]
[2014-02-17 18:40:22 - Spream] Warning: com.amazonaws.util.TimingInfo: can't find referenced class org.apache.http.annotation.NotThreadSafe
[2014-02-17 18:40:22 - Spream]       You should check if you need to specify additional program jars.
[2014-02-17 18:40:22 - Spream] Warning: there were 425 unresolved references to classes or interfaces.
[2014-02-17 18:40:22 - Spream]          You may need to specify additional library jars (using '-libraryjars').
[2014-02-17 18:40:22 - Spream] java.io.IOException: Please correct the above warnings first.
[2014-02-17 18:40:22 - Spream]  at proguard.Initializer.execute(Initializer.java:321)
[2014-02-17 18:40:22 - Spream]  at proguard.ProGuard.initialize(ProGuard.java:211)
[2014-02-17 18:40:22 - Spream]  at proguard.ProGuard.execute(ProGuard.java:86)
[2014-02-17 18:40:22 - Spream]  at proguard.ProGuard.main(ProGuard.java:492)

И если я добавлю

-dontwarn com.amazonaws.**

ProGuard работает правильно, но когда я запускаю приложение, оно немедленно закрывается с этим RuntimeException:

java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:299)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.RuntimeException: Failed to initialize the regions.
at com.amazonaws.g.c.b(Unknown Source)
at com.amazonaws.g.c.a(Unknown Source)
at com.amazonaws.g.c.a(Unknown Source)
at com.amazonaws.g.a.a(Unknown Source)
at com.gzanitti.spream.c.d(Unknown Source)
at com.gzanitti.spream.c.c(Unknown Source)
at com.gzanitti.spream.n.a(Unknown Source)
at com.gzanitti.spream.n.doInBackground(Unknown Source)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
... 5 more

Любая идея? Я застрял на этой проблеме в течение нескольких часов.

1 ответ

Проблема не в Proguard, а в файле конфигурации отсутствующих регионов. Убедитесь, что он доступен в classpath последней банки.

https://github.com/aws/aws-sdk-android/blob/master/src/awssdk_config_default.json

-k

Другие вопросы по тегам