Setting up Gradle for api 26 (Android)

后端 未结 6 885
青春惊慌失措
青春惊慌失措 2020-12-04 15:13

Since I have upgraded my Nexus 5x to Android O DP3 I am not able to test my applications. I get the error for not having configured my Gradle-file to work with the new API-l

相关标签:
6条回答
  • 2020-12-04 15:47

    Appart from setting maven source url to your gradle, I would suggest to add both design and appcompat libraries. Currently the latest version is 26.1.0

    maven {
        url "https://maven.google.com"
    }
    

    ...

    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:design:26.1.0'
    
    0 讨论(0)
  • 2020-12-04 15:56

    Have you added the google maven endpoint?

    Important: The support libraries are now available through Google's Maven repository. You do not need to download the support repository from the SDK Manager. For more information, see Support Library Setup.

    Add the endpoint to your build.gradle file:

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

    Which can be replaced by the shortcut google() since Android Gradle v3:

    allprojects {
        repositories {
            jcenter()
            google()
        }
    }
    

    If you already have any maven url inside repositories, you can add the reference after them, i.e.:

    allprojects {
        repositories {
            jcenter()
            maven {
                url 'https://jitpack.io'
            }
            maven {
                url 'https://maven.google.com'
            }
        }
    }
    
    0 讨论(0)
  • 2020-12-04 16:01

    Appears to be resolved by Android Studio 3.0 Canary 4 and Gradle 3.0.0-alpha4.

    0 讨论(0)
  • 2020-12-04 16:02

    you must add in your MODULE-LEVEL build.gradle file with:

    //module-level build.gradle file
    repositories {
        maven {
            url 'https://maven.google.com'
    
        }
    }
    

    see: Google's Maven repository

    I have observed that when I use Android Studio 2.3.3 I MUST add repositories{maven{url 'https://maven.google.com'}} in MODULE-LEVEL build.gradle. In the case of Android Studio 3.0.0 there is no need for the addition in module-level build.gradle. It is enough the addition in project-level build.gradle which has been referred to in the other posts here, namely:

    //project-level build.gradle file
    allprojects {
     repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
      }
    }
    

    UPDATE 11-14-2017: The solution, that I present, was valid when I did the post. Since then, there have been various updates (even with respect to the site I refer to), and I do not know if now is valid. For one month I did my work depending on the solution above, until I upgraded to Android Studio 3.0.0

    0 讨论(0)
  • 2020-12-04 16:05

    You could add google() to repositories block

    allprojects {
        repositories {
            jcenter()
            maven {
                url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'
    
            }
            maven {
                url "https://jitpack.io"
            }
            google()
        }
    }
    
    0 讨论(0)
  • 2020-12-04 16:06
    allprojects {
        repositories {
            jcenter()
            maven {
                url "https://maven.google.com"
            }
        }
    }
    
    android {
        compileSdkVersion 26
        buildToolsVersion "26.0.1"
        defaultConfig {
            applicationId "com.keshav.retroft2arrayinsidearrayexamplekeshav"
            minSdkVersion 15
            targetSdkVersion 26
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
     compile 'com.android.support:appcompat-v7:26.0.1'
        compile 'com.android.support:recyclerview-v7:26.0.1'
        compile 'com.android.support:cardview-v7:26.0.1'
    
    0 讨论(0)
提交回复
热议问题