Java Proguard配置以使用改装
我的应用程序在调试中运行正常,但在创建要发布的apk时,我遇到以下错误Java Proguard配置以使用改装,java,android,proguard,retrofit,android-proguard,Java,Android,Proguard,Retrofit,Android Proguard,我的应用程序在调试中运行正常,但在创建要发布的apk时,我遇到以下错误 Process: neocom.dealerbook, PID: 9044 java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0 at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255) at java.ut
Process: neocom.dealerbook, PID: 9044
java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at neocom.dealerbook.controller.k.a(MapActivity.java:103)
at neocom.dealerbook.controller.k.success(MapActivity.java:98)
at retrofit.CallbackRunnable$1.run(CallbackRunnable.java:45)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
下面是MapActivity.java:103
Callback<ClienteConfiguracao> callback = new Callback<ClienteConfiguracao>() {
int failCount = 0;
@Override
public void success(ClienteConfiguracao clienteConfiguracao, Response response) {
currentClient = clienteConfiguracao.getDealerships().get(0); /* Line 103 */
setupToggles(currentClient);
List<String> mAuthorization = clienteConfiguracao.getAuthorization();
toAllowPermissions = new HashMap<>();
Set<String> allImplementedKeys = PermissionManager.ALL_PERMISSIONS.keySet();
for (String key : mAuthorization) {
if (allImplementedKeys.contains(key)) {
List value = PermissionManager.ALL_PERMISSIONS.get(key);
toAllowPermissions.put(key, value);
}
}
Callback Callback=new Callback(){
int故障计数=0;
@凌驾
公共无效成功(客户配置客户配置,响应){
currentClient=clientConfiguracao.getDealerhips().get(0);/*第103行*/
设置切换(currentClient);
List mAuthorization=clientconfiguracao.getAuthorization();
toAllowPermissions=newHashMap();
Set allImplementedKeys=PermissionManager.ALL_PERMISSIONS.keySet();
for(字符串键:授权){
if(allImplementedKeys.contains(key)){
列表值=PermissionManager.ALL_PERMISSIONS.get(key);
toAllowPermissions.put(键、值);
}
}
这里是我创建的proguard文件,用于搜索我得到的错误、改造站点和其他
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
}
-dontwarn retrofit.**
-dontwarn com.squareup.okhttp.**
-dontwarn okio.**
-dontwarn retrofit.appengine.UrlFetchClient
-keep class retrofit.** { *; }
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-keepattributes Signature
-keepattributes Exceptions
-keepattributes *Annotation*
-keepattributes SourceFile
-keepattributes LineNumberTable
-keepclasseswithmembers class * {
@retrofit.http.* <methods>;
}
-assumenosideffects类android.util.Log{
公共静态布尔isLoggable(java.lang.String,int);
公共静态INTV(…);
公共静态int i(…);
公共静态int w(…);
公共静态int d(…);
公共静态INTE(…);
}
-dontwarn改装**
-dontwarn com.squareup.okhttp**
-唐特沃恩·奥基奥**
-dontwarn改装.appengine.UrlFetchClient
-保持类更新。**{*;}
-保持类com.squareup.okhttp.*{*;}
-保持接口com.squareup.okhttp.*{*;}
-保留署名
-保留特例
-keepattributes*注释*
-keepattributes源文件
-保持属性LineNumber可编辑
-keepclassswithmembers类*{
@http.*;
}
有什么建议吗?问题就在这里
currentClient = clienteConfiguracao.getDealerships().get(0);
clientconfiguracao.getDealerhips()为空。您需要检查它是否包含具有
if (clienteConfiguracao.getDealerships().size() > 0) {
clienteConfiguracao.getDealerships().get(0);
} else {
//handle empty ArrayList
}
在对gson进行改型时,将Progard规则添加到序列化的和反序列化的类非常重要
例如:
-keep class com.example.model.** { *; }
另一个建议是使用。很多不同的库都有规则。只需添加-keep class com.google.gson.*{*;}
哪一行是您得到错误的确切位置?在第103行中,第二个代码段的行尾有一条注释。如果它变为空,则是GSON或关于Proguard中的改装。因为我确信如果改装成功返回,则会有一个值。如果不生成签名/Proguard APK,则错误永远不会发生。你是一个救生员