简体   繁体   English

无法生成签名的APK

[英]Can't generate signed APK

I have to create an Application using android studio and need to generate signed Apk but when i generate signed Apk it will show some warning and build failed please help me to solve this problem here is my error log file 我必须使用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

I have photoutil.jar file in my libs folder but again a get the same error please help me to solve the problem thanks in advance here is my gradle 我的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'

please help me to solve this problem thanks in advance 请帮助我解决这个问题,谢谢

In your gradle add this. 在您的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'

        }
    }

In proguard-rules.pro add proguard-rules.pro添加

-dontwarn com.kosalgeek.android.photoutil.**

And set true to minifyEnabled true May be this will help. 并将true设置为minifyEnabled true可能会有所帮助。

As I can see you have enabled proguard in your release build so it is very common getting warnings with pruguard. 如我所见,您已在发行版本中启用了proguard,因此使用pruguard发出警告是很常见的。

In your case those are related to the lib com.kosalgeek.android.photoutil. 您的情况与lib com.kosalgeek.android.photoutil有关。 I think you should use -dontwarn as Devendra suggested above. 我认为您应该使用-dontwarn,如上文Devendra建议的那样。

If this doesn't work then probably you should find the correct proguard rules for your library. 如果这不起作用,则可能应该为您的库找到正确的proguard规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM