안드로이드 개발 팁 #18 - 오래된 프로젝트의 build.gradle 파일 수정

2016년엔가 만들어 두었던 안드로이드 샘플 프로젝트들이 여럿 있는데요. 그 중 하나를 수정하려고 했습니다. 그런데 build.gradle 파일이 오래되었기 때문에 프로젝트를 로딩하자마자 이런 저런 오류들이 발생했습니다. 이번 포스트에서는 오래된 build.gradle 파일로부터 발생한 오류는 무엇인지, 이들을 어떻게 해결하는지를 간단히 정리해 봅니다.


프로젝트의 build.gradle 파일 수정

수정한 내용은 다음과 같습니다.

  • Android Gradle Plugin Version을 7.2.1로 올림 (예전 버전: 1.5.0)
  • respositories 블록들에 google() 추가
buildscript {
    repositories {
        google()    // 추가한 코드
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.1'    // 1.5.0에서 7.2.1로 수정

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

allprojects {
    repositories {
        google()    // 추가한 코드
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

gradle-wrapper.properties 파일 수정

수정 내용은 다음과 같습니다.

  • Gradle 버전 수정: 2.8.0에서 7.3.3으로
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip 
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

app 모듈의 build.gradle 파일 수정

수정 내용은 다음과 같습니다.

dependencies 블록 안에서 작성된 단어들을 다음과 같이 변경

  • compile: implementation으로 변경
  • testCompile: testImplementation으로 변경
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:appcompat-v7:23.1.1'
}

마치며...

스팀 앱 개발기를 작성하고 있지만, 오늘처럼 본업과 관련된 안드로이드 앱 개발 이야기도 한번씩 작성하고 있습니다. 사이드 프로젝트도 좋지만, 본업이 가장 중요하니까요. 본업에서 필요한 학습들은 빨리 마치고, 개인 앱 개발도 계속 할 수 있으면 좋겠습니다. 이것으로 이번 포스트도 마칩니다.


지난 안드로이드 개발 팁

Sort:  
 2 years ago 

[광고] STEEM 개발자 커뮤니티에 참여 하시면, 다양한 혜택을 받을 수 있습니다.

Upvoted! Thank you for supporting witness @jswit.
default.jpg

Coin Marketplace

STEEM 0.15
TRX 0.15
JST 0.029
BTC 56269.96
ETH 2364.95
USDT 1.00
SBD 2.26