All the libraries must use the same versions

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 06:14:32

问题


My depencies

dependencies {
compile 'me.dm7.barcodescanner:zxing:1.9'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'

implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

compile 'com.theartofdev.edmodo:android-image-cropper:2.7.+'

}

I get an error in appcompat line when compiling that found version 27.1.1,26.1.0 examples include ..vectordrawable 27.1.1 nd supportdesign 26.1.0

My target SDK is 26.

I tried to switch versions to 27 but my SDK target is 26, I get an error.


回答1:


Whenever you see this type of problem, explicitly declare the probelmatic libraries in your gradle file with the same version of your other support libs:

implementation "com.android.support:animated-vector-drawable:26.1.0"
implementation "com.android.support:design:26.1.0"
implementation 'com.android.support:support-vector-drawable:26.1.0'

This happens because some of your dependencies use a different version of it.

Also, use implementation not compile. Compile has been deprecated:

implementation 'me.dm7.barcodescanner:zxing:1.9'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'



回答2:


There are conflicted dependencies in your project. You need to check up the dependencies tree of your project by running the following command in your Linux terminal:

./gradlew app:dependencies

or if you're using Windows:

 gradlew app:dependencies

in your root project. Where app is your module name.

Quick checking your dependencies block, you will find the following library:

compile 'com.theartofdev.edmodo:android-image-cropper:2.7.+'

is using support library version 27.1.1 for its dependencies (You can check its build.gradle).

You can exclude the library from image cropper with:

implementation ('com.theartofdev.edmodo:android-image-cropper:2.7.0') {    
    exclude group: 'com.android.support'
    exclude module: 'appcompat-v7'
}

The side effect of using the old version of support library is you can't be so sure that your program will work correctly. It's because the owner of library probably didn't test the library with older version of support library.

The better way is by changing your BuildToolsVersion, compileSdkVersion, targetSdkVersion, and support libraries to version 27. Something like the following:

android {
  compileSdkVersion 27
  buildToolsVersion '27.0.3'

  defaultConfig {
    applicationId "com.package.name"
    minSdkVersion 15
    targetSdkVersion 27

    ...
  }

  ...
}

dependencies {
  implementation fileTree(dir: 'libs', include: ['*.jar'])

  implementation 'com.android.support:appcompat-v7:27.1.1'
  implementation 'com.android.support:design:27.1.1'

  // your other dependencies
  ...
}


来源:https://stackoverflow.com/questions/50183287/all-the-libraries-must-use-the-same-versions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!