抱歉英语不好,我是android studio的新开发者。
在这些日子里,我试图搜索一些在我的Android应用程序中工作的库。
我研究了两个库,CSS Parser和ph-css。
这些库我使用maven存储库来处理依赖关系。
CSS Parser - 我试图复制CSS Parser网页和此页面中显示的示例( stackoverflow.com/questions/1513587/looking-for-a-css-parser-in-java ),但有些类不存在,例如: CSSRule 。 想通了,我在eclipse中创建了一个项目,我找到了使用的库:
import org.w3c.dom.css.CSSRule;
import org.w3c.dom.css.CSSRuleList;
import org.w3c.dom.css.CSSStyleRule;
有了这个,我在maven资源库中搜索这些库,然后找到了页面( mvnrepository.com/artifact/xml-apis/xml-apis/1.4.01 )(XML-APIS)。所有错误都消失了,但是当我编译时出现这个错误。
Error:trouble processing "javax/xml/XMLConstants.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
This is often due to inadvertently including a core library file
in your application's project, when using an IDE (such as
Eclipse). If you are sure you're not intentionally defining a
core class, then this is the most likely explanation of what's
going on.
However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.
If you really intend to build a core library -- which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application -- then use
the "--core-library" option to suppress this error message.
If you go ahead and use "--core-library" but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.
If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.
ph-CSS - 我使用相同的过程,放入maven存储库并运行。另一个失败了,看来这条消息:
Error:PARSE ERROR:
Error:unsupported class file version 52.0
Error:...while parsing com/helger/commons/CGlobal.class
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_65\bin\java.exe'' finished with non-zero exit value 1
我尝试使用此页面( stackoverflow.com/questions/37902840/got-unsupported-class-file-version-52-0-after-including-a-module-to-a-project )
什么都没发生...... 当我看到作者更改日志关于jdk 8时,我试图使用它( developer.android.com/preview/j8-jack.html?hl=en ):
我删除了重复的文件,此消息显示:
Error:Library reading phase: Type javax.annotation.Untainted from file 'C:\Users\user\AndroidStudioProjects\CSSTest\app\build\intermediates\jill\debug\packaged\jsr305-3.0.1-dd0e9f5d0efb3025f6fde4238fd4a5c268f62a63.jar' has already been imported from file 'C:\Users\user\AndroidStudioProjects\CSSTest\app\build\intermediates\jill\debug\packaged\annotations-3.0.1u2-2b84c751906484cab0381cba276af74c2923d73b.jar', type 'javax.annotation.Untainted' (see property 'jack.import.type.policy' for type collision policy)
com.android.jack.api.v01.CompilationException: Library reading phase: Type javax.annotation.Untainted from file 'C:\Users\user\AndroidStudioProjects\CSSTest\app\build\intermediates\jill\debug\packaged\jsr305-3.0.1-dd0e9f5d0efb3025f6fde4238fd4a5c268f62a63.jar' has already been imported from file 'C:\Users\user\AndroidStudioProjects\CSSTest\app\build\intermediates\jill\debug\packaged\annotations-3.0.1u2-2b84c751906484cab0381cba276af74c2923d73b.jar', type 'javax.annotation.Untainted' (see property 'jack.import.type.policy' for type collision policy)
现在,我不知道如何解决这个问题。有什么提示吗?
道歉,我没有包含超链接,因为我没有声誉要求。
答案 0 :(得分:0)
Android不支持jdk 8的所有功能,因此在使用最新版本的ph-css(使用jdk 8编译)时会出现不支持的类文件版本52-0错误。但是,您可以使用版本4.1.4,这是最后一个通过将其添加到build.gradle文件来编译的jdk 6/7
dependencies {
compile 'com.helger:ph-css:4.1.4'
}