草庐IT

android + eclipse + maven + actionbarsherlock

coder 2023-12-06 原文

我阅读了很多关于 actionbarsherlock、maven、android 的内容,但我所看到的解决方案没有一个对我有用:(

我确信我非常接近解决方案,但我不明白,我需要一些帮助:)

所以这是我的问题,我尝试创建一个依赖于 Actionbarsherlock 的 android maven 项目....这看起来很简单,但我总是遇到这些错误

[2013-01-16 18:10:28 - Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
[2013-01-16 18:10:28 - greennfc-samples] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
[2013-01-16 18:10:50 - Dex Loader] Unable to execute dex: Multiple dex files define Lorg/hamcrest/Description;
[2013-01-16 18:10:50 - greennfc-samples] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/hamcrest/Description;

这是我的配置:

eclipse 朱诺号 M2e 1.2.0 ADT 21 maven 3.0.4

这是父pom:

<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>org.sonatype.oss</groupId>
    <artifactId>oss-parent</artifactId>
    <version>7</version>
</parent>

<groupId>com.greennfc.tools</groupId>
<artifactId>greennfc</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Green NFC - Parent</name>
<description>Android Nfc library for an easer management of NFC features</description>
<packaging>pom</packaging>
<url>https://github.com/binomed/greennfc</url>
<inceptionYear>2013</inceptionYear>

<!-- 
<scm>
    <connection>scm:git:ssh://git@github.com/octo-online/robospice.git</connection>
    <url>git:ssh://git@github.com/octo-online/robospice.git</url>
    <developerConnection>scm:git:ssh://git@github.com/octo-online/robospice.git</developerConnection>
    <tag>HEAD</tag>
</scm>
 -->

<licenses>
    <license>
        <name>Apache 2</name>
        <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
</licenses>

<issueManagement>
    <system>Github Issue Tracker</system>
    <url>https://github.com/octo-online/robospice/issues</url>
</issueManagement>

<developers>
    <developer>
        <id>JFG</id>
        <name>Jean-Francois Garreau</name>
        <email>jean.francois.garreau@binomed.fr</email>
    </developer>
</developers>

<!-- 
<mailingLists>
    <mailingList>
        <name>RoboSpice Forum/Mailinglist</name>
        <post>http://groups.google.com/group/robospice</post>
        <subscribe>http://groups.google.com/group/robospice/subscribe</subscribe>
        <unsubscribe>https://groups.google.com/group/robospice/subscribe</unsubscribe>
    </mailingList>
</mailingLists>

<ciManagement>
    <system>jenkins</system>
    <url>https://robospice.ci.cloudbees.com/job/Build%20RoboSpice/</url>
</ciManagement>
 -->

<modules>
    <!-- core library -->
    <module>greennfc-core</module>

    <!-- Base librairies elements -->
    <module>greennfc-filters</module>

    <!-- extensions -->

    <!-- Demo -->
    <module>greennfc-samples</module>
</modules>

<properties>
    <android.version>4.1.1.4</android.version>
    <android-platform.version>14</android-platform.version>
    <android-annotations.version>4.1.1.4</android-annotations.version>
    <android-support.version>r7</android-support.version>
    <android-maven-plugin.version>3.5.0</android-maven-plugin.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <github.global.server>github</github.global.server>
    <maven.javadoc.skip>true</maven.javadoc.skip>
</properties>

<!-- TODO : remove this when android maven plugin 3.4.2 is out -->
<pluginRepositories>
    <pluginRepository>
        <id>oss.sonatype.org-jayway-snapshots</id>
        <name>Jayway OpenSource SNAPSHOTs on Sonatype.org</name>
        <url>http://oss.sonatype.org/content/repositories/jayway-snapshots/</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>annotations</artifactId>
            <version>${android-annotations.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>${android.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android-test</artifactId>
            <version>${android.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>provided</scope>
        </dependency>

        <!-- https://stackoverflow.com/questions/5591811/ignoring-innerclasses-attribute-warning-is-killing-eclipse -->
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.1</version>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <pluginManagement>
        <plugins>
            <!-- https://stackoverflow.com/questions/13040788/how-to-elimate-the-maven-enforcer-plugin-goal-enforce-is-ignored-by-m2e-wa -->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.apache.maven.plugins</groupId>
                                    <artifactId>maven-enforcer-plugin</artifactId>
                                    <versionRange>[1.0.0,)</versionRange>
                                    <goals>
                                        <goal>enforce</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore />
                                </action>
                            </pluginExecution>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.apache.maven.plugins</groupId>
                                    <artifactId>maven-dependency-plugin</artifactId>
                                    <versionRange>[1.0.0,)</versionRange>
                                    <goals>
                                        <goal>copy-dependencies</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore />
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>${android-maven-plugin.version}</version>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
            </plugin>
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.7</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <links>
                        <link>http://commons.apache.org/lang/api</link>
                        <link>http://java.sun.com/j2se/1.5.0/docs/api</link>
                    </links>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.1.2</version>
            </plugin>

            <!-- deploy artifacts to github for downloads -->
            <plugin>
                <groupId>com.github.github</groupId>
                <artifactId>downloads-maven-plugin</artifactId>
                <version>0.6</version>
                <configuration>
                    <description>${project.version} release of ${project.name}</description>
                    <override>true</override>
                    <includeAttached>true</includeAttached>
                    <includes>
                        <include>${project.artifactId}-${project.version}.jar</include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>upload</goal>
                        </goals>
                        <phase>deploy</phase>
                    </execution>
                </executions>
            </plugin>

            <!-- deploy javadoc and maven site to github -->
            <plugin>
                <groupId>com.github.github</groupId>
                <artifactId>site-maven-plugin</artifactId>
                <version>0.7</version>
                <configuration>
                    <message>Creating site for ${project.version}</message>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>site</goal>
                        </goals>
                        <phase>site</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <reportPlugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-project-info-reports-plugin</artifactId>
                            <version>2.2</version>
                            <configuration>
                                <dependencyDetailsEnabled>true</dependencyDetailsEnabled>
                                <dependencyLocationsEnabled>true</dependencyLocationsEnabled>
                            </configuration>
                        </plugin>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-javadoc-plugin</artifactId>
                            <version>2.7</version>
                        </plugin>
                    </reportPlugins>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

<profiles>
    <profile>
        <id>sign</id>
        <activation>
            <property>
                <name>performRelease</name>
                <value>true</value>
            </property>
        </activation>
        <properties>
            <maven.javadoc.skip>false</maven.javadoc.skip>
        </properties>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

这是我项目的pom

<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>com.greennfc.tools</groupId>
    <artifactId>greennfc</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</parent>

 <artifactId>greennfc-samples</artifactId>
  <packaging>apk</packaging>
 <name>Green Nfc - Samples</name>
 <properties>
    <notificationcompat2.version>1.1.2</notificationcompat2.version>
    <actionbarsherlock.version>4.2.0</actionbarsherlock.version>
    <roboguice.version>2.0</roboguice.version>
    <robosherlock.version>1.4</robosherlock.version>
    <google.http.client.version>1.12.0-beta</google.http.client.version>
    <simplexmlserializer.version>2.6.6</simplexmlserializer.version>
    <jackson.version>1.9.9</jackson.version>
</properties>

<dependencies>
    <!-- Green Nfc dependencies -->
    <dependency>
        <groupId>com.greennfc.tools</groupId>
        <artifactId>greennfc-core</artifactId>
        <version>${project.version}</version>
    </dependency>

    <!-- Other libs -->
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.android</groupId>
      <artifactId>support-v4</artifactId>
        <version>${android-support.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.actionbarsherlock</groupId>
      <artifactId>actionbarsherlock</artifactId>
      <version>${actionbarsherlock.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.actionbarsherlock</groupId>
        <artifactId>actionbarsherlock</artifactId>
        <version>${actionbarsherlock.version}</version>
        <type>apklib</type>
        <scope>provided</scope>
    </dependency>
</dependencies>  

<build>
    <sourceDirectory>src/</sourceDirectory>
    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <configuration>
                <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
                <assetsDirectory>${project.basedir}/assets</assetsDirectory>
                <resourceDirectory>${project.basedir}/res</resourceDirectory>
                <nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
                <sdk>
                    <platform>${android-platform.version}</platform>
                </sdk>
                <undeployBeforeDeploy>true</undeployBeforeDeploy>
            </configuration>
            <extensions>true</extensions>
        </plugin>

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>

这是我的尝试:

Maven Android Project with Test Suite http://v.zasadnyy.com/blog/abs-maven-eclipse-integration/

作为 actionbarsherlock 项目,我使用的是 git 存储库的头部,我复制了库目录,将其粘贴到与我的父项目相同的文件夹中,并根据 {groupId}-{artifactId}-{version} 重命名它

我真的愿意从头开始并找到正确的方法,因为我不明白为什么它不起作用...:(

预先感谢您的帮助

最佳答案

这是我修复它的方法。这是由于 Maven 试图在 Eclipse 也导出其 Android 依赖项时导出其依赖项:

  1. 项目->属性->Java 构建路径
  2. 转到“订购和导出”选项卡。
  3. 取消选中“Maven Dependencies”,这样它们就不会重复导出。
  4. 清理并尝试运行它。
  5. 如果仍然不起作用,请取消选中“Android Dependencies”。

关于android + eclipse + maven + actionbarsherlock,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14364067/

有关android + eclipse + maven + actionbarsherlock的更多相关文章

  1. ruby-on-rails - 如何优雅地重启 thin + nginx? - 2

    我的瘦服务器配置了nginx,我的ROR应用程序正在它们上运行。在我发布代码更新时运行thinrestart会给我的应用程序带来一些停机时间。我试图弄清楚如何优雅地重启正在运行的Thin实例,但找不到好的解决方案。有没有人能做到这一点? 最佳答案 #Restartjustthethinserverdescribedbythatconfigsudothin-C/etc/thin/mysite.ymlrestartNginx将继续运行并代理请求。如果您将Nginx设置为使用多个上游服务器,例如server{listen80;server

  2. ruby - 使用 `+=` 和 `send` 方法 - 2

    如何将send与+=一起使用?a=20;a.send"+=",10undefinedmethod`+='for20:Fixnuma=20;a+=10=>30 最佳答案 恐怕你不能。+=不是方法,而是语法糖。参见http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_expressions.html它说Incommonwithmanyotherlanguages,Rubyhasasyntacticshortcut:a=a+2maybewrittenasa+=2.你能做的最好的事情是:

  3. 安卓apk修改(Android反编译apk) - 2

    最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路

  4. ruby - 如何计算 Liquid 中的变量 +1 - 2

    我对如何计算通过{%assignvar=0%}赋值的变量加一完全感到困惑。这应该是最简单的任务。到目前为止,这是我尝试过的:{%assignamount=0%}{%forvariantinproduct.variants%}{%assignamount=amount+1%}{%endfor%}Amount:{{amount}}结果总是0。也许我忽略了一些明显的东西。也许有更好的方法。我想要存档的只是获取运行的迭代次数。 最佳答案 因为{{incrementamount}}将输出您的变量值并且不会影响{%assign%}定义的变量,我

  5. arrays - Ruby 数组 += vs 推送 - 2

    我有一个数组数组,想将元素附加到子数组。+=做我想做的,但我想了解为什么push不做。我期望的行为(并与+=一起工作):b=Array.new(3,[])b[0]+=["apple"]b[1]+=["orange"]b[2]+=["frog"]b=>[["苹果"],["橙子"],["Frog"]]通过推送,我将推送的元素附加到每个子数组(为什么?):a=Array.new(3,[])a[0].push("apple")a[1].push("orange")a[2].push("frog")a=>[[“苹果”、“橙子”、“Frog”]、[“苹果”、“橙子”、“Frog”]、[“苹果”、“

  6. += 的 Ruby 方法 - 2

    有没有办法让Ruby能够做这样的事情?classPlane@moved=0@x=0defx+=(v)#thisiserror@x+=v@moved+=1enddefto_s"moved#{@moved}times,currentxis#{@x}"endendplane=Plane.newplane.x+=5plane.x+=10putsplane.to_s#moved2times,currentxis15 最佳答案 您不能在Ruby中覆盖复合赋值运算符。任务在内部处理。您应该覆盖+,而不是+=。plane.a+=b与plane.a=

  7. ruby - Sinatra + Heroku + Datamapper 使用 dm-sqlite-adapter 部署问题 - 2

    出于某种原因,heroku尝试要求dm-sqlite-adapter,即使它应该在这里使用Postgres。请注意,这发生在我打开任何URL时-而不是在gitpush本身期间。我构建了一个默认的Facebook应用程序。gem文件:source:gemcuttergem"foreman"gem"sinatra"gem"mogli"gem"json"gem"httparty"gem"thin"gem"data_mapper"gem"heroku"group:productiondogem"pg"gem"dm-postgres-adapter"endgroup:development,:t

  8. ruby - Ruby 中字符串运算符 + 和 << 的区别 - 2

    我是Ruby和这个网站的新手。下面两个函数是不同的,一个在函数外修改变量,一个不修改。defm1(x)x我想确保我理解正确-当调用m1时,对str的引用被复制并传递给将其视为x的函数。运算符当调用m2时,对str的引用被复制并传递给将其视为x的函数。运算符+创建一个新字符串,赋值x=x+"4"只是将x重定向到新字符串,而原始str变量保持不变。对吧?谢谢 最佳答案 String#+::str+other_str→new_strConcatenation—ReturnsanewStringcontainingother_strconc

  9. ruby - rails 3.2.2(或 3.2.1)+ Postgresql 9.1.3 + Ubuntu 11.10 连接错误 - 2

    我正在使用PostgreSQL9.1.3(x86_64-pc-linux-gnu上的PostgreSQL9.1.3,由gcc-4.6.real(Ubuntu/Linaro4.6.1-9ubuntu3)4.6.1,64位编译)和在ubuntu11.10上运行3.2.2或3.2.1。现在,我可以使用以下命令连接PostgreSQLsupostgres输入密码我可以看到postgres=#我将以下详细信息放在我的config/database.yml中并执行“railsdb”,它工作正常。开发:adapter:postgresqlencoding:utf8reconnect:falsedat

  10. ruby - 在 Ruby + Chef 中检查现有目录失败 - 2

    这是我在ChefRecipe中的一blockRuby:#ifdatadirdoesn'texist,moveoverthedefaultoneif!File.exist?("/vol/postgres/data")execute"mv/var/lib/postgresql/9.1/main/vol/postgres/data"end结果是:Executingmv/var/lib/postgresql/9.1/main/vol/postgres/datamv:inter-devicemovefailed:`/var/lib/postgresql/9.1/main'to`/vol/post

随机推荐