Development Tip

Android Studio 3.2.1 업그레이드 후 빌드 오류

yourdevel 2020. 10. 25. 13:11
반응형

Android Studio 3.2.1 업그레이드 후 빌드 오류


Udacity에서 샘플 프로젝트를 만들고 있습니다. 지금까지 잘 작동했지만 Android Studio 3.2.1로 업그레이드 한 후 아래 빌드 오류가 발생했습니다.

Gradle 버전 : 4.6

프로젝트 링크 : https://github.com/udacity/ud851-Sunshine/tree/student/S02.02-Solution-Menus

Could not find com.android.tools.build:aapt2:3.2.1-4818971**. Searched in the following locations:
    file:/C:/Users/sandeepk2/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971.pom
    file:/C:/Users/sandeepk2/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971-windows.jar
    file:/C:/Users/sandeepk2/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971.pom
    file:/C:/Users/sandeepk2/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971-windows.jar
    file:/C:/Users/sandeepk2/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971.pom
    file:/C:/Users/sandeepk2/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971-windows.jar
    https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971.pom
    https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971-windows.jar Required by:
    project :app

어떻게 고칠 수 있습니까?


Android Studio 3.2.1 업데이트의 경우

google()루트 수준에 추가하기 만하면 됩니다.build.gradle

buildscript {
    repositories {
        google()   //  <--here
        jcenter()
    }
 }

allprojects {
    repositories {
        google()   //  <-- here
        jcenter()
    }
}

그리고 마술을보십시오-오류가 사라졌습니다.


프로젝트 gradle버전은 꽤 오래되었습니다.

classpath 'com.android.tools.build:gradle:2.2.3'

Android Studio v3.2.1을 사용하고 있으므로 다음을 업데이트하십시오 gradle.

classpath 'com.android.tools.build:gradle:3.2.0' // or 3.2.1 maybe

또한 보시다시피 다음에서 일부 패키지를 찾고있었습니다.

file:/C:/Users/sandeepk2/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971.pom

google(), 최상위 저장소 로 추가 하는 것을 잊었을 것입니다 . 그냥 추가google()

루트의 저장소에 build.gradle.


이 문제를 해결하려면

먼저 아래 링크에서 누락 된 Jar 파일을 다운로드하십시오. 버전 3.2.1-4818971이 누락되었습니다.

https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971-windows.jar

폴더 구조를 Android에서 Project로 전환하십시오.

FolderStructure

이제 앱 내부의 libs 폴더로 이동합니다. (libs 폴더가 존재하지 않는 경우 앱 폴더를 마우스 오른쪽 버튼으로 클릭하여 생성 할 수 있습니다. 새로 만들기를 선택하고 디렉토리를 선택하십시오.)

LibsFolder

다운로드 한 .jar 파일을 libs 폴더에 붙여 넣습니다. jar 파일을 마우스 오른쪽 버튼으로 클릭하고 하단에서 라이브러리로 추가를 클릭합니다. 이것은 build.gradle에 구현 파일 ( 'libs / library_name.jar')을 추가하는 것을 처리합니다 [빌드 파일에 수동으로 입력 할 필요가 없습니다].

AddAsLibrary

Everything should be okay once you sync after doing the above. Here is the source link to this solution: https://developer.android.com/studio/command-line/aapt2#download_aapt2

Let me know if you run into any other issues whilst doing the above.


Yeah, as d4rkcon said download https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971-windows.jar But you can do simplier - just put this file in directory where Andoid Studio is trying to find it. If you don't have directories like /tools/build/aapt2/3.2.1-4818971/ in AndroidSDK folder just create them and then put aapt2-3.2.1-4818971-windows.jar file in.


Add Google repository in your build.gradle(Project:xxxxx)

allprojects {
    repositories {
        google()
    }
}

clear gradle cache

rm -rf $HOME/.gradle/caches/

and resync to download all dependencies


Change your build.gradle as follows.

android {
    compileSdkVersion 26
    buildToolsVersion "28.0.3"

    defaultConfig {
        applicationId "your package name here"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:appcompat-v7:26.1.0'
}

빌드 스크립트에 google () 추가> 저장소 모든 프로젝트에 Google 추가> 저장소

파일 트리에서도 컴파일 키워드의 대체로 구현을 사용하십시오.

전의.

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    implementation 'com.android.support:appcompat-v7:25.3.1'
    implementation 'com.android.support:design:25.3.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-v4:25.3.1'

참고 URL : https://stackoverflow.com/questions/52790020/build-errors-after-android-studio-3-2-1-upgrade

반응형