android代码混淆aar_android打包aar、发布签名包、混淆

1、打包aar的工程

①AndroidManifest.xml中不能有,如果有这个的话,在别的项目引用这个aar包之后,手机上会有两个图标

②build.gradle中不能有apply plugin: 'com.android.application',需要改为apply plugin: 'com.android.library'

android打包aar步骤.png

arr包路径.png

image.png

别的项目引用aar包

aar包放在libs包下,同时build.gradle文件中引入

image.png

image.png

2、关于地图引用百度sdk

引用的jar包有如下:

image.png

BaiduLBS_Android.jar放在libs包下,

arm64-v8a/

armeabi/

armeabi-v7a放在JniLibs包下

image.png

3、目前有maputil、CommonReportPage可以打包为aar

E:\ASProject\androidcommon

E:\ASProject\010trunk\CommonReportPage

4、android打包签名包

Build→Generate Signed APK,注意versionname和versioncode

也要改

defaultConfig {

applicationId "com.jsptpd.srfa"

minSdkVersion 15

targetSdkVersion 25

versionCode 27

versionName "0.2.7"

ndk {

abiFilters "armeabi", "armeabi-v7a"

}

}

image.png

5、android打包签名包,混淆

build.gradle文件中引入proguard-rules.pro

buildTypes {

release { //发布版本使用混淆文件

minifyEnabled true

proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

}

}

完整build.gradle(Module:app)

apply plugin: 'com.android.application'

//apply plugin: 'android-apt'

def AAVersion = '4.0.0'

android {

compileSdkVersion 25

buildToolsVersion '26.0.2'

defaultConfig {

applicationId "com.jsptpd.srfa"

minSdkVersion 15

targetSdkVersion 25

versionCode 27

versionName "0.2.7"

ndk {

abiFilters "armeabi", "armeabi-v7a"

}

}

buildTypes {

release { //发布版本使用混淆文件

minifyEnabled true

proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

}

}

compileOptions {

sourceCompatibility JavaVersion.VERSION_1_8

targetCompatibility JavaVersion.VERSION_1_8

}

// repositories {

// flatDir {

// dirs 'libs'

// }

//

// }

}

dependencies {

implementation 'com.android.support.constraint:constraint-layout:1.1.0'

compile fileTree(include: ['*.jar'], dir: 'libs')

testCompile 'junit:junit:4.12'

compile(name: 'maputil-release', ext: 'aar')

compile(name: 'commonreportpage', ext: 'aar')

compile(name: 'compass-release', ext: 'aar')

compile(name: 'towerheightmeter-release', ext: 'aar')

annotationProcessor "org.androidannotations:androidannotations:$AAVersion"

compile "org.androidannotations:androidannotations-api:$AAVersion"

compile 'com.android.support:appcompat-v7:25.3.1'

compile 'org.greenrobot:greendao:2.2.0'

compile 'com.squareup.retrofit2:retrofit:2.0.2'

compile 'com.squareup.retrofit2:converter-gson:2.0.2'

compile 'com.android.support:design:25.3.1'

compile 'com.android.support:support-v4:25.3.1'

compile 'com.github.stfalcon:frescoimageviewer:0.4.1'

compile 'com.facebook.fresco:fresco:1.1.0'

compile 'com.github.bumptech.glide:glide:3.6.1'

compile 'com.commit451:PhotoView:1.2.4'

compile 'com.isseiaoki:simplecropview:1.0.13'

compile 'com.yongchun:com.yongchun.imageselector:1.1.0'

compile 'io.reactivex.rxjava2:rxandroid:2.0.1'

compile 'io.reactivex.rxjava2:rxjava:2.0.7'

compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'

// compile 'com.android.support:multidex:1.0.1'

}

//apply plugin: 'me.tatarka.retrolambda'

完整proguard-rules.pro

proguard-rules.pro中实体类model要避免混淆

# Add project specific ProGuard rules here.

# By default, the flags in this file are appended to flags specified

# in W:\AndroidSDKNew/tools/proguard/proguard-android.txt

# You can edit the include path and order by changing the proguardFiles

# directive in build.gradle.

#

# For more details, see

# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following

# and specify the fully qualified class name to the JavaScript interface

# class:

#-keepclassmembers class fqcn.of.javascript.interface.for.webview {

# public *;

#}

-keep class !com.jsptpd.** {*;}

-keep class com.jsptpd.srfa.model.** {*;}

-keep class com.jsptpd.workformcommon.Model.** {*;}

-keep class com.jsptpd.srfa.restapi.ResponseObj {*;}

-keep class com.jsptpd.srfa.restapi.Error {*;}

-keep class com.jsptpd.srfa.view.widget.LayerControl.Model.** {*;} #图层功能混淆

-keepclasseswithmembers class * {

@retrofit2.http.* ;

}

-keepattributes Signature

-keepattributes Exceptions

-keepclassmembers class * extends de.greenrobot.dao.AbstractDao {

public static java.lang.String TABLENAME;

}

-keep class **$Properties

-dontwarn com.pgyersdk.**

-keep class com.pgyersdk.** { *; }

-dontwarn **

# Retrofit

-keep class retrofit2.** { *; }

-dontwarn retrofit2.**

-keepattributes Signature

-keepattributes Exceptions

-dontwarn okio.**

-dontwarn javax.annotation.**

# RxJava RxAndroid

-dontwarn sun.misc.**

-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {

long producerIndex;

long consumerIndex;

}

-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {

rx.internal.util.atomic.LinkedQueueNode producerNode;

}

-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {

rx.internal.util.atomic.LinkedQueueNode consumerNode;

}

-dontnote rx.internal.util.PlatformDependent

见项目智慧查勘/通用查勘 E:\ASProject\newapp引入了下面两个项目的aar

E:\ASProject\010trunk\CommonReportPage

E:\ASProject\010trunk\maputil

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值