2017-05-08 32 views
1

私はアンドロイドアプリを持っています。私はちょうどその上で作業を終え、PlayStoreで公開する準備ができました。しかし、他の人が直接逆コンパイルをするのを避けるために、私はセキュリティの保護層を追加したかったのです。Android:minifyEnabledで署名付きAPKを生成するには

minifyEnabledを 'true'に設定して署名付きapkを生成しようとしました。しかし、アンドロイドスタジオはいくつかのエラーを表示し始めた、1つの時点でカウントは800エラーを超えていた。私は解決策をオンラインで探そうとしましたが、この問題の主な原因は、アプリケーションに追加したすべてのサードパーティのライブラリである可能性があることです。

このタイプの問題を克服する最も一般的な解決策の1つは、-dontwarnまたは-keep属性をproguard-rules.txtファイルに追加することでした。しかし、問題は、私がすべてのソリューションをオンラインで利用できるようにした後でさえも持続しました。私はYouTubeで何かを見つけようとしましたが、何も使いませんでした。誰かが私を助けてくれますか?ここでは、アプリレベルのgradelファイルは次のとおりです。

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.0" 
    defaultConfig { 
     applicationId "com.example.android.jsontutorial" 
     minSdkVersion 16 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner      "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:25.1.0' 
    compile 'com.android.support:design:25.1.0' 
    compile 'com.android.support:support-v4:25.1.0' 
    compile 'com.android.volley:volley:1.0.0' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
    compile 'com.android.support:recyclerview-v7:25.1.0' 
    compile 'com.android.support:cardview-v7:25.1.0' 
    //compile 'com.google.firebase:firebase-core:10.2.4' 
    compile 'com.google.firebase:firebase-ads:10.0.1' 
    testCompile 'junit:junit:4.12' 
} 
apply plugin: 'com.google.gms.google-services' 
apply plugin: 'com.google.gms.google-services' 

ここproguard-rules.txtファイルされる:

Warning: there were 1341 unresolved references to classes or interfaces. 
     You may need to add missing library jars or update their versions. 
     If your code works fine without the missing classes, you can suppress 
     the warnings with '-dontwarn' options. 
     (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass) 
Warning: there were 83 unresolved references to program class members. 
     Your input classes appear to be inconsistent. 
     You may need to recompile the code. 
     (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember) 

Warning: Exception while processing task java.io.IOException: Please correct the above warnings first. 
:app:transformClassesAndResourcesWithProguardForRelease FAILED 

あなた場合:

# Add project specific ProGuard rules here. 
# By default, the flags in this file are appended to flags specified 
# in C:\Users\Priyansh\AppData\Local\Android\Sdk/tools/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 tvName to the JavaScript interface 
# class: 
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { 
# public *; 
#} 

-dontwarn  com.squareup.picasso.** 
-dontwarn  com.android.support.** 
-dontwarn  com.android.support.** 
-dontwarn  com.android.support.** 
-dontwarn  com.android.volley.** 
-dontwarn  com.android.support.** 
-dontwarn  com.android.support.** 
-dontwarn  com.google.firebase.** 

ここで私はGradleのコンソールで見つかった、一見有用な情報がされます詳細な警告をご覧になりたい場合は、here

誰かがこの問題に取り組むのを手伝ってもらえますか?私はいつものようにソリューションが簡単なReBuildのように単純すぎると思っていますが、助けてください!

P.S.私はすでに完全なクリーンビルドと再構築を試みました。

答えて

2

あなたProGuardの-rules.txtにこれらを追加します。

-keep class java.awt.event.** { *; } 
-keep class org.apache.** { *; } 
-keep class org.gradle.** { *; } 
-keep class groovy.lang.** { *; } 
-keep class javax.swing.** { *; } 

これは、あなたが持っているエラーの数を減らす必要があります。すべての問題を解決するまで、より多くの文を追加してください。

+1

解決していただきありがとうございます。私も次の行を追加しなければなりません: '-ignorewarnings -keep class * { public private *; } ' –

関連する問題