Android maven+Eclipse luna构建/启动问题



我的android项目使用maven插件编写时遇到了一些问题。

第一个问题是,即使这个项目用maven构建得很好,我也无法启动它

Dx 
trouble writing output: already prepared
[2014-09-15 11:13:31 - easyex] Dx 
trouble processing "javax/xml/namespace/QName.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.
[2014-09-15 11:13:31 - easyex] Dx 1 error; aborting
[2014-09-15 11:13:31 - easyex] Conversion to Dalvik format failed with error 1

我在SO上看到了很多关于这个问题的问题,但没有人帮我。

为了解决这个问题,我尝试:

  1. 在java构建路径中,在Order and Export选项卡上取消选择Android 4.4W Library,只选择Maven Dependencies(因为它还包括Android运行时)。仍然会出现同样的错误
  2. 让maven更新项目的配置,在这种情况下,项目是由eclipse启动的,但我在主活动上有一个ClassNotFOund异常(似乎找不到类文件)
  3. 取消选择同一选项卡上的所有库,应用程序可以工作,但找不到android-support-v4中的NotificationCompatLibrary。(这也是第二个问题)。但我在pom中包含了支持库。我可以在maven依赖关系jar列表中看到它

这是我的pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.italialinux</groupId>
    <artifactId>easyex</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>easyex</name>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <platform.version>4.1.1.4</platform.version>
        <android.api.level>17</android.api.level>
        <android.plugin.version>3.8.2</android.plugin.version>
        <maven.compiler.source>1.6</maven.compiler.source>
        <maven.compiler.target>1.6</maven.compiler.target>
    </properties>
    <repositories>
        <repository>
            <id>repo</id>
            <url>file://${project.basedir}/repo</url>
            <releases>
                <enabled>true</enabled>
                <checksumPolicy>ignore</checksumPolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>com.italialinux</groupId>
            <artifactId>android-support-v4</artifactId>
            <version>1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>${platform.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>${android.plugin.version}</version>
                <configuration>
                    <dex>
                        <coreLibrary>true</coreLibrary>
                    </dex>
                    <sdk>
                        <path>${env.ANDROID_HOME}</path>
                        <platform>${android.api.level}</platform>
                    </sdk>
                    <deleteConflictingFiles>true</deleteConflictingFiles>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                </configuration>
                <extensions>true</extensions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                </configuration>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <!--This plugin's configuration is used to store Eclipse m2e settings 
                    only. It has no influence on the Maven build itself. -->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            com.jayway.maven.plugins.android.generation2
                                        </groupId>
                                        <artifactId>
                                            android-maven-plugin
                                        </artifactId>
                                        <versionRange>
                                            [3.8.2,)
                                        </versionRange>
                                        <goals>
                                            <goal>consume-aar</goal>
                                            <goal>
                                                generate-sources
                                            </goal>
                                            <goal>proguard</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

请注意,我为android-support-v4创建了一个自定义存储库,因为默认存储库中在线可用的版本似乎没有更新,并且缺少最新版本中可用的一些功能。

你知道如何解决这个问题吗?我不确定它是否与Eclipse Luna相关,但我在另一个Eclipse(开普勒)中配置了相同的项目,它运行良好。

总之,我有以下问题:

  1. 无法启动应用程序,出现错误写入输出时出现问题,已准备好
  2. 或者,如果我解决了这个问题,我对android支持库有问题,它不包括在构建路径中。但如果我在构建路径中包含maven依赖项,我会得到错误#1

编辑

我仍然有问题。但是我添加了更多的细节。如果我比较我的开普勒安装上的Maven依赖关系库和Luna中的依赖关系库,我可以看到在Luna库中,android包的依赖关系列表中有所有的jar(http://mvnrepository.com/artifact/com.google.android/android/4.1.1.4)。而在开普勒,我只能看到android-support-v4库。

在kepler安装中,我可以选择Maven Dependencies,并将它们放入构建路径中(这样我就可以拥有android支持的v4库),但使用luna,如果我包含Maven Depistencies,我会出现上面的错误。

编辑2kepler和luna之间的另一个区别是,第一个安装了eclipse 1.4版的m2e,第二个安装了1.5版。

我花了很多天的时间研究这个问题,发现了问题所在,以及两种可能的解决方案。

首先:是什么导致了这个问题?

m2e安卓插件仍然不能很好地与m2e插件1.5版本配合使用。这里有很好的记录:
https://github.com/rgladwell/m2e-android/issues/224

这个问题有两种可能的解决方案:

  1. 第一个是使用github中尚未发布的代码构建m2e android(这似乎解决了问题)。我没有尝试这个解决方案,但如果你想的话,这里解释了如何从源代码构建插件:
    https://github.com/rtack/m2e-android/tree/m2e-1.5

  2. 使用m2e插件1.4.*但您不能使用eclipse-luna来使用该插件。因此,你需要做的是用kepler复制luna并安装该插件的旧版本。

    由于在市场上只能使用最新版本,因此必须使用"安装新软件"手动安装。

    转到"帮助"->"安装新软件",然后使用以下URL添加新存储库:
    http://download.eclipse.org/technology/m2e/releases/1.4/1.4.1.20140328-1905

相关内容

  • 没有找到相关文章

最新更新