【问题标题】:Not able to build Release APK in Android Studio无法在 Android Studio 中构建发布 APK
【发布时间】:2016-02-22 07:05:00
【问题描述】:

在我的 Android 应用程序中,我们集成了 Paypal 付款方式。它工作正常。但是我们无法生成 Release Apk。请帮我找出解决方案。

这是我的日志

Information:Gradle tasks [:app:assembleRelease]
:app:preBuild UP-TO-DATE
:app:preReleaseBuild UP-TO-DATE
:app:checkReleaseManifest
:app:preDebugBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
:app:prepareComAndroidSupportCardviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2311Library UP-TO-DATE
:app:prepareComAndroidSupportPaletteV72311Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42311Library UP-TO-DATE
:app:prepareComMcxiaokeVolleyLibraryAar100Library UP-TO-DATE
:app:prepareComPaypalSdkPaypalAndroidSdk2131Library UP-TO-DATE
:app:prepareIoCardAndroidSdk530Library UP-TO-DATE
:app:prepareReleaseDependencies
:app:compileReleaseAidl UP-TO-DATE
:app:compileReleaseRenderscript UP-TO-DATE
:app:generateReleaseBuildConfig UP-TO-DATE
:app:generateReleaseAssets UP-TO-DATE
:app:mergeReleaseAssets UP-TO-DATE
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources UP-TO-DATE
:app:mergeReleaseResources UP-TO-DATE
:app:processReleaseManifest UP-TO-DATE
:app:processReleaseResources UP-TO-DATE
:app:generateReleaseSources UP-TO-DATE
:app:processReleaseJavaRes UP-TO-DATE
:app:compileReleaseJavaWithJavac UP-TO-DATE
:app:compileReleaseNdk UP-TO-DATE
:app:compileReleaseSources UP-TO-DATE
:app:proguardRelease
Note: there were 29 duplicate class definitions.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
Warning:com.paypal.android.sdk.br: can't find referenced class com.google.android.gms.ads.identifier.AdvertisingIdClient
Warning:com.paypal.android.sdk.br: can't find referenced class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info
Warning:com.paypal.android.sdk.br: can't find referenced class com.google.android.gms.common.GooglePlayServicesUtil
Warning:com.paypal.android.sdk.br: can't find referenced class com.google.android.gms.ads.identifier.AdvertisingIdClient
Warning:com.paypal.android.sdk.br: can't find referenced class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info
Warning:com.paypal.android.sdk.br: can't find referenced class com.google.android.gms.common.GooglePlayServicesUtil
Warning:com.paypal.android.sdk.bs: can't find referenced class com.google.android.gms.ads.identifier.AdvertisingIdClient
Warning:com.paypal.android.sdk.bs: can't find referenced class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info
Warning:com.paypal.android.sdk.bs: can't find referenced class com.google.android.gms.ads.identifier.AdvertisingIdClient
Warning:com.paypal.android.sdk.bs: can't find referenced class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info
Warning:okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning:okio.Okio: can't find referenced class java.nio.file.Files
Warning:okio.Okio: can't find referenced class java.nio.file.Path
Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning:okio.Okio: can't find referenced class java.nio.file.Path
Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning:okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning:okio.Okio: can't find referenced class java.nio.file.Path
Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning:okio.Okio: can't find referenced class java.nio.file.Path
Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning:okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning:there were 24 unresolved references to classes or interfaces.
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Exception while processing task 
java.io.IOException: Please correct the above warnings first.
    at proguard.Initializer.execute(Initializer.java:473)
    at proguard.ProGuard.initialize(ProGuard.java:233)
    at proguard.ProGuard.execute(ProGuard.java:98)
    at proguard.gradle.ProGuardTask.proguard(ProGuardTask.java:1074)
    at com.android.build.gradle.tasks.AndroidProGuardTask.doMinification(AndroidProGuardTask.java:139)
    at com.android.build.gradle.tasks.AndroidProGuardTask$1.run(AndroidProGuardTask.java:115)
    at com.android.builder.tasks.Job.runTask(Job.java:48)
    at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41)
    at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:227)
    at java.lang.Thread.run(Thread.java:745)
:app:dexRelease UP-TO-DATE
:app:validateConfigSigning
:app:packageRelease FAILED
Error:Execution failed for task ':app:packageRelease'.
> Unable to compute hash of E:\AMI_REPO\auido\trunk\Customers\AMITekh\C-Tunes\Clients\Android\cTunes\app\build\intermediates\classes-proguard\release\classes.jar
Information:BUILD FAILED
Information:Total time: 5.526 secs
Information:1 error
Information:23 warnings
Information:See complete output in console

构建文件

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:recyclerview-v7:+'
    compile 'com.android.support:palette-v7:+'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.parse:parse-android:1.+'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.paypal.sdk:paypal-android-sdk:2.13.1'
}

Proguard.txt 文件

-dontwarn android.support.**
-dontwarn com.parse.*
-dontwarn com.paypal.android.*
-dontwarn com.google.android.gms.*

【问题讨论】:

标签: android paypal


【解决方案1】:

你应该像下面这样使用keep:

-keep class android.support.** { *; }
-keep interface android.support.** { *; }

-keep class com.parse.** { *; }
-keep interface com.parse.** { *; }

-keep class com.paypal.android.** { *; }
-keep interface com.paypal.android.** { *; }

-keep class com.google.android.gms.** { *; }
-keep interface com.google.android.gms.** { *; }

【讨论】:

  • 是的。只需尝试为您使用的每个库保留。其中一些不需要保留
  • Warnings have Gone.. 但它给出了以下错误
  • 错误:任务 ':app:packageRelease' 执行失败。 > 无法计算 E:\AMI_REPO\auido\trunk\Customers\AMITekh\C-Tunes\Clients\Android\cTunes\app\build\intermediates\classes-proguard\release\classes.jar 的哈希值
【解决方案2】:

我遇到了同样的问题。

添加 -dontwarn okio.** 到 proguard-project.txt 为我解决了问题。

不确定,这是否会导致某些功能出现问题,但我的一次性付款效果很好。

伟大的工作贝宝。首先 v2.10.0 在没有警告的情况下停止工作,而 v2.13.1 需要额外的 proguard 东西...

【讨论】:

    【解决方案3】:

    你需要在你的 proguard 文件中添加这个: -dontwarn com.paypal.android.** 代替 -dontwarn com.paypal.android.*

    【讨论】:

      猜你喜欢
      • 2018-06-10
      • 1970-01-01
      • 1970-01-01
      • 2013-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多