java.lang.IllegalArgumentException: already added: Lorg/hamcrest/BaseDescription; Conversion to Dalvik format failed with error 1

前端 未结 3 701
难免孤独
难免孤独 2021-01-04 11:13

First of all, there are at least 2 postings with the same problem but these solutions don\'t work anymore, at least not in my installation.

I\'m using m2e with Eclip

3条回答
  •  迷失自我
    2021-01-04 11:46

    I tried the above solutions and still got the error. Only after some more try and error I found out that the hamcrest classes are also contained in another jar: mockito (I was not yet aware that mockito won't work with my instrumentation tests)

    So I solved my problem by removing mockito-all.jar from my dependencies and excluded hamcrest from the transitive dependencies of junit like this:

     
        junit
        junit
        test
        4.10
        
            
                hamcrest-core
                org.hamcrest
            
        
      
    

    This exclusion may also be needed for commons-logging (as of the date of writing) because otherwise the apk builder will protest about old classes.

提交回复
热议问题