问题描述
因为功能的需要,添加了一个外部的jar包,添加之后运行就报出以下错误,
Error:trouble processing 'java/lang/AutoCloseable.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 fileError:in your application’s project, when using an IDE (such asError:Eclipse). If you are sure you’re not intentionally defining aError:core class, then this is the most likely explanation of what’sError:going on.Error:However, you might actually be trying to define a class in a coreError:namespace, the source of which you may have taken, for example,Error:from a non-Android virtual machine project. This will mostError:assuredly not work. At a minimum, it jeopardizes theError: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 onlyError:appropriate as part of creating a full virtual machineError:distribution, as opposed to compiling an application -- then useError:the '--core-library' option to suppress this error message.Error:If you go ahead and use '--core-library' but are in factError:building an application, then be forewarned that your applicationError:will still fail to build or run, at some point. Please beError:prepared for angry customers who find, for example, that yourError:application ceases to function once they upgrade their operatingError:system. You will be to blame for this problem.Error:If you are legitimately using some code that happens to be in aError:core package, then the easiest safe alternative you have is toError:repackage that code. That is, move the classes in question intoError:your own package namespace. This means that they will never be inError:conflict with core system classes. JarJar is a tool that may helpError:you in this endeavor. If you find that you cannot do this, thenError:that is an indication that the path you are on will ultimatelyError:lead to pain, suffering, grief, and lamentation.Error:1 error; aborting:app:transformClassesWithDexForDebug FAILEDError: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 ’/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/bin/java’’ finished with non-zero exit value 1
问题解答
回答1:自己找到了解决方案,不过具体为什么要这样做还不清楚。。解决方案:修改引起错误的jar包的scope属性,由compile->provided,这个操作可以在File->Project Structure->Dependencies 中修改 或者在project视图下 app文件夹中的build.gradle文件中里面有dependencies的内容,把对应jar包的compile修改为provided
回答2:试试用jdk1.7 编译看看