when add Room Persistence Library into my project,then i got a problem,it bothers me for a long time.
```
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.1.1, 24.0.0. Examples include com.android.support:support-compat:26.0.0 and com.android.support:animated-vector-drawable:25.3.1
````
And,my support library version is 25.3.1.What is the reason for this problem?Thank you for your help.
Make sure you clean and sync your project.
Room doesn't have anything to do, for now, with the support libraries.
@florina-muntenescu I ran into the same issue, and running a gradle dependency check, it does look like the Room runtime library relies on the support library and is referencing version 26.0.0 of support-annotations and support-core-utils and this causes a conflict if my app still uses version 25.3.1 of the support libraries (I get build errors that go away as soon as I remove the Room runtime dependency from my libraries).
| +--- android.arch.persistence.room:runtime:1.0.0-alpha9
| | +--- android.arch.persistence.room:common:1.0.0-alpha9
| | | \--- com.android.support:support-annotations:26.0.0
| | +--- android.arch.persistence.room:support-db:1.0.0-alpha9
| | | \--- com.android.support:support-annotations:26.0.0
| | +--- android.arch.persistence.room:support-db-impl:1.0.0-alpha9
| | | +--- com.android.support:support-annotations:26.0.0
| | | \--- android.arch.persistence.room:support-db:1.0.0-alpha9 (*)
| | +--- android.arch.core:runtime:1.0.0-alpha9
| | | +--- com.android.support:support-annotations:26.0.0
| | | \--- android.arch.core:common:1.0.0-alpha9
| | | \--- com.android.support:support-annotations:26.0.0
| | \--- com.android.support:support-core-utils:26.0.0 (*)
cc @yigit since there was a ticket for this on the issue tracker as well. I've posted some more details there: https://issuetracker.google.com/issues/65322413#comment4
As I mentioned there, the easiest way to reproduce this is to create a new project in Android Studio targeting API 25, and then add the alpha9 version of Room. When building an APK, the build will break due to the support library conflict.
@nirajsanghvi thanks,you described the detail error,and now i have to remove the Room library.
@florina-muntenescu I had modified api to 26,and modified support library version to 26.1.0,then the error will not produce.But if i downgrade api to 25,the error will reproduce.
I was able to make the error go away excluding support dependencies from rom library
implementation("android.arch.persistence.room:runtime:$versions.arch") {
exclude group: 'com.android.support'
}
annotationProcessor("android.arch.persistence.room:compiler:$versions.arch") {
exclude group: 'com.android.support'
}
I have:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:25.4.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'
// implementation 'com.android.support:cardview-v7:25.4.0'
// Room (use 1.1.0-alpha2 for latest alpha)
// for ROOM (SQL database)
implementation ("android.arch.persistence.room:runtime:1.0.0") {
exclude group: "com.android.support", module: "support-annotations"
}
kapt ("android.arch.persistence.room:compiler:1.0.0") {
exclude group: "com.android.support", module: "support-annotations"
}
}
But I have an error:
Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 10 cannot be smaller than version 14 declared in library [android.arch.persistence.room:runtime:1.0.0] C:\Users\Vany.gradle\caches\transforms-1\files-1.1\runtime-1.0.0.aar\962e01d9ce394c0ff499af867e8197af\AndroidManifest.xml as the library might be using APIs not available in 10
Suggestion: use a compatible library with a minSdk of at most 10,
or increase this project's minSdk version to at least 14,
or use tools:overrideLibrary="android.arch.persistence.room" to force usage (may lead to runtime failures)
I opened _AndroidManifest.xml_ at:
C:\Users\Vany.gradle\caches\transforms-1\files-1.1\runtime-1.0.0.aar\962e01d9ce394c0ff499af867e8197af
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2016 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.arch.persistence.room" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="26" />
</manifest>
_android:minSdkVersion="14"_ in _"android.arch.persistence.room:runtime:1.0.0"_ so it cannot be used with SDK < 14
LOL, I fixed it!
for minSDK = 10
Add it into you app's _AndroidManifest.xml_
<uses-sdk tools:overrideLibrary="android.arch.persistence.room, android.arch.persistence.db.framework, android.arch.persistence.db, android.arch.core" />
then Alt+Enter on word "tools" in _"tools:overrideLibrary"_ to import _xmlns:tools="http://schemas.android.com/tools"_
So manifest's top will looks like
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" <!--
package="My.App">
<!-- OverrideLibrary FOR ROOM -->
<uses-sdk tools:overrideLibrary="android.arch.persistence.room, android.arch.persistence.db.framework, android.arch.persistence.db, android.arch.core" />
Then go to _build.gradle(Module: app)_ and add that to your _dependencies_
/**
* START OF
* ROOM
*/
// Room (use 1.1.0-alpha2 for latest alpha)
// for ROOM (SQL database)
// ΡΠ±ΠΈΡΠ°Π΅ΠΌ ΡΡΠΈ Π·Π°Π²ΠΈΡΠΈΠΌΠΎΡΡΠΈ ΠΈΠ· Π·Π°Π²ΠΈΡΠΈΠΌΠΎΡΡΠ΅ΠΉ
def deleteSomeDependencies = {
exclude group: "com.android.support", module: "support-annotations"
exclude group: "com.android.support", module: "support-core-utils"
exclude group: "com.android.support", module: "support-compat"
}
implementation "android.arch.persistence.room:runtime:1.0.0", deleteSomeDependencies
kapt "android.arch.persistence.room:compiler:1.0.0", deleteSomeDependencies
/**
* END OF
* ROOM
*/
So your _build.gradle(app)_ will look like
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
// for ROOM (SQL database)
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 25
defaultConfig {
applicationId "My.App"
minSdkVersion 10
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:25.4.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'
// implementation 'com.android.support:cardview-v7:25.4.0'
/**
* START OF
* ROOM
*/
// Room (use 1.1.0-alpha2 for latest alpha)
// for ROOM (SQL database)
// ΡΠ±ΠΈΡΠ°Π΅ΠΌ ΡΡΠΈ Π·Π°Π²ΠΈΡΠΈΠΌΠΎΡΡΠΈ ΠΈΠ· Π·Π°Π²ΠΈΡΠΈΠΌΠΎΡΡΠ΅ΠΉ
def deleteSomeDependencies = {
exclude group: "com.android.support", module: "support-annotations"
exclude group: "com.android.support", module: "support-core-utils"
exclude group: "com.android.support", module: "support-compat"
}
implementation "android.arch.persistence.room:runtime:1.0.0", deleteSomeDependencies
kapt "android.arch.persistence.room:compiler:1.0.0", deleteSomeDependencies
/**
* END OF
* ROOM
*/
}
It just lets Gradle Sync to work, _but it can crash your app_.
Most helpful comment
I was able to make the error go away excluding support dependencies from rom library