【问题标题】:Run Time Error Android Studio - Because of Adding JAR运行时错误 Android Studio - 由于添加 JAR
【发布时间】:2016-08-27 09:45:00
【问题描述】:

首先我想道歉,如果我的帖子不准确,或者它对其他帖子有一些苛刻的想象,我可以用它来解决问题 - 一直在寻找但没有找到。

所以,我使用的是 Android Studio 2.1 最新和最新版本。

所以我有一个应用程序做一些非常非常基本的事情.. 我使用声音等,所以我尝试使用以下罐子:

First Jar | Second Jar

问题是,在尝试使用 Jars 之前,我可以完美地运行我的文件并且应用程序按预期工作。

当尝试通过添加这 2 个 Jars(或仅 1 个)和使用这些 Jars 的相关类代码来扩展应用程序功能时,应用程序将无法启动,它甚至不会在设备或模拟器上加载.值得一提的是 - 我尝试仅使用 jars(没有新代码)运行应用程序以隔离问题并确保 jars 是问题所在。

据我所知,这些罐子会导致问题,这是 SDK 返回的错误日志:

Error:trouble processing "java/applet/Applet.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
:app:transformClassesWithDexForDebug FAILED
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_66\bin\java.exe'' finished with non-zero exit value 1

抛出该错误后,进程终止,应用程序甚至不会加载/开始运行。如果我删除 jar 文件并完全重新运行相同的代码 - 它工作得很好。

【问题讨论】:

  • 阅读错误信息... "您实际上可能正在尝试在核心命名空间中定义一个类,例如,您可能从非 Android虚拟机项目。这肯定行不通“... tl;dr Android 不满意java.*javax.* 包的使用

标签: java android android-studio jar


【解决方案1】:

看起来问题出在 Jars 文件上。问题可能是由包含较旧的库或您的 IDE 配置错误引起的。根据 android jar 检查您的依赖项。 可能不得不考虑文件来解决问题...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-17
    • 1970-01-01
    • 1970-01-01
    • 2015-11-28
    • 2015-04-01
    • 2021-07-08
    • 1970-01-01
    相关资源
    最近更新 更多