Closed tonycheng93 closed 7 years ago
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" />
**_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.
when add Room Persistence Library into my project,then i got a problem,it bothers me for a long time.
And,my support library version is 25.3.1.What is the reason for this problem?Thank you for your help.