I can only solve dependencies by using'+' in Library versions

Asked

Viewed 162 times

2

22 Dec 2017 Error that occurred when with Offlinework Erro que deu quando estava com o OfflineWork

After switching to Online Work Após mudar para Online Work

ORIGINAL: I’ve been trying to avoid doing it that way:

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

because the use of '+' is discouraged, but Gradle can never "solve dependencies" if I use

...v7:26.1.1 ou v7:27.0.2(com os devidos ajustes)

or any other version you can find on the web.

I put down the full code of the build.Radle of the App (in 1º) and the build.Radle of the project (in 2º).

I ask you: to) How to proceed to avoid the '+'? b) Where can I find the versions (26.x.x, for example) that exist and can be compiled?

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26//23
    buildToolsVersion '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
}

2 answers

0

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

To) How to proceed to avoid the '+'?

Use all support libraries in the same version, I recommend 26.1.0 or similar (version 27.0.2 ta with some problems), 'compileSDKVersion': 26, 'buildToolsVersion':26.1.0 and all support library dependencies. 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 to look in SDK Manager, you will see the necessary updates, installed versions, etc...

  • It seems that the base error comes from something related to the certificates. I updated the original post with bug photos.

  • Try version 26.1.0, I’m also having some problems with version 27.0.2, I managed to use version 27.0.0 at most.

  • Fixing: I was able to use version 27.0.1 at most (make sure in SDK Manager that the version used is installed)

0

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

Preferably you should use the last revision, which on this date is version 27.0.2.

In Support Library Packages you find the list of all libraries and their identifier to be used in Gradle.

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

  • Right, so I went back to using 27.0.2 in all occurrences and got several errors, even running the App online and after changing the 'compileSDKVersion' to 27 (I kept Build tools at 26.0.3): 'Could not resolve with.android.support:appcompat-v7:27.0.2' and the same error for the other Biblio. The error also stated: 'Could not get Resource https://jcenter... etc'.

  • I don’t know what else to say, maybe there are causes other than the versions.

  • 'Could not resolve with.android.support:appcompat-v7:27.0.2', Sign in to SDK Manager and update required items

Browser other questions tagged

You are not signed in. Login or sign up in order to post.