我必须使用android studio创建一个应用程序并且需要生成签名的Apk但是当我生成签名的Apk时它会显示一些警告并且构建失败请帮我解决这个问题这里是我的错误日志文件
Information:Gradle tasks [:app:assembleRelease]
Information:0 errors
Information:0 warnings
Information:See complete output in console
Warning:com.kosalgeek.android.photoutil.MainActivity: can't find referenced class com.kosalgeek.android.photoutil.R$layout
Warning:com.kosalgeek.android.photoutil.MainActivity: can't find referenced class com.kosalgeek.android.photoutil.R$id
Warning:com.kosalgeek.android.photoutil.MainActivity: can't find referenced class com.kosalgeek.android.photoutil.R$menu
Warning:com.kosalgeek.android.photoutil.MainActivity: can't find referenced class com.kosalgeek.android.photoutil.R$id
Warning:com.kosalgeek.android.photoutil.MainActivity: can't find referenced class com.kosalgeek.android.photoutil.R$layout
Warning:com.kosalgeek.android.photoutil.MainActivity: can't find referenced class com.kosalgeek.android.photoutil.R$id
Warning:com.kosalgeek.android.photoutil.MainActivity: can't find referenced class com.kosalgeek.android.photoutil.R$menu
Warning:com.kosalgeek.android.photoutil.MainActivity: can't find referenced class com.kosalgeek.android.photoutil.R
Warning:there were 9 unresolved references to classes or interfaces.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> java.io.IOException: Please correct the above warnings first.
Information:BUILD FAILED
Information:Total time: 1 mins 31.858 secs
我的libs文件夹中有photoutil.jar文件,但同样会出现同样的错误 请提前帮助我解决问题 这是我的傻瓜
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com.example.jijoabraham.informe"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
maven {
url "http://dl.bintray.com/lukaville/maven"
}
maven { url "https://jitpack.io" }
}
}
configurations{
all*.exclude group: 'com.mcxiaoke.volley'
}
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 files('libs/PhotoUtil.jar')
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:palette-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
compile 'com.yqritc:recyclerview-flexibledivider:1.2.4'
compile 'com.squareup.okhttp3:okhttp:3.3.1'
compile 'com.nbsp:library:1.09'
compile 'com.github.PhilJay:MPAndroidChart:v2.0.9'
compile 'com.google.firebase:firebase-database:9.6.1'
compile 'com.google.firebase:firebase-core:9.6.1'
compile 'com.pkmmte.view:circularimageview:1.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
请提前帮助我解决此问题
答案 0 :(得分:0)
在你的gradle中加上这个。
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/maven/pom.properties'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
在proguard-rules.pro
添加
-dontwarn com.kosalgeek.android.photoutil.**
并将true设置为minifyEnabled true
可能这会有所帮助。
答案 1 :(得分:0)
正如我所看到的,您已经在发布版本中启用了proguard,因此通过pruguard获取警告非常常见。
在您的情况下,这些与lib com.kosalgeek.android.photoutil有关。 我认为你应该使用 -dontwarn 作为上面提到的Devendra。
如果这不起作用,那么您可能应该为您的库找到正确的proguard规则。