无法在Android Studio中构建Release APK
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无法在Android Studio中构建Release APK相关的知识,希望对你有一定的参考价值。
在我的android应用程序中,我们集成了Paypal Payment方法。它运作良好。但是我们无法生成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.*
以上是关于无法在Android Studio中构建Release APK的主要内容,如果未能解决你的问题,请参考以下文章
Android Studio 无法在 Windows 操作系统中构建反应原生项目
在 Android Studio 中使用 ProGuard 时我无法构建应用程序
无法在终端中构建应用程序,只能使用 Android Studio。 (离子,科尔多瓦)
Android Studio 升级到 3.1 后无法构建/同步新项目或现有项目
Visual Studio 中的 Cordova 项目无法在 Android 上构建:找不到 com.android.support:support-v4