2017-01-17 6 views
3

私のコードにproguardを適用した後、それはまだかなり読みやすいです。クラスとパッケージの名前は変更されません。クラス変数、それはすべて名前が変更されたものです。 Android Studio 2.2.3。 ビルド:Gradleの:私のリリースAPK表示AndroidスタジオのProGuardは、非常に弱い難読化機能を提供します。

# 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.** { *; } 

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 2.2.3

build.gradle enter image description here

+0

@Aenadonはい。私はproguard-android-optimize.txtを試しました。私のAPKは30kb小さくなりましたが、目に見える違いはありません。 – despecher

答えて

2

あなたはライブラリAppIntroを使っているのを見ることができます。このライブラリには、プロジェクトのすべてのクラスを保存しているライブラリのproguardルールがあるという問題があります。ライブラリのproguardルールはローカルクラスとマージされるので、最終ビルドではすべてのクラスが保持され、難読化されません。

この問題は4.2で修正されましたが、このバージョンはMaven Centralでリリースされていません。一方で、ライブラリをローカルでクローンし、graleで手動でインポートする必要があります。

手順:ローカルのGithub経由

  1. ダウンロードまたはライブラリのクローンを作成
  2. は、新しいを作成し、プロジェクトのルートに新しいフォルダlibsを作成します(緑Clone or Downloadボタンがあります)フォルダAppIntrolibsフォルダ
  3. クローンプロジェクトのlibrary - フォルダの内容をに置きますフォルダには、我々は正常に動作しなければならないあなたのbuild.gradle

今すぐProGuardの中compile project(':libs:AppIntro')と交換してくださいあなたのsettings.gradle

  • compile 'com.github.paolorotolo:appintro:4.1.0'include ':libs:AppIntro'を追加ステップ3
  • で作成されました!

  • +0

    あなたの答えをありがとう。はい、確かに、AppIntroライブラリを削除した後、proguardが正しく動作するようになりました。 – despecher

    +0

    私は今、同じ問題があり、私はこのAppIntroライブラリをプロジェクトに持っていません。 ProGuardにすべてのクラスを除外させる悪質なリンゴを適切に診断して見つけ出す方法は? – Segabond

    関連する問題