Expert wanna be
Expert wanna be

Reputation: 10624

How to resolve Could not find android.arch.lifecycle:compiler?

I'm trying to use Android lifecycle, but I'm stocking on adding lifecycle-compiler dependency.

This is the module build.gradle,

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
    compileSdkVersion 25
    buildToolsVersion "26.0.0"
    dataBinding {
        enabled = true
    }
    defaultConfig {
        applicationId "com.example.jj.mvvm"
        minSdkVersion 19
        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 {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    kapt 'com.android.databinding:compiler:2.3.3'

    implementation "android.arch.lifecycle:runtime:1.0.0"
    implementation "android.arch.lifecycle:extensions:1.0.0-beta1"
    kapt "android.arch.lifecycle:compiler:1.0.0-beta1"
}
repositories {
    mavenCentral()
}

and I got the below error,

Error:Could not find android.arch.lifecycle:compiler:1.0.0-beta1.
Searched in the following locations:
    file:/C:/Users/jj/AppData/Local/Android/android-sdk/extras/m2repository/android/arch/lifecycle/compiler/1.0.0-beta1/compiler-1.0.0-beta1.pom
    file:/C:/Users/jj/AppData/Local/Android/android-sdk/extras/m2repository/android/arch/lifecycle/compiler/1.0.0-beta1/compiler-1.0.0-beta1.jar
    file:/C:/Users/jj/AppData/Local/Android/android-sdk/extras/google/m2repository/android/arch/lifecycle/compiler/1.0.0-beta1/compiler-1.0.0-beta1.pom
    file:/C:/Users/jj/AppData/Local/Android/android-sdk/extras/google/m2repository/android/arch/lifecycle/compiler/1.0.0-beta1/compiler-1.0.0-beta1.jar
    file:/C:/Users/jj/AppData/Local/Android/android-sdk/extras/android/m2repository/android/arch/lifecycle/compiler/1.0.0-beta1/compiler-1.0.0-beta1.pom
    file:/C:/Users/jj/AppData/Local/Android/android-sdk/extras/android/m2repository/android/arch/lifecycle/compiler/1.0.0-beta1/compiler-1.0.0-beta1.jar
    file:/C:/Program Files/Android/Android Studio/gradle/m2repository/android/arch/lifecycle/compiler/1.0.0-beta1/compiler-1.0.0-beta1.pom
    file:/C:/Program Files/Android/Android Studio/gradle/m2repository/android/arch/lifecycle/compiler/1.0.0-beta1/compiler-1.0.0-beta1.jar
    https://jcenter.bintray.com/android/arch/lifecycle/compiler/1.0.0-beta1/compiler-1.0.0-beta1.pom
    https://jcenter.bintray.com/android/arch/lifecycle/compiler/1.0.0-beta1/compiler-1.0.0-beta1.jar
    https://repo1.maven.org/maven2/android/arch/lifecycle/compiler/1.0.0-beta1/compiler-1.0.0-beta1.pom
    https://repo1.maven.org/maven2/android/arch/lifecycle/compiler/1.0.0-beta1/compiler-1.0.0-beta1.jar
Required by:
    project :app

This is the project build.gradle file,

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.1.50'

    repositories {
        jcenter()
        google()
    }
    dependencies {
        // classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.android.tools.build:gradle:3.0.0-beta4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Could you please review what I'm doing wrong?

** My Android studio version is 2.3.3 and I'm using Kotlin

Upvotes: 8

Views: 14559

Answers (4)

MohammadReza
MohammadReza

Reputation: 154

in my Case (Could not find core-runtime-2.1.0.aar) Resolved after 2H Searched

allprojects {
repositories {
    google() // TOP 
    ........
    ........
    ........
}

}

Upvotes: 0

Sergei Buvaka
Sergei Buvaka

Reputation: 621

You must replace the current version of LifeCycle.

implementation "androidx.lifecycle:lifecycle-extensions:2.1.0"
implementation "androidx.lifecycle:lifecycle-common-java8:2.1.0"

Here you can see the current version of the dependencies https://developer.android.com/jetpack/androidx/releases/lifecycle

Upvotes: 2

kkost
kkost

Reputation: 3760

In my case for my Cordova project I put maven { url 'https://maven.google.com' } before jcenter():

buildscript {
    repositories {
         maven {
            url "https://maven.google.com"
        }
        jcenter()
    }

This solved my issue

Upvotes: 0

fal
fal

Reputation: 3085

Try adding maven { url 'https://maven.google.com' } to your build script repositories:

buildscript {
    ext.kotlin_version = '1.1.50'

    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
        google()
    }

As a note, you no longer need android.arch.lifecycle:compiler:1.0.0-beta1 if you're using Java 8. You can use android.arch.lifecycle:common-java8:1.0.0-beta1 instead.

Upvotes: 8

Related Questions