android - Android Studio 中的 ProGuard 提供了非常弱的混淆。

标签 android proguard android-proguard

在对我的代码应用混淆器之后,它仍然非常可读。类和包不会重命名。类变量,这就是所有被重命名的。 安卓工作室 2.2.3。 构建:gradle: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 规则保留了项目中的所有类。库的 proguard 规则与本地规则合并,因此在最终构建中所有类都被保留并且不会被混淆。

这个问题在4.2已经修复,但是这个版本还没有在Maven Central上发布。同时,你必须在本地克隆库并在 gradle 中手动导入它。

步骤:

  1. 通过 Github 在本地下载或克隆库(有一个绿色的 Clone or Download 按钮)
  2. 在项目的根目录中创建一个新文件夹 libs
  3. libs文件夹中新建文件夹AppIntro
  4. 将克隆项目的 library 文件夹中的内容放入我们在步骤 3 中创建的 AppIntro 文件夹中
  5. include ':libs:AppIntro' 添加到您的 settings.gradle
  6. compile 'com.github.paolorotolo:appintro:4.1.0' 替换为 compile project(':libs:AppIntro') 在你的 build.渐变

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

关于android - Android Studio 中的 ProGuard 提供了非常弱的混淆。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41690374/

相关文章:

java - Proguard 删除 Android 应用程序中的注释

java - 使用 proguard 混淆 Parcelable 类

android - 在 Android 库 AAR 中使用时无法找到 Volley 的字节码

java - 注意 : com. google.common.cache.Striped64 动态访问声明的字段 'base'

Android 文件名中带空格打不开

android - 安卓手机的蓝牙设备类别有哪些?

android - ClassCastException : BasicHttpResponse cannot be cast to org. apache.http.HttpEntity 安卓

android - JNI : Printing Matrix to logcat doesn't work

android - 在Android上测试发行版应用,测试用的APK不是 `proguarded`

android - Proguard 与 AAR 库问题