简体   繁体   English

使用maven-android-plugin不能将第三方jar包含到Android应用程序中

[英]Cannot include 3rd-party jars into Android application with the maven-android-plugin

I am trying to use the samples provided, but when I add another jar that I already created with POJO's, I am not able to compile the application anymore 我正在尝试使用提供的示例,但是当我添加另一个我用POJO创建的jar时,我无法再编译应用程序了

            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>maven-android-plugin</artifactId>
                <version>2.8.4</version>
                <configuration>
                    <sdk>
                        <platform>9</platform>
                    </sdk>
                    <emulator>
                        <avd>23</avd>
                        <wait>10000</wait>
                        <!--<options>-no-skin</options>-->
                    </emulator>
                    <zipalign>
                        <verbose>true</verbose>
                    </zipalign>
                    <deleteConflictingFiles>true</deleteConflictingFiles>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                </configuration>
            </plugin>

When I use my jar I created, I get this OOM error 当我使用我创建的jar时,我收到此OOM错误

    [INFO] solution is to recompile the class from source, using an up-to-date compiler
    [INFO] and without specifying any "-target" type options. The consequence of ignoring
    [INFO] this warning is that reflective operations on this class will incorrectly
    [INFO] indicate that it is *not* an inner class.
    [INFO]
    [INFO] UNEXPECTED TOP-LEVEL ERROR:
    [INFO] java.lang.OutOfMemoryError: Java heap space
    [INFO]  at com.android.dx.rop.code.RopMethod.calcPredecessors(RopMethod.java:153)
    [INFO]  at com.android.dx.rop.code.RopMethod.labelToPredecessors(RopMethod.java:95)
    [INFO]  at com.android.dx.dex.code.RopTranslator.pickOrder(RopTranslator.java:345)
    [INFO]  at com.android.dx.dex.code.RopTranslator.translateAndGetResult(RopTranslator.java:205)
    [INFO]  at com.android.dx.dex.code.RopTranslator.translate(RopTranslator.java:102)
    [INFO]  at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:289)
    [INFO]  at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:131)
    [INFO]  at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:85)
    [INFO]  at com.android.dx.command.dexer.Main.processClass(Main.java:369)
    [INFO]  at com.android.dx.command.dexer.Main.processFileBytes(Main.java:346)
    [INFO]  at com.android.dx.command.dexer.Main.access$400(Main.java:59)
    [INFO]  at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:294)
    [INFO]  at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:134)
    [INFO]  at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
    [INFO]  at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
    [INFO]  at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
    [INFO]  at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
    [INFO]  at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
    [INFO]  at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
    [INFO]  at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
    [INFO]  at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
    [INFO]  at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
    [INFO]  at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
    [INFO]  at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
    [INFO]  at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
    [INFO]  at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
    [INFO]  at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
    [INFO]  at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
    [INFO]  at com.android.dx.command.dexer.Main.processOne(Main.java:313)
    [INFO]  at com.android.dx.command.dexer.Main.processAllFiles(Main.java:233)
    [INFO]  at com.android.dx.command.dexer.Main.run(Main.java:185)
    [INFO]  at com.android.dx.command.dexer.Main.main(Main.java:166)
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Summary:
    [INFO]
    [INFO] Chapter 06: Mobile Device Parent .................. SUCCESS [0.359s]
    [INFO] Chapter 06: Mobile Device Application ............. FAILURE [1:27.859s]

I even tried upping the memory 我甚至试着增加记忆力

 set JAVA_OPTS="%JAVA_OPTS% -Xmx512m -XX:MaxPermSize=768m"

But still ran out for some reason. 但由于某种原因仍然用完了。

Now, when I try to use another jar from someone else, say Crest which states it works out-of-the-box with android: 现在,当我尝试使用其他人的另一个jar时,请说Crest声称它与Android开箱即用:

    <dependency>
        <groupId>org.codegist.crest</groupId>
        <artifactId>codegist-crest</artifactId>
    </dependency>

I then try to build and get this error: 然后我尝试构建并得到此错误:

    [INFO] trouble processing "javax/xml/bind/annotation/adapters/CollapsedStringAdapter.class":
    [INFO]
    [INFO] Ill-advised or mistaken usage of a core class (java.* or javax.*)
    [INFO] when not building a core library.
    [INFO]
    ...
    [INFO] If you are legitimately using some code that happens to be in a
    [INFO] core package, then the easiest safe alternative you have is to
    [INFO] repackage that code. That is, move the classes in question into
    [INFO] your own package namespace. This means that they will never be in
    [INFO] conflict with core system classes. JarJar is a tool that may help
    [INFO] you in this endeavor. If you find that you cannot do this, then
    [INFO] that is an indication that the path you are on will ultimately
    [INFO] lead to pain, suffering, grief, and lamentation.

So 所以

  1. how do I determine what classes I am able to use with an android application? 如何确定我可以使用Android应用程序的类?

  2. How do I structure a common domain jar that 我如何构建一个共同的域jar

Regarding OOM: try setting MAVEN_OPTS="-Xmx512m" instead of JAVA_OPTS 关于OOM:尝试设置MAVEN_OPTS =“ - Xmx512m”而不是JAVA_OPTS

Regarding core class: info you got is pretty informative. 关于核心课程:你获得的信息非常丰富。 Jar you have included contains some classes in core namespace, that is not allowed. 你包含的jar包含核心命名空间中的一些类,这是不允许的。 You can use jarjar as suggested. 你可以按照建议使用jarjar。

  1. you can use classes that are listed here: http://developer.android.com/reference/packages.html 您可以使用此处列出的类: http//developer.android.com/reference/packages.html
  2. seems incomplete question 似乎不完整的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM