问题描述
于是我运行ProGuard的,第一次,我得到一个奇怪的错误:
失败:建立失败,一个例外。
* 什么地方出了错:
执行失败的任务:应用程序:proguardRelease。
> java.io.IOException异常:无法读取[C:\用户\有些\工作区\ MyApp的\程序\ BIN \类](没有这样的文件或目录)
* 尝试:
与--stacktrace选项获取堆栈跟踪运行。与--info或--debug选项运行,以获得更多的日志输出。
下面是我的摇篮:
应用插件:'机器人'
安卓{
compileSdkVersion 19
buildToolsVersion '19 .1.0
defaultConfig {
的minSdkVersion 16
targetSdkVersion 19
版本code 1
VERSIONNAME1.0
}
buildTypes {
推出 {
runProguard真
proguardFiles getDefaultProguardFile('ProGuard的-android.txt'),'ProGuard的-rules.txt
}
}
}
依赖{
编译com.android.support:support-v4:19.0.+
编译com.google.android.gms:播放服务:4.3.23
编译文件树(导演:库,包括:['的* .jar'])
编译com.viewpagerindicator:库:2.4.1@aar
编译组:com.android.support,名称:appcompat-V7,版本:'18 0.0 +。
编译com.squareup.picasso:毕加索:2.3+
编译com.github.castorflex.smoothprogressbar:图书馆:0.4.0
}
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile){
options.compilerArgs<< -Xlint:选中<< -Xlint:德precation
}
}
}
我的ProGuard-rules.txt:
-injars斌/班
-injars库
-outjars斌/班,processed.jar
-libraryjars /usr/local/java/android-sdk/platforms/android-9/android.jar
-dont preverify
-repackageclasses''
-allowaccessmodification
-optimizations!code /简/算术
-keepattributes *注释*
-keep公共类*扩展android.app.Activity
-keep公共类*扩展android.app.Application
-keep公共类*扩展android.app.Service
-keep公共类*扩展android.content.BroadcastReceiver
-keep公共类*扩展android.content.ContentProvider
-keep公共类*扩展android.view.View {
公共和LT; INIT>(android.content.Context);
公共和LT; INIT>(android.content.Context,android.util.AttributeSet);
公共和LT; INIT>(android.content.Context,android.util.AttributeSet,INT);
公共无效套*(......);
}
-keepclasseswithmembers类* {
公共和LT; INIT>(android.content.Context,android.util.AttributeSet);
}
-keepclasseswithmembers类* {
公共和LT; INIT>(android.content.Context,android.util.AttributeSet,INT);
}
-keepclassmembers类*扩展android.content.Context {
公共无效*(android.view.View);
公共无效*(android.view.MenuItem);
}
-keepclassmembers类*实现android.os.Parcelable {
静态** CREATOR;
}
-keepclassmembers类** R $ * {
公共静态<领域取代;
}
-keepclassmembers类* {
@ android.webkit.JavascriptInterface<方法&GT ;;
}
Android的摇篮插件已经指定了所有输入和输出你,所以你必须的没有的指定 -injars
, -outjars
或 -libraryjars
。
此外,该文件 ProGuard的-android.txt
在Android SDK中规定的所有通用的Android设置为你,所以你不应该再次指定它们。
从本质上讲,你的文件 ProGuard的-rules.txt
可以是空的,除了任何特定应用程序设置,以确保任何反映继续工作。
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 << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}
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 <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(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 <fields>;
}
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
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.
这篇关于Android的工作室 - ProGuard的&QUOT; java.io.IOException异常...斌\类(没有这样的文件或目录)&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!