【问题标题】:CSS Parser for android适用于 Android 的 CSS 解析器
【发布时间】:2016-12-24 07:29:11
【问题描述】:

抱歉英语不好,我是 android studio 的新开发人员。

这些天来,我试图搜索一些在我的 android 应用程序中工作的库。

我研究了两个库,CSS Parserph-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 - 我使用相同的过程,将 gradle 放入 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-includes-a-module-to-a-project强>)在stackoverflow中

什么都没有发生... 当我看到作者关于 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)

现在,我不知道如何解决这个问题。有什么建议吗?

抱歉,我没有包含超链接,因为我没有声誉要求。

【问题讨论】:

    标签: android css parsing


    【解决方案1】:

    Android 不支持 jdk 8 的所有功能,因此在使用最新版本的 ph-css(使用 jdk 8 编译)时会出现 unsupported-class-file-version-52-0 错误。但是,您可以通过将其添加到 build.gradle 文件中来使用版本 4.1.4,这是针对 jdk 6/7 编译的最后一个版本

    dependencies {
        compile 'com.helger:ph-css:4.1.4'
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-07
      • 1970-01-01
      相关资源
      最近更新 更多