Proguard in Android Studio provides a very weak obfuscation function

After applying Proguard to my code, it is still very readable. Classes and packages are not renamed. Class variables, that is, all renamed variables. Android studio 2.2.3. Establishment: level: 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.** { *; }

View my distribution apk

resolvent:

I can see that you are using the appintro library. There is a problem with the library. The protection rules of the library will preserve all classes in the project. The Proguard rules of the library are merged with the local rules, so all classes will be preserved and will not be confused in the final version

This problem has been fixed in 4.2, but this version has not been released on Maven central. At the same time, you must clone the library locally and import it manually in gradle

pace:

>Download or clone the library locally via GitHub (green "clone" or "download" button) >Create a new folder library in the root directory of the project > create a new folder appintro in the LIBS folder > put the contents of the Library folder of the cloned project into the appintro folder we created in step 3 > Add 'include' in your settings.gradle ': LIBS: appintro' > compile the project with the file in build.gradle (': LIBS: appintro') Replace and compile 'com. GitHub. Paolorotolo: appintro: 4.1.0'

Now, Proguard should work normally!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>