Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
292 views
in Technique[技术] by (71.8m points)

android - 'Could not resolve recyclerview-v7' Error, while updating gradle version and compile to implementation

I am working on Android since 2 years. I never faced issue like this. After updating Android Studio and com.android.tools.build:gradle:3.1.3, i am facing this issue.

Issue: Could not resolve RecyclerView-v7

This is a silly issue which make me stuck for 1 hour. This only happens in com.android.tools.build:gradle:3.1.3.

Project level build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply from: rootProject.file('dependencies.gradle')

buildscript {
    repositories {
        jcenter()

        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
    }
}

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
        jcenter()
        maven { url 'https://maven.google.com' }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

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

App level build.gradle

apply plugin: 'com.android.application'
android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    defaultConfig {
        applicationId "in.kpis.upkeep"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        setProperty("archivesBaseName", applicationId + "-v" + versionCode + "(" + versionName + ")")
    }
    dataBinding {
        enabled = true
    }
    buildTypes {
        debug {
            versionNameSuffix "-T"
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            versionNameSuffix "-R"
        }
    }

    useLibrary 'org.apache.http.legacy'
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    compileOptions {
        targetCompatibility rootProject.ext.targetCompatibilityVersion
        sourceCompatibility rootProject.ext.sourceCompatibilityVersion
    }
}
def SUPPORT_LIB_VER = '27.1.1'
def SDP_VERSION = '1.0.5'
def BUTTER_KNIFE_VER = '8.8.1'
dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    implementation "com.android.support:appcompat-v7:$SUPPORT_LIB_VER"
    implementation "com.android.support:design:${SUPPORT_LIB_VER}"
    implementation "com.android.support:cardview-v7:$SUPPORT_LIB_VER"
    implementation "com.android.support:recyclerview-v7:${SUPPORT_LIB_VER}"
    implementation 'com.googlecode.libphonenumber:libphonenumber:8.0.1'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.google.code.gson:gson:2.8.4'
    implementation "com.jakewharton:butterknife:${BUTTER_KNIFE_VER}"
    annotationProcessor "com.jakewharton:butterknife-compiler:${BUTTER_KNIFE_VER}"
    implementation 'com.wdullaer:materialdatetimepicker:3.6.0'
    implementation "com.intuit.sdp:sdp-android:$SDP_VERSION"
    implementation "com.intuit.ssp:ssp-android:$SDP_VERSION"
    implementation group: 'org.simpleframework', name: 'simple-xml', version: '2.7.1'
    implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
    implementation 'com.android.volley:volley:1.1.0'
    implementation 'com.github.esafirm.android-image-picker:imagepicker:1.13.0'
    implementation 'com.github.bumptech.glide:glide:4.5.0'
}

Exported versions

ext {
    compileSdkVersion = 27
    buildToolsVersion = '27.0.3'
    minSdkVersion = 15
    targetSdkVersion = 27
    sourceCompatibilityVersion = JavaVersion.VERSION_1_8
    targetCompatibilityVersion = JavaVersion.VERSION_1_8
}

I downgraded build.gradle to make this working but that's not a solution. Someone know this issue?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is because You have updated all compile to implementation in your build.gradle "App level"

To solve this - Go to your build.gradle (Project level)

and You just need to add google() on top of jcenter() inside repositories blockes.

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

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

Take this code and put inside your build.gradle "Project Level"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...