I can only resolve dependencies if I use '+' in the versions of the Libraries

2

22 Dec 2017 Error that occurred while offline

AfterswitchingtoOnlineWork

ORIGINAL:I'vebeentryingtoavoiddoingitthisway:

dependencies{compilefileTree(include:['*.jar'],dir:'libs')compile'com.android.support:appcompat-v7:26.+'

Becausetheuseof'+'isdiscouraged,Gradlecannever'resolvedependencies'ifIuse

...v7:26.1.1ouv7:27.0.2(comosdevidosajustes)

oranyotherversionyoumayfindontheweb.

IputdownthecompletecodeoftheAppbuild.gradle(in1st)andthebuild.gradleoftheproject(in2nd).

Iask:a)HowdoIavoid'+'?b)WherecanIfindtheversions(26.x.x,forexample)thatexistandcanbecompiled?

applyplugin:'com.android.application'android{compileSdkVersion26//23buildToolsVersion'26.0.3'defaultConfig{applicationId"com.example.android.LearnEnglish"
        minSdkVersion 15
        targetSdkVersion 26//23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    jcenter()
    google()
    //maven { url "https://maven.google.com" } Este só se usa com Gradle abaixo de 4.1
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:26.+'
    //compile 'com.android.support:support-v4.app.ActivityCompat'//com.android.support:support-compat:+'
    //compile 'com.android.support:support-v4:23.3.0'
    //compile 'com.android.support:design:23.3.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    /*compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:23.3.0'
        compile 'com.android.support:support-v4:23.3.0'
        compile 'com.android.support:design:23.3.0'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        testCompile 'junit:junit:4.12'*/
}

(project:)

buildscript {
    repositories {
        // Gradle 4.1 and higher include support for Google's Maven repo using
        // the google() method. And you need to include this repo to download
        // Android plugin 3.0.0 or higher.
        jcenter()
        google()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        google()


    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
    
asked by anonymous 02.12.2017 / 18:50

2 answers

0

It is not recommended to use "+", can cause errors, Android Studio warns about this in dependencies.

A) How to proceed to avoid '+'?

Use all support libraries in the same version, I recommend 26.1.0 or similar (version 27.0.2 has some problems), 'compileSDKVersion': 26, 'buildToolsVersion': 26.1.0 and all dependencies of the libraries.     ex:

compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'

B) Where can I find the versions (26.x.x, for example) that exist and can be compiled?

Personally I recommend you look in the SDK Manager, you will see the required updates, installed versions, etc ...

    
10.12.2017 / 21:39
0

When using the support libraries, in those that are related to each other, you must use the same revision number.

You should preferably use the latest revision, which at this date is version 27.0.2.

In the Support Library Packages you will find the listing of all libraries and their identifier to use in gradle .

You can find lists and details of the most recent revisions at Recent Support Library Revisions .

    
02.12.2017 / 19:55