Development Tip

여러 dex 파일이 landroid / support / annotation / AnimRes를 정의합니다.

yourdevel 2020. 12. 6. 22:13
반응형

여러 dex 파일이 landroid / support / annotation / AnimRes를 정의합니다.


내 의존성에 안드로이드 지원 주석을 추가 한 순간

compile 'com.android.support:support-annotations:20.0.0'

이 오류가 발생했습니다.

오류 코드 : 2 출력 : UNEXPECTED TOP-LEVEL EXCEPTION : com.android.dex.DexException : Multiple dex files define Landroid / support / annotation / AnimRes; com.android.dx.merge.DexMerger.readSortableTypes (DexMerger.java:594) at com.android.dx.merge.DexMerger.getSortedTypes (DexMerger.java:552) at com.android.dx.merge.DexMerger.mergeClassDefs (DexMerger.java:533) at com.android.dx.merge.DexMerger.mergeDexes (DexMerger.java:170) at com.android.dx.merge.DexMerger.merge (DexMerger.java:188) at com.android. dx.command.dexer.Main.mergeLibraryDexBuffers (Main.java:439) at com.android.dx.command.dexer.Main.runMonoDex (Main.java:287) at com.android.dx.command.dexer.Main. com.android.dx.command.dexer.Main.main (Main.java:199)에서 com.android.dx.command.Main.main (Main.java:103)에서 실행 (Main.java:230)

build.gradle

android {
    compileSdkVersion 19
    buildToolsVersion '20.0.0'

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 19
    }
}

dependencies {
    compile 'com.android.support:support-v4:19.0.0'
    compile 'com.crashlytics.android:crashlytics:1.+'
    compile 'com.android.support:support-annotations:20.0.0'
}

이 문제를 경험 한 사람이 있습니까? 나는 여기 에서 해결책을 시도했다 .


문제는 android-support-annotations.jarAndroid 주석을 포함하는 별도의 라이브러리 였지만 어떤 이유로 이러한 주석이 이미 android-support-v4.jar파일의 최신 버전에 포함되어 있다는 것입니다 .

주석 jar를 삭제하면 문제가 해결되었습니다.


빌드-> 깨끗한 프로젝트, 작동했습니다.


android-support-v4.jar을 삭제했는데 제대로 작동했습니다.


이것이 Cordova / ionic 프로젝트라면 이것은 나를 위해 일했습니다.

이 줄을 platform / android 아래의 build.gradle에 22 번 줄 뒤에 추가합니다. 즉, 플러그인 적용: 'android'

configurations {
   all*.exclude group: 'com.android.support', module: 'support-v4'
}

페이스 북 플러그인을 사용한 Cordova 프로젝트에서이 정확한 문제를 해결했습니다. 다음 platforms\android\project.properties과 같이 에서이 줄을 주석 처리하여 성공적으로 빌드 할 수있었습니다 .

# cordova.system.library.1=com.android.support:support-v4:+

그리고 다음 platforms\android\build.gradle과 같이 에서이 줄을 주석 처리합니다 .

// compile "com.android.support:support-v4:+"

그런 다음 빌드를 수행합니다. 이 줄을 추가 한 (katzer / cordova-plugin-local-notifications)를 설치했을 때 문제가 시작되었지만 빌드에 추가하는 라이브러리가 이미 facebook 플러그인 빌드의 일부이기 때문에 충돌이 발생했습니다.


다른 사용자가 말했듯이 문제를 해결해야하는 첫 번째 요소는 종속성입니다. 그러나 때로는 몇 시간 동안 어려움을 겪고 문제를 찾지 못하므로 대신 빌드 프로세스 에 집중할 수 있습니다 .

파일이 생성 되는 방식을.dex 변경 하면 때때로 문제가 해결됩니다. 다음 단계를 수행 할 수 있습니다.

  • Build.gradle (앱) 파일을 엽니 다.
  • 작업 dexOptions 검색
  • 다음으로 변경하십시오.

    dexOptions {
      incremental false 
    }
    

파일에서 작업을 찾지 못한 경우 추가 할 수 있습니다.


저에게 그 이유는 새로운 데이터 바인딩 라이브러리였습니다.

com.android.databinding:dataBinder:1.0-rc2

어떻게 든 충돌하는 버전의 주석 lib를 사용했습니다.

configurations.all {
    resolutionStrategy {
        force group: 'com.android.support', name: 'support-v4', version: '23.1.0'
        force group: 'com.android.support', name: 'appcompat-v7', version: '23.1.0'
        force group: 'com.android.support', name: 'support-annotations', version: '23.1.0'
    }
}

그러나 새 버전 rc3rc4버전이 문제를 해결 한 것 같으므로 해당 버전을 사용하십시오.


같은 문제가 있었지만 빌드 폴더에서 빌드 파일을 삭제했습니다.

프로젝트 이름 / 앱 / 빌드

그리고 모든 관련 오류를 제거했습니다. "프로젝트를 정리할 수 없습니다."및 "$ anim을 사용하여 오류 발생"


이 문제를 해결했습니다. 그 이유는 Android 지원 라이브러리 19.0.0을 종속성으로 포함했지만 19.1.0이 필요하기 때문입니다. 자세한 내용은 여기를 참조하십시오.

그래서 그것은

dependencies {
    compile 'com.android.support:support-v4:19.1.0'
    compile 'com.crashlytics.android:crashlytics:1.+'
    compile 'com.android.support:support-annotations:20.0.0'
}

If you import AppCompat as a library project and you also have android-support-annotations.jar in libs elsewhere, make sure to import everywhere AppCompat library only (it already includes this annotations lib). Then delete all android-support-annotations.jar to avoid merging multiple versions of this library.


Updating Android SDK Tools fixed it for me, now it just sees the copy in android-support-v4.jar.

I had the same problem when using ant, and the annotations library was being included automatically by an outdated sdk.dir/tools/ant/build.xml.


Clean project works as a temporary fix, but the issue will reappear on next compilation error.

To fix more reliably, I had to update the dependency to android support-v4 to com.android.support:support-v4:22.2.0.


Put in your build.gradle the dependency of support-annotations according with your compileSdkVersion. For instance: A project with the compileSdkVersion 25 you can put the following dependence:

compile 'com.android.support:support-annotations:25.0.1'

This will solve your problem.


In my case I had a file called cache.xml under /build/intermediates/dex-cache/cache.xml in the root project folder. I deleted this file, rebuild the project and it worked for me.


I deleted the android-support-v4.jar and it worked.

Explain - android-support-v4.jar is conflicting with my other .jar files of project\libs files ** specially when you are running with java 8 on AS.


Put android-support-v4.jar in your libs folder in eclipse. Clean and build the project. It will resolve the issue.


Another reason that messages such as these can come up in Android Studio when building and launching can be the cause of application tags in your libraries.

If you have several Android Library projects that you imported as modules. Go into those projects and remove the <application> ... </application> tags and everything between them. These can cause issues in the build process along with the support library issues already mentioned.


From /platforms/android/libs/ delete android-support-v4.jar. It works for me.

참고URL : https://stackoverflow.com/questions/26342444/multiple-dex-files-define-landroid-support-annotation-animres

반응형