android + eclipse + maven + actionbarsherlock

前端 未结 5 1503
心在旅途
心在旅途 2021-02-10 04:27

I read lots of things about actionbarsherlock, maven, android but none of the solution I\'ve seen worked for me :(

I\'m sure that I\'m pretty close to the solution but I

相关标签:
5条回答
  • 2021-02-10 04:48

    I had a very similar issue using Maven, Eclipse, and ActionBarSherlock. The problem is that the support library gets put into the build path twice, making the dexopt confused about the multiple declarations.

    I was able to get rid of one of the places where dexopt was finding the support library by changing the pom.xml for ActionBarSherlock from

    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>support-v4</artifactId>
    </dependency>
    

    to

    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>support-v4</artifactId>
        <scope>provided</scope>
    </dependency>
    

    Make sure you clean the project after saving this change.

    0 讨论(0)
  • 2021-02-10 04:52

    I tried hard to make the ActionBarSherlock lib project work with Maven but I failed. Similar issues. So I removed maven dependencies in the lib project and use libs/android-support-v4.jar instead. Btw, the test folder is also deleted. Then I run my own project with refers to the lib project. Things went well.

    0 讨论(0)
  • 2021-02-10 04:54

    Here's how I fixed it. It's due to Maven trying to export its dependencies when Eclipse is also exporting its Android dependencies:

    1. Project->Properties->Java Build Path
    2. Go to the Order and Export tab.
    3. Uncheck "Maven Dependencies" so they don't get double exported.
    4. Clean and try to run it.
    5. If it still doesn't work, also uncheck "Android Dependencies."
    0 讨论(0)
  • 2021-02-10 05:00

    Ok thanks every one for your answers, the things that worked for me was :

    1. Remove supportv4 libs from actionbarsherlock
    2. Comment the import of junit in actionbarsherlock project in order to avoid this generation
    0 讨论(0)
  • 2021-02-10 05:04

    You need to identify which dependencies in your pom.xml are including the classes that the Dalvik compiler is complaining about.

    1. In eclipse, you can identify what jar the problematic class belongs to by Open Type (on mac Command-T).

    2. Then you determine which transitive dependencies to those jars you have by looking up each direct dependency you have in maven central. And peering into the projects pom.xml.

    3. Once identified you need to add exclusion clauses to the corresponding dependency configuration in your project pom.xml.

    project pom.xml:

    <dependencies>
    <dependency>
            <groupId>...</groupId>
            <artifactId>...</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>org.hamcrest</artifactId>
                    <groupId>hamcrest</groupId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
    

    There's a brute force way to do it as well. Just open up the project in eclipse, expand the 'Maven Dependencies' in project viewer, then add the exclusion clause to each direct dependency in your project pom one by one, each time hitting save. The android maven configuration plugin will recalculate the dependencies under 'Maven Dependencies' and you'll see the problematic jar disappear. Once you get all of them your Dalvik errors will disappear as well.

    0 讨论(0)
提交回复
热议问题