无法签署发布 APK - :app:shrinkReleaseMultiDexComponents FAILED [英] Unable to sign release APK - :app:shrinkReleaseMultiDexComponents FAILED
问题描述
我正在尝试生成已签名的 apk,但日志不断向我显示以下错误:
I'm trying to generate a signed apk and the log keeps showing me the following error:
:app:compileReleaseJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:app:compileReleaseNdk UP-TO-DATE
:app:compileReleaseSources
:app:collectReleaseMultiDexComponents
:app:proguardRelease
Warning:com.google.android.gms.internal.zzac: can't find referenced class android.net.http.AndroidHttpClient
Warning:com.google.android.gms.internal.zzw: can't find referenced method 'void addHeader(java.lang.String,java.lang.String)' in program class com.google.android.gms.internal.zzw$zza
Warning:com.google.android.gms.internal.zzw$zza: can't find referenced method 'void setURI(java.net.URI)' in program class com.google.android.gms.internal.zzw$zza
Warning:com.ironsource.mobilcore.j: can't find referenced method 'void setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)' in library class android.app.Notification
Warning:com.mopub.volley.toolbox.HttpClientStack: can't find referenced method 'void addHeader(java.lang.String,java.lang.String)' in program class com.mopub.volley.toolbox.HttpClientStack$HttpPatch
Warning:com.mopub.volley.toolbox.HttpClientStack$HttpPatch: can't find referenced method 'void setURI(java.net.URI)' in program class com.mopub.volley.toolbox.HttpClientStack$HttpPatch
Warning:com.mopub.volley.toolbox.Volley: can't find referenced class android.net.http.AndroidHttpClient
Warning:there were 4 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)
Warning:there were 4 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile the code.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
Warning:there were 1 unresolved references to library class members.
You probably need to update the library versions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
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:shrinkReleaseMultiDexComponents FAILED
Error:Execution failed for task ':app:shrinkReleaseMultiDexComponents'.
> java.io.IOException: The output jar [<project_path>\app\build\intermediates\multi-dex\release\componentClasses.jar] must be specified after an input jar, or it will be empty.
以下是我的应用级 build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.my.app"
minSdkVersion 14
targetSdkVersion 23
versionCode 25
versionName "2.5"
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
javaMaxHeapSize "2048M"
}
}
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.2.0'
compile 'me.dm7.barcodescanner:zxing:1.7.2'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.scottyab:secure-preferences-lib:0.1.3'
compile 'com.soundcloud.android:android-crop:1.0.0@aar'
compile('com.afollestad.material-dialogs:core:0.8.1.0@aar') {
transitive = true
}
compile('com.mopub:mopub-sdk:3.13.0@aar') {
transitive = true
}
compile project(':android-support-v4-preferencefragment')
compile project(':circular_progress_bar')
compile files('libs/mobilecore_V1.1.jar')
compile files('libs/libAdapterSDKMoPub.jar')
compile files('libs/adcolony.jar')
}
还有我的顶级 build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
我尝试过其他版本的 gradle,如 1.4.0-beta1'、1.4.0-beta2
和 1.3.1
仍然没有运气.
I have tried with other version of gradle like 1.4.0-beta1', 1.4.0-beta2
, and 1.3.1
still no luck.
推荐答案
在你的跟踪中有一些信息 --
There is some info right there in your trace --
警告:有 4 个未解析的类或接口引用.您可能需要添加缺少的库 jar 或更新它们的版本.如果您的代码在没有丢失类的情况下运行良好,您可以取消带有-dontwarn"选项的警告.(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning:there were 4 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)
您的问题至少有一部分是在 API 23 中删除了 AndroidHttpClient
,并且您的库中至少有一个依赖于它.你有三个选择.
At least part of your problem is that AndroidHttpClient
was removed in API 23, and at least one of your libraries depends on it. You have three options.
1) 您可以在 build.gradle
文件中包含以下内容.其中包括您的 apk 中的遗留库.请参阅 Apache HTTP 客户端删除一>.
1) You can include the following in your build.gradle
file. Which includes the legacy library in your apk. See Apache HTTP Client Removal.
android {
useLibrary 'org.apache.http.legacy'
}
2) 您可以降低目标并将 sdk 编译为 22 而不是 23.这应该允许您编译,或至少解决 AndroidHttpClient
问题,直到库更新为不需要它为止.
2) You can lower your target and compile sdk to 22 instead of 23. That should allow you to compile, or at least resolve the AndroidHttpClient
issue until the libraries are updated to not require it.
3) 您可以将 -dontwarn
命令添加到您的 proguard 文件中,以抑制警告以获取构建.如文档中所述,如果您不确定可以安全地忽略警告,这可能很危险.我不确定忽略因删除 HttpClient
和相关类而产生的警告是否安全.在 M 上运行时可能会导致构建不稳定,但对于 L 及以下应该是安全的,因为这些类存在于该 API 级别的设备上.
3) You can add -dontwarn
commands to your proguard file to suppress the warns to get a build. As noted in the documentation, this can be dangerous if you aren't certain the warnings can be safely ignored. I am not certain if ignoring warnings stemming from the removal of HttpClient
and associated classes is safe or not. It might lead to an unstable build when running on M, but should be safe for L and below because those classes exist on devices at that API level.
添加:对于同样挣扎的人,请记住,您必须将依赖项中的 builToolsVersion
和 com.android.support
降低到 22.0.1代码>.
ADDED:
For whoever struggles the same, keep in mind that you'll have to lower your builToolsVersion
and com.android.support
in the dependency to 22.0.1
.
这篇关于无法签署发布 APK - :app:shrinkReleaseMultiDexComponents FAILED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!