使用Proguard与Android Studio生成签名apk时出现问题
build.gradle文件使用Proguard与Android Studio生成签名apk时出现问题,android,android-studio,android-gradle-plugin,build.gradle,Android,Android Studio,Android Gradle Plugin,Build.gradle,build.gradle文件 apply plugin: 'com.android.application' android { signingConfigs { config { keyAlias 'abc' keyPassword 'feet' storeFile file('C:/Users/Nabasree/Desktop/mylocation') storePa
apply plugin: 'com.android.application'
android {
signingConfigs {
config {
keyAlias 'abc'
keyPassword 'feet'
storeFile file('C:/Users/Nabasree/Desktop/mylocation')
storePassword 'feet'
}
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
compileSdkVersion 19
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "in.myapp"
minSdkVersion 14
targetSdkVersion 19
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
debug {
debuggable true
signingConfig signingConfigs.config
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
productFlavors {
}
}
dependencies {
compile project(':facebookSDK')
compile project(':glowPadView')
compile project(':pullToRefreshListView')
compile project(':librari')
// compile ('com.github.flavienlaurent.datetimepicker:library:VERSION');
compile project(':viewPagerIndicatorLib')
compile files('libs/android-saripaar-1.0.2.jar')
compile files('libs/android-support-v13.jar')
compile files('libs/com.haarman.listviewanimations-2.6.0.jar')
compile files('libs/crashlytics.jar')
compile files('libs/eventbus-2.2.1.jar')
compile files('libs/image-chooser-library-1.3.0.jar')
compile files('libs/Parse-1.7.1.jar')
compile files('libs/picasso-2.3.2.jar')
compile files('libs/sugar-1.2.jar')
}
我几乎没有像facebook这样的图书馆项目。我的项目和库都使用相同版本的支持库v13
在生成签名的apk时,我遇到了以下错误
任务“:myapp:proguardRelease”的执行失败
我不知道如何解决这个问题并生成一个签名的apk
还查看了library projects libs文件夹,但没有找到android-support-v4.jar。我所拥有的只是android-support-v13.jar不要直接引用支持库中的jar;当您这样做时,构建系统无法在它的多个版本之间消除歧义,并且会出现这种类型的错误。通过引用其Maven坐标将其包括在内:
dependencies {
compile 'com.android.support:support-v13:X.X.X'
}
其中X.X.X是基于您编译所使用的API的正确版本号。如果您通过UI在“项目结构”>“模块”>“依赖项”>“按钮”>“库依赖项”中包含此依赖项,它将帮助您选择正确的版本号
您还可能会发现,通过Maven坐标包含其他依赖项,而不是纠缠它们的JAR,是很方便的;同一个库依赖项UI有一个搜索功能来帮助您查找库。如上所述,我从SDK添加了support-v13,直接依赖库,而不是通过lib文件夹 除了上述更改,我还对proguard-android.txt文件进行了一些修改 对于添加的第三方库:
-dontwarn android.support.**,com.example.**,com.example1.**
facebook补充道:
-keep class com.facebook.** {
*;
}
现在,它工作正常。嗨,纳巴斯利,你找到解决问题的方法了吗?我现在看到了完全相同的错误,我相信我正在像你一样拉扯我的头发:[要添加到这一点,请确保从libs或它所在的任何其他文件夹中删除此库
-keep class com.facebook.** {
*;
}