Android Studio - ProGuard “java.io.IOException …bin\\classes (No such file or directory)”

匿名 (未验证) 提交于 2019-12-03 01:18:02

问题:

So I am running ProGuard for the first time and I am getting a weird error:

FAILURE: Build failed with an exception.  * What went wrong: Execution failed for task ':app:proguardRelease'. > java.io.IOException: Can't read [C:\Users\Some\workspace\MyApp\app\bin\classes] (No such file or directory)  * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

Here is my gradle:

apply plugin: 'android'  android {     compileSdkVersion 19     buildToolsVersion '19.1.0'      defaultConfig {         minSdkVersion 16         targetSdkVersion 19         versionCode 1         versionName "1.0"     }     buildTypes {         release {             runProguard true             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'         }     } }  dependencies {     compile 'com.android.support:support-v4:19.0.+'     compile 'com.google.android.gms:play-services:4.3.23'     compile fileTree(dir: 'libs', include: ['*.jar'])     compile 'com.viewpagerindicator:library:2.4.1@aar'     compile group:'com.android.support', name:'appcompat-v7', version:'18.0.+'     compile 'com.squareup.picasso:picasso:2.3+'     compile 'com.github.castorflex.smoothprogressbar:library:0.4.0' }  allprojects {     gradle.projectsEvaluated {         tasks.withType(JavaCompile) {             options.compilerArgs 

my proguard-rules.txt:

-injars      bin/classes -injars      libs -outjars     bin/classes-processed.jar -libraryjars /usr/local/java/android-sdk/platforms/android-9/android.jar  -dontpreverify -repackageclasses '' -allowaccessmodification -optimizations !code/simplification/arithmetic -keepattributes *Annotation*  -keep public class * extends android.app.Activity -keep public class * extends android.app.Application -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.content.ContentProvider  -keep public class * extends android.view.View {     public (android.content.Context);     public (android.content.Context, android.util.AttributeSet);     public (android.content.Context, android.util.AttributeSet, int);     public void set*(...); }  -keepclasseswithmembers class * {     public (android.content.Context, android.util.AttributeSet); }  -keepclasseswithmembers class * {     public (android.content.Context, android.util.AttributeSet, int); }  -keepclassmembers class * extends android.content.Context {    public void *(android.view.View);    public void *(android.view.MenuItem); }  -keepclassmembers class * implements android.os.Parcelable {     static ** CREATOR; }  -keepclassmembers class **.R$* {     public static ; }  -keepclassmembers class * {     @android.webkit.JavascriptInterface ; } 

回答1:

The Android Gradle plugin already specifies all input and output for you, so you must not specify -injars, -outjars, or -libraryjars.

Moreover, the file proguard-android.txt in the Android SDK specifies all generic Android settings for you, so you shouldn't specify them again.

Essentially, your file proguard-rules.txt can be empty, except for any application-specific settings to make sure any reflection continues to work.



回答2:

you no need these lines, because these are already defined.

-injars      bin/classes -injars      libs -outjars     bin/classes-processed.jar -libraryjars /usr/local/java/android-sdk/platforms/android-9/android.jar 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!