我有一个使用AWS AppSync SDK并具有以下gradle配置的Android App,以连接到云后端。
implementation 'com.amazonaws:aws-android-sdk-appsync:2.7.+'
通过Cognito用户池控制对后端资源的访问。在未启用proguard的情况下,用户身份验证和从后端获取数据的效果很好。 如果启用Proguard,我会收到与AWS开发工具包相关的各种警告。 我设法在启用proguard的情况下生成签名APK的唯一方法是,像这样抑制所有与AWS相关的警告:
-dontwarn com.amazonaws.**
执行此操作时,生成的APK无法验证用户身份,并且无法从后端检索数据。 当我尝试调试APK时,在Android Studio中收到以下错误:
Could not connect to remote process. Aborting debug session.
是否有更细粒度的proguard设置可以消除所有警告,但又不会破坏与后端的连接?
答案 0 :(得分:0)
以下Proguard配置对我有用:
-keepnames class com.amazonaws.**
-keepnames class com.amazon.**
# Request handlers defined in request.handlers
-keep class com.amazonaws.services.**.*Handler
# The following are referenced but aren't required to run
-dontwarn com.fasterxml.jackson.**
-dontwarn org.apache.commons.logging.**
# Android 6.0 release removes support for the Apache HTTP client
-dontwarn org.apache.http.**
# The SDK has several references of Apache HTTP client
-dontwarn com.amazonaws.http.**
-dontwarn com.amazonaws.metrics.**
-dontwarn com.amazonaws.mobile.**
-dontwarn com.amazonaws.mobileconnectors.**
所有警告均消失,并且apk连接到后端而没有任何问题。