尝试生成签名的APK Android Studio 3时出错 [英] getting error while try to generate signed APK android studio 3

查看:106
本文介绍了尝试生成签名的APK Android Studio 3时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在android studio 3中生成签名的APK时出现以下错误

I am getting the following error when try to generate signed APK in android studio 3

 Error:trouble processing "javax/xml/namespace/QName.class":
Error:Ill-advised or mistaken usage of a core class (java.* or javax.*)
Error:when not building a core library.
Error:This is often due to inadvertently including a core library file
Error:in your application's project, when using an IDE (such as
Error:Eclipse). If you are sure you're not intentionally defining a
Error:core class, then this is the most likely explanation of what's
Error:going on.
Error:However, you might actually be trying to define a class in a core
Error:namespace, the source of which you may have taken, for example,
Error:from a non-Android virtual machine project. This will most
Error:assuredly not work. At a minimum, it jeopardizes the
Error:compatibility of your app with future versions of the platform.
Error:It is also often of questionable legality.
Error:If you really intend to build a core library -- which is only
Error:appropriate as part of creating a full virtual machine
Error:distribution, as opposed to compiling an application -- then use
Error:the "--core-library" option to suppress this error message.
Error:If you go ahead and use "--core-library" but are in fact
Error:building an application, then be forewarned that your application
Error:will still fail to build or run, at some point. Please be
Error:prepared for angry customers who find, for example, that your
Error:application ceases to function once they upgrade their operating
Error:system. You will be to blame for this problem.
Error:If you are legitimately using some code that happens to be in a
Error:core package, then the easiest safe alternative you have is to
Error:repackage that code. That is, move the classes in question into
Error:your own package namespace. This means that they will never be in
Error:conflict with core system classes. JarJar is a tool that may help
Error:you in this endeavor. If you find that you cannot do this, then
Error:that is an indication that the path you are on will ultimately
Error:lead to pain, suffering, grief, and lamentation.
Error:1 error; aborting
Error:Execution failed for task ':_4SaleApp:transformClassesWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --num-threads=4 --multi-dex --main-dex-list /Volumes/Data/AMIRA/Work/Q84Sale/Q84Sale/_4SaleApp/build/intermediates/multi-dex/release/maindexlist.txt --output /Volumes/Data/AMIRA/Work/Q84Sale/Q84Sale/_4SaleApp/build/intermediates/transforms/dex/release/0 --min-sdk-version 16 /Volumes/Data/AMIRA/Work/Q84Sale/Q84Sale/_4SaleApp/build/intermediates/transforms/jarMerging/release/0.jar}

任何人都可以帮忙吗?

推荐答案

XPP答案对我不起作用.大多数交叉引用的答案都忽略了这可能是由其他库依赖项(即JAR/AAR)引起的.在我的情况下,此错误仅在已签名的构建过程中出现-未签名的构建很好.

The XPP answer did not work for me. Most of the cross-referenced answers ignore that this can be caused by other library dependencies (i.e. JARs/AARs). In my case this error was only appearing during the signed build -- unsigned builds were fine.

运行'gradlew:[MY-PROJECT]:dependencies'显示完整的依赖树.如果在javax/java命名空间中找到使用JAR或类的依赖项,则可以在依赖项声明中添加gradle exclude语句,例如(gradle 4.1 +):

Running 'gradlew :[MY-PROJECT]:dependencies' shows the full dependency tree. If you find a dependency that uses a JAR or classes in the javax/java namespace, then you can add a gradle exclude statement to your dependency declaration, such as (gradle 4.1+):

api('my.favorite.dependency') { exclude group: 'javax' }

api('my.favorite.dependency') { exclude group: 'javax' }

然后再次运行gradle':dependencies'任务.您应该看到现在已从树中删除了排除的依赖项.如果编译需要此依赖关系,而其他地方未提供此依赖关系,则build */assemble *任务将失败.如果依赖项在运行时是必需的,而在其他地方未提供(例如).由操作系统,然后是应用程序.将编译,然后在运行时失败,并带有"ClassNotFound"异常.

Then run the gradle ':dependencies' task again. You should see that the excluded dependency is now removed from the tree. If this dependency is required for compilation and not provided elsewhere, then the build*/assemble* tasks will fail. If the dependency is required at runtime and not provided elsewhere, for ex. by the OS, then the app. will compile and then fail at runtime with a "ClassNotFound" exception.

在最坏的情况下,如果依赖关系树没有太大帮助,那么您可能必须开始注释掉依赖关系以及使用它们的代码,以找出罪魁祸首.希望几乎没有使用导致此错误的依赖项.一旦找到导致错误的依赖关系,就需要使用以下两种方法之一来解决这种情况.可以用不会引起错误的东西替换JAR/AAR;或重建依赖关系,以使javax/java类不会随JA​​R/AAR一起导出.

In the worst case, if the dependency tree isn't much help, then you may have to start commenting-out dependencies and the code that uses them, to find the culprit dependency. Hopefully the dependency that caused this error was barely used. Once you find the dependency that causes the error, you need to fix the situation one of two ways. Either replace the JAR/AAR with something that doesn't cause the error; or rebuild the dependency so that the javax/java classes are not exported with the JAR/AAR.

这篇关于尝试生成签名的APK Android Studio 3时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆