“Conversion to Dalvik format failed with error 1” on external JAR

前端 未结 30 2528
抹茶落季
抹茶落季 2020-11-21 07:32

In my Android application in Eclipse I get the following error.

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already add

30条回答
  •  暖寄归人
    2020-11-21 07:52

    I ran into this problem because the Android-Maven-plugin in Eclipse was apparently not recognizing transitive references and references referenced twice from a couple of projects (including an Android library project), and including them more than once. I had to use hocus-pocus to get everything included only once, even though Maven is supposed to take care of all this.

    For example, I had a core library globalmentor-core, that was also used by globalmentor-google and globalmentor-android (the latter of which is an Android library). In the globalmentor-android pom.xml I had to mark the dependency as "provided" as well as excluded from other libraries in which it was transitively included:

        
            com.globalmentor
            globalmentor-core
            1.0-SNAPSHOT
            
            provided
        
    

    Then in the final application pom.xml I had to use the right trickery to allow only one inclusion path---as well as not explicitly including the core library:

        
        
        
        
        
        
    
        
            com.globalmentor
            globalmentor-google
            1.0-SNAPSHOT
            
                
                
                    com.globalmentor
                    globalmentor-core
                
            
        
    
        
            com.globalmentor
            globalmentor-android
            1.0-SNAPSHOT
        
    

提交回复
热议问题