Android:启用Proguard API后调用无效

时间:2016-03-10 06:36:14

标签: android apache http-headers apache-httpclient-4.x android-proguard

我只是在我的应用程序中启用了proguard。我使用Titanium.Media.showCamera({          success:function(event)           { Ti.API.info('   in showcamera   success ');  var cameraImage = event.media; Alloy.createController('customerTagPost').getView();             },             cancel:function()             {                              },             error:function(error)             {               },             allowImageEditing:true,             saveToPhotoGallery:true, mediaTypes:[Ti.Media.MEDIA_TYPE_PHOTO]         }); 方法进行API调用。

org.apache.http

当我第一次启用Proguard时,我在尝试生成发布APK时收到警告

 buildTypes {
    release {
        // signingConfig signingConfigs.release
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

所以我在Proguard中添加了一些规则

Warning:library class org.apache.http.conn.scheme.LayeredSocketFactory extends or implements program class org.apache.http.conn.scheme.SocketFactory
Warning:library class android.webkit.WebView depends on program class android.net.http.SslCertificate
Warning:library class android.webkit.WebViewClient depends on program class android.net.http.SslError
Warning:library class org.apache.http.conn.ssl.SSLSocketFactory depends on program class org.apache.http.conn.scheme.HostNameResolver
Warning:library class org.apache.http.conn.ssl.SSLSocketFactory depends on program class org.apache.http.params.HttpParams
Warning:library class org.apache.http.params.HttpConnectionParams depends on program class org.apache.http.params.HttpParams

发布APK成功后,但API没有调用。

任何人都可以帮助我。

1 个答案:

答案 0 :(得分:0)

ProGuard模糊处理将转换模型类名称,因此如果您使用Gson在post方法中传递这些类名,则API将无效,因此请保留所有模型类,如下所示

-keep class com.android.appname.** { *; }
(The package name of the you app)
-dontwarn class com.android.appname.**