答えて

2

ProGuardのは、デバッグに有効になっている場合は、定義することができminifyEnabled

trueを設定、解除または両方

buildTypes { 
     release { 
      minifyEnabled true 
      proguardFiles 'proguard-rules.pro' 
     } 
     debug { 
      minifyEnabled false 
      proguardFiles 'proguard-rules.pro' 
     } 
    } 

あなたは彼を設定へproguardFilesをも設定することができ、このsiteをチェックドキュメントについては、次の例をご覧ください。

# Add project specific ProGuard rules here. 
# By default, the flags in this file are appended to flags specified 
# in /Users/balysv/Documents/Android/sdk/tools/proguard/proguard-android.txt 
# You can edit the include path and order by changing the ProGuard 
# include property in project.properties. 
# 
# 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 *; 
#} 

-optimizationpasses 5 
-dontskipnonpubliclibraryclasses 
-dontskipnonpubliclibraryclassmembers 
-dontpreverify 
-verbose 

-obfuscationdictionary proguard-dic.txt 
-classobfuscationdictionary proguard-dic.txt 
-packageobfuscationdictionary proguard-dic.txt 

辞書ファイルは、あなたのコードを難読化するために使用するラベルを持つ単純なテキストファイル、行ごとに1つのラベルです:コードの難読化は、あなたの辞書ファイルで、この設定を設定します。

+0

おかげで、どのように、その内容とは? – nuhkoca

+0

私の回答を更新 –

+0

どのように私の依存関係にこの設定を適用できますか? – nuhkoca

3

APKファイルをできるだけ小さくするには、縮小ビルドを有効にして、リリースビルドで未使用のコードとリソースを削除する必要があります。

コード縮小は、含まれているコードライブラリからのものを含め、パッケージされたアプリケーションから未使用のクラス、フィールド、メソッド、属性を検出して削除するProGuardで利用できます(64k参照制限を回避する貴重なツールになります)。

ProGuardは、バイトコードを最適化し、未使用のコード命令を削除し、短い名前の残りのクラス、フィールド、メソッドを難読化します。難読化されたコードはAPKをリバースエンジニアリングするのを困難にします。これは、アプリでライセンス確認などの機密性の高い機能を使用する場合に特に役立ちます。例えば

、build.gradleファイルから次のスニペットは、コードリリースビルド用の縮小を可能にします:

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

Example of use from Proguard, from Android Studio

+0

おかげで、私はそれを見てみましょう。どうすれば私の依存関係にproguardを使うことができますか? – nuhkoca

関連する問題