簡體   English   中英

無法生成簽名的APK

[英]Can't generate signed APK

我必須使用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'

請幫助我解決這個問題,謝謝

在您的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可能會有所幫助。

如我所見,您已在發行版本中啟用了proguard,因此使用pruguard發出警告是很常見的。

您的情況與lib com.kosalgeek.android.photoutil有關。 我認為您應該使用-dontwarn,如上文Devendra建議的那樣。

如果這不起作用,則可能應該為您的庫找到正確的proguard規則。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM