zoukankan      html  css  js  c++  java
  • android 导出apk

    一个困扰了几个月的问题在今天得以解决,运动益智可能有点过,能让一个人思路清晰倒是真!

    问题描述:本地调试运行及不加密导出apk运行正常,当加密生成apk安装后,从接口返回的数据总是空。尝试过各种配置,不加密网络流,不加密调接口的方法.与网络交互的方法类通通通通通通不加密...失败!

    信了你的邪,今天把服务器返回的数据Toast出来一看,返回的数据并非空值,原来问题出现在反序列化!

    导出加密包用到fastjson反序列化一定要加上

    -keep class com.alibaba.fastjson.** { *; }
    
    #-keepnames class * implements java.io.Serializable
    -keep public class * implements java.io.Serializable {
            public *;
    }

    step1.将project.properties的proguard.config属性的路径设为proguard-project.txt

    # This file is automatically generated by Android Tools.
    # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
    #
    # This file must be checked in Version Control Systems.
    #
    # To customize properties used by the Ant build system edit
    # "ant.properties", and override values to adapt the script to your
    # project structure.
    #
    # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
    #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
    # Project target.
    proguard.config=proguard-project.txt
    target=android-19

    step2.修改proguard-project.txt

    -dontusemixedcaseclassnames
    -dontskipnonpubliclibraryclasses
    -verbose
    -ignorewarnings
    -dontoptimize
    -dontpreverify
    -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*  
    
    -keepattributes *Annotation*
    -keepattributes Signature  
    -keep public class com.google.vending.licensing.ILicensingService
    -keep public class com.android.vending.licensing.ILicensingService
    
    
    -keep class * implements android.os.Parcelable {
      public static final android.os.Parcelable$Creator *;
    }
    
    -keepclassmembers class **.R$* {
        public static <fields>;
    }
    
    -dontwarn android.support.**
    #把Libs下引用的jar包都申明进来
    -libraryjars libs/AMap_2DMap_v2.6.0_20150916.jar
    -libraryjars libs/Android_Location_V1.3.3.jar
    -libraryjars libs/android-support-v4.jar
    -libraryjars libs/fastjson-1.2.7.jar
    -libraryjars libs/javacsv.jar
    -libraryjars libs/json-lib-1.1-jdk13.jar
    -libraryjars libs/ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar  
    -libraryjars libs/poi-3.6-20091214.jar
    #不需要混淆的部分申明进来,有些类经过混淆会导致程序编译不通过
    -keep public class * extends android.app.Fragment    
    -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.content.BroadcastReceiver  
    -keep public class * extends android.content.ContentProvider  
    -keep public class * extends android.app.backup.BackupAgentHelper  
    -keep public class * extends android.preference.Preference  
    -keep public class * extends android.support.v4.**  
    -keep public class com.android.vending.licensing.ILicensingService  
    
    
    
    -keep class com.amap.api.maps2d.**{*;}
    -keep class com.amap.api.mapcore2d.**{*;}
    -keep class com.amap.api.location.**{*;}
    -keep class com.amap.api.fence.**{*;}
    -keep class com.autonavi.aps.amapapi.model.**{*;}
    -keep class com.alibaba.fastjson.** { *; }
    
    #-keepnames class * implements java.io.Serializable
    -keep public class * implements java.io.Serializable {
            public *;
    }
  • 相关阅读:
    Binder机制,从Java到C (5. IBinder对象传递形式)
    Binder机制,从Java到C (4. Parcel)
    Binder机制,从Java到C (3. ServiceManager in Java)
    Binder机制,从Java到C (2. IPC in System Service :AMS)
    Binder机制,从Java到C (10. Binder驱动)
    Binder机制,从Java到C (8. ServiceManager in Native)
    Binder机制,从Java到C (7. Native Service)
    Binder机制,从Java到C (6. Binder in Native : libbinder)
    Binder机制,从Java到C (1. IPC in Application Remote Service)
    SVM详解
  • 原文地址:https://www.cnblogs.com/huangzhen22/p/5157682.html
Copyright © 2011-2022 走看看