Program Tip

API 26 (Android) 용 Gradle 설정

programtip 2020. 12. 6. 21:56
반응형

API 26 (Android) 용 Gradle 설정


Nexus 5x를 Android O DP3로 업그레이드했기 때문에 애플리케이션을 테스트 할 수 없습니다. 새 API 수준 (26)에서 작동하도록 Gradle 파일을 구성하지 않은 경우 오류가 발생합니다.

그래서 이것과 종속성을 변경했지만 모든 지원 라이브러리에서 다음과 같은 오류가 계속 발생합니다.

Failed to resolve: com.android.support:design:26.0.0-beta2

클릭

Install repository and sync project

올바른 종속성을 다운로드하기위한 진행 대화 상자를 표시하지만 오류를 제거하지는 않습니다. 프로젝트 정리, 리포지토리 설치 및 프로젝트 재 구축도 작동하지 않습니다.

appcompat-v7

appcompat-v7 : 26.0.0-beta2에서 (Gradle 동기화 전에) 오류가있는 줄이 삐걱 거리는 줄이 나타납니다.

When using a compileSdkVersion older than android-O revision 2,
the support library version must be 26.0.0-alpha1 or lower (was 26.0.0-beta2)

누군가가 Android API 26에 맞게 Gradle 파일을 올바르게 구성하도록 도와 줄 수 있습니까? 어떤 도움을 주시면 감사하겠습니다.

추신 : 현재 Gradle 3.0.0-alpha3을 사용하고 있지만 Gradle 2.3.2에서 동일한 오류가 발생합니다.

내 Gradle 파일 :

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion '26.0.0'

defaultConfig {
    applicationId "********"
    minSdkVersion 21
    targetSdkVersion 26
    versionCode 3
    versionName "2.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:26.0.0-beta2'
compile 'com.android.support:design:26.0.0-beta2'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:cardview-v7:26.0.0-beta2'
compile 'com.android.support:recyclerview-v7:26.0.0-beta2'
compile 'com.redbooth:WelcomeCoordinator:1.0.1'
compile 'com.github.kittinunf.fuel:fuel-android:1.4.0'
compile 'com.pkmmte.view:circularimageview:1.1'
compile 'com.ramotion.foldingcell:folding-cell:1.1.0'
}

Google Maven 엔드 포인트 를 추가 했습니까 ?

중요 : 이제 Google의 Maven 저장소를 통해 지원 라이브러리를 사용할 수 있습니다. SDK Manager에서 지원 저장소를 다운로드 할 필요가 없습니다. 자세한 내용은 지원 라이브러리 설정을 참조하십시오 .

build.gradle 파일에 엔드 포인트를 추가 하십시오.

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

google()Android Gradle v3 이후 바로 가기로 대체 할 수 있습니다 .

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

내부에 이미 maven URL이있는 경우 다음과 repositories같이 참조를 추가 할 수 있습니다.

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

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'

Maven 소스 URL을 gradle로 설정하는 Appart는 디자인 및 appcompat 라이브러리를 모두 추가하는 것이 좋습니다. 현재 최신 버전은 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'

google()리포지토리 블록에 추가 수 있습니다.

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'

        }
        maven {
            url "https://jitpack.io"
        }
        google()
    }
}

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


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

참고URL : https://stackoverflow.com/questions/44500176/setting-up-gradle-for-api-26-android

반응형