2016-02-02 12 views
17

Android StudioでProguardの難読化機能を有効にして、アプリを保護する必要があります。私はそれを適用する方法のプロセスを探しましたが、私は明確な解決策を得ていませんでした。私はそれを試して、私はいつもエラーが表示されます。だから誰も私のアプリでそれを適用する明確なステップを教えてくれる?AndroidスタジオでProGuard難読化を有効にする方法は?

私は、次の手順でこれをやっています:Androidのメーカーで

  1. を、Androidのプロジェクトを開きます。

  2. プロジェクトビューに変更します。

  3. 変更するには、次の行:​​プロジェクトビューで

  4. セットProGuardのルール(オプション)

    4.1へ

    minifyEnable false、proguard-rules.proファイルを選択します。

    4.2 ProGuardに特定のクラスを難読化しないように指示するには、次の行を追加します。

    -keepclassmembers class com.dom925.xxxx 
    { 
        public * 
    } 
    

私は手順を実行して取得していますエラーが

Error:Execution failed for task ':app:packageRelease'. Unable to compute hash of D:\Android\Pojectname\app\build\intermediates\classes-proguard\release\classes.jar

+0

私たちはあなたの依存関係に基づいて、より正確な答えをすることができるので、ここで –

+0

は、いくつかの参照http://stackoverflow.com/questions/30934729/cant-generate-signed-apk-from-androidであるあなたのbuild.gradleを投稿-studio-execution-for-task-packa –

+0

ここにいくつかの参考資料がありますhttp://stackoverflow.com/questions/20885725/how-to-use-the-proguard-in-android-studio –

答えて

9

ある私はこの問題を考え出し:

はあなたのためにproguard-rules.proを開きプロジェクトを作成し、下部に追加してください:

-dontwarn java.nio.file.Files 
-dontwarn java.nio.file.Path 
-dontwarn java.nio.file.OpenOption 
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 

は基本的に私はそれがこのだった解決方法を私は「リリース」モードで私のアプリを実行しようと、ここでこの男のようなエラーの束を得た:https://github.com/square/okio/issues/144

私はかなり彼が言ったことに続いて、それを修正しました。

希望すると、他のユーザーがAPKを生成するのに役立ちます。ここ

訪問詳細は:

Error:Execution failed for task ':app:packageRelease'. > Unable to compute hash of /../AndroidStudioProjects/../classes.jar

+0

友人http://stackoverflow.com/questions/35150026/how-to-generate-proguard-obfuscation-in-using-android-studio –

32

のAndroid StudioでProGuardのを有効にするには。

以下は、Android StudioでデフォルトのProGuardを有効にする方法のサンプルです。ゴーアプリのbuild.gradleファイルへ

  1. minifyEnabled真
  2. はデフォルト1を有効にするには、APKサイズ
  3. proguardFiles getDefaultProguardFile('proguard-android.txt') を減らすために真shrinkResourcesをイネーブル。独自のプロガードファイルを使用する場合は、以下の規則を使用してください。

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

Androidやその他の設定のためのProGuardの設定とのリンクはこれらのリンクでご利用いただけます:

は詳細についてthis link

を経ます
1
if you are building the android project with jack, then it will automatically do the shrinking, obfuscation, repackaging and multidex. 
Just add below in 

defaultConfig { 
     jackOptions { 
      enabled true 
     }   
    } 

and in build types, mention the project proguard file. 
buildTypes { 
     release { 
      // Jack build environment does not require minifyEnabled or shrinkResources. 
      // Conceptually, the jack compiler consolidates the functionality of javac, ProGuard, and dex in a single conversion step 
      //minifyEnabled = true  
      //shrinkResources true 

      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt' 
     } 

     debug { 
................... 
     } 
    } 



To disable the ProGuard obfuscation, it is required to add below line in your proguard-project.txt file 

####No obfuscation 
-dontobfuscate 
関連する問題