Reputation: 597
I'm trying to add Room support in my android project. I've added all dependencies to the gradle files and it successfully build... once. Each following build results in Could not find androidx.room:room-compiler:compiler
This is my module gradle file:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
google()
}
buildscript{
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
google()
}
}
android {
//...
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') {
transitive = true
}
implementation 'com.airbnb.android:lottie:2.2.0'
implementation 'com.google.android.material:material:1.0.0-beta01'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01'
def room_version = "2.1.0-alpha03"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:compiler:$room_version"
}
And here's my project gradle file:
apply plugin: 'kotlin-android-extensions'
apply plugin: 'announce'
buildscript {
ext.kotlin_version = '1.3.10'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
maven { url "https://maven.google.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
task info {
doLast {
announce.announce "Running $it.name", 'local'
println gradle.gradleVersion
}
}
Lastly, here is full error:
Could not find androidx.room:room-compiler:compiler.
Searched in the following locations:
- file:/home/miku/Android/Sdk/extras/m2repository/androidx/room/room-compiler/compiler/room-compiler-compiler.pom
- file:/home/miku/Android/Sdk/extras/m2repository/androidx/room/room-compiler/compiler/room-compiler-compiler-2.1.0-alpha03.jar
- file:/home/miku/Android/Sdk/extras/google/m2repository/androidx/room/room-compiler/compiler/room-compiler-compiler.pom
- file:/home/miku/Android/Sdk/extras/google/m2repository/androidx/room/room-compiler/compiler/room-compiler-compiler-2.1.0-alpha03.jar
- file:/home/miku/Android/Sdk/extras/android/m2repository/androidx/room/room-compiler/compiler/room-compiler-compiler.pom
- file:/home/miku/Android/Sdk/extras/android/m2repository/androidx/room/room-compiler/compiler/room-compiler-compiler-2.1.0-alpha03.jar
- https://dl.google.com/dl/android/maven2/androidx/room/room-compiler/compiler/room-compiler-compiler.pom
- https://dl.google.com/dl/android/maven2/androidx/room/room-compiler/compiler/room-compiler-compiler-2.1.0-alpha03.jar
- https://jcenter.bintray.com/androidx/room/room-compiler/compiler/room-compiler-compiler.pom
- https://jcenter.bintray.com/androidx/room/room-compiler/compiler/room-compiler-compiler-2.1.0-alpha03.jar
- https://jitpack.io/androidx/room/room-compiler/compiler/room-compiler-compiler.pom
- https://jitpack.io/androidx/room/room-compiler/compiler/room-compiler-compiler-2.1.0-alpha03.jar
- https://maven.google.com/androidx/room/room-compiler/compiler/room-compiler-compiler.pom
- https://maven.google.com/androidx/room/room-compiler/compiler/room-compiler-compiler-2.1.0-alpha03.jar
- https://repo.maven.apache.org/maven2/androidx/room/room-compiler/compiler/room-compiler-compiler.pom
- https://repo.maven.apache.org/maven2/androidx/room/room-compiler/compiler/room-compiler-compiler-2.1.0-alpha03.jar
- https://maven.fabric.io/public/androidx/room/room-compiler/compiler/room-compiler-compiler.pom
- https://maven.fabric.io/public/androidx/room/room-compiler/compiler/room-compiler-compiler-2.1.0-alpha03.jar
- https://dl.google.com/dl/android/maven2/androidx/room/room-compiler/compiler/room-compiler-compiler.pom
- https://dl.google.com/dl/android/maven2/androidx/room/room-compiler/compiler/room-compiler-compiler-2.1.0-alpha03.jar
Required by:
project :fpcommonlib
Gradle syncs fine, so it would seam like it's finding required libraries. Building app however makes Android Studio display that error message instead of actually building the app. So it looks like Gradle and Build are using different repositories for some reason. On top of that Kotlin code does not show any errors either.
Upvotes: 2
Views: 2784
Reputation: 121
Maybe it's a bit late but for me it was enough removing .idea / and .gradle / directories inside the project folder.
Best regards!
Upvotes: 0
Reputation: 597
Ok, so after some hustle I did find a solution
I've created a new project and added all additional dependencies that have been used in original project. Then I've copied project Gradle from new project into the old one and it worked. I do not know how nor why as both Gradle files look the same.
But just to be save (I might be missing something obvious) here are both Gradle files
Working one:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
google()
}
buildscript{
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
google()
}
}
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') {
transitive = true
}
implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01'
implementation 'com.google.android.material:material:1.0.0-beta01'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation 'com.airbnb.android:lottie:2.8.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'androidx.core:core-ktx:1.0.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
def room_version = "2.1.0-alpha04"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
}
Corrupted one:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
google()
}
buildscript{
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
google()
}
}
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.2'
// implementation 'com.android.support:support-v4:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') {
transitive = true
}
implementation 'com.airbnb.android:lottie:2.8.0'
implementation 'com.google.android.material:material:1.0.0-beta01'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01'
def room_version = "2.1.0-alpha04"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:compiler:$room_version"
}
Upvotes: 1