ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Android Studio中的ProGuard提供了非常弱的混淆功能.

2019-11-11 21:25:35  阅读:417  来源: 互联网

标签:proguard android-proguard android


在将proguard应用于我的代码后,它仍然非常可读.类和包未重命名.类变量,即所有已重命名的变量.
Android Studio 2.2.3.
建立:等级:2.2.3

build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "25.0.1"

defaultConfig {
    applicationId "com.mypackagename"
    minSdkVersion 19
    targetSdkVersion 24
    versionCode 3
    versionName "1.0"
    vectorDrawables.useSupportLibrary = true
}

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

dexOptions {
    dexInProcess = true
}

   lintOptions {
    abortOnError true
    checkReleaseBuilds true
}
}

ext {
supportLibVersion = '25.0.1'
playServisesVersion = '10.0.0'
}

repositories {
maven { url "https://jitpack.io" }
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.github.PhilJay:MPAndroidChart:v2.2.5'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.wdullaer:materialdatetimepicker:3.0.0'
compile 'com.aurelhubert:ahbottomnavigation:2.0.1'
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:cardview-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile "com.google.android.gms:play-services-analytics:${playServisesVersion}"
compile "com.google.android.gms:play-services-drive:${playServisesVersion}"
compile "com.google.firebase:firebase-ads:${playServisesVersion}"
compile "com.google.firebase:firebase-core:${playServisesVersion}"
compile 'com.anjlab.android.iab.v3:library:1.0.34'
compile 'com.github.paolorotolo:appintro:4.1.0'
compile 'net.danlew:android.joda:2.9.5.1'
}
apply plugin: 'com.google.gms.google-services'

proguard-rules.pro

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:.....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 *;
#}
-dontwarn com.github.mikephil.charting.**
-keep class android.support.v7.** { *; }
-keep class android.support.graphics.drawable.** { *; }

查看我的发行版APK
enter image description here

解决方法:

我可以看到您正在使用AppIntro库.该库有一个问题,其中库的保护规则会保留项目中的所有类.库的proguard规则与本地规则合并,因此在最终版本中,所有类都将保留并且不会被混淆.

此问题已在4.2中修复,但尚未在Maven Central上发布此版本.同时,您必须在本地克隆该库,然后在gradle中手动将其导入.

脚步:

>通过Github在本地下载或克隆库(绿色的“克隆”或“下载”按钮)
>在项目的根目录中创建一个新的文件夹库
>在libs文件夹中创建一个新文件夹AppIntro
>将克隆项目的库文件夹的内容放入我们在步骤3中创建的AppIntro文件夹中
>在您的settings.gradle中添加include’:libs:AppIntro’
>用build.gradle中的编译项目(‘:libs:AppIntro’)替换编译’com.github.paolorotolo:appintro:4.1.0′

现在,proguard应该可以正常工作!

标签:proguard,android-proguard,android
来源: https://codeday.me/bug/20191111/2022647.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有