无法在Android Studio中构建Release APK

幼敏悟过人,读书辄成诵。这篇文章主要讲述无法在Android Studio中构建Release APK相关的知识,希望能为你提供帮助。
在我的android应用程序中,我们集成了Paypal Payment方法。它运作良好。但是我们无法生成Release Apk。请帮我找出解决方案。
【无法在Android Studio中构建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_REPOauido runkCustomersAMITekhC-TunesClientsAndroidcTunesappuildintermediatesclasses-proguard eleaseclasses.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.*

答案你应该使用如下保持:
-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.** { *; }

另一答案我有同样的问题。
-dontwarn okio.**添加到proguard-project.txt为我解决了这个问题。
不确定,如果这可能会导致某些功能出现问题,但我的一次性付款工作正常。
伟大的工作Paypal。第一个v2.10.0停止工作,没有警告,v2.13.1需要额外的proguard东西......
另一答案尝试将此代码添加到build.gradle文件中。
android{ packagingOptions{ exclude 'AndroidManifest.xml' exclude 'lib/arm64-v8a/libcardioDecider.so' exclude 'lib/arm64-v8a/libcardioRecognizer.so' exclude 'lib/arm64-v8a/libcardioRecognizer_tegra2.so' exclude 'lib/arm64-v8a/libopencv_core.so' exclude 'lib/arm64-v8a/libopencv_imgproc.so' exclude 'lib/armeabi/libcardioDecider.so' exclude 'lib/armeabi-v7a/libcardioDecider.so' exclude 'lib/armeabi-v7a/libcardioRecognizer.so' exclude 'lib/armeabi-v7a/libcardioRecognizer_tegra2.so' exclude 'lib/armeabi-v7a/libopencv_core.so' exclude 'lib/armeabi-v7a/libopencv_imgproc.so' exclude 'lib/mips/libcardioDecider.so' exclude 'lib/x86/libcardioDecider.so' exclude 'lib/x86/libcardioRecognizer.so' exclude 'lib/x86/libcardioRecognizer_tegra2.so' exclude 'lib/x86/libopencv_core.so' exclude 'lib/x86/libopencv_imgproc.so' exclude 'lib/x86_64/libcardioDecider.so' exclude 'lib/x86_64/libcardioRecognizer.so' exclude 'lib/x86_64/libcardioRecognizer_tegra2.so' exclude 'lib/x86_64/libopencv_core.so' exclude 'lib/x86_64/libopencv_imgproc.so' } }

另一答案你需要在你的proguard文件中添加它:-dontwarn com.paypal.android.**而不是-dontwarn com.paypal.android.*

    推荐阅读