App 을 새로 생성해서 테스트 하려고 하니 오류가 나옵니다.
Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.
Gradle 을 살펴보고
android { compileSdkVersion 31 buildToolsVersion "31.0.0" defaultConfig { applicationId "copycoding.tistory.sample" minSdkVersion 16 targetSdkVersion 31 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" }
설치된 SDK Tool 도 살펴봐도
별 문제 없는것 같은데..
1. 버전 낮추기
다시 설치하긴 귀찮고 전체적으로 버전을 30 으로 낮추어 봅니다.
android { compileSdkVersion 30 buildToolsVersion " 30.0.3 " defaultConfig { applicationId "copycoding.tistory.sample" minSdkVersion 16 targetSdkVersion 30 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" }dependencies { implementation 'androidx.appcompat:appcompat: 1.3.1' implementation 'com.google.android.material:material:1.5.0'
이런. 새로운 오류가 발생 합니다.
ERROR:C:\Users\will\.gradle\caches\transforms-2\files-2.1\4eb2fc21ccc2dce4da190845bc3482ac\material-1.5.0\res\values-v31\values-v31.xml:3:5-94: AAPT: error: resource android:color/system_neutral1_1000 not found.
Material Component Library 버전이 업데이트 되어서 31 을 사용해야 한다고 합니다.
답을 찾았네요. material 버전을 낮추면 되는거군요.
android { compileSdkVersion 30 buildToolsVersion "30.0.3" defaultConfig { applicationId "copycoding.tistory.sample" minSdkVersion 16 targetSdkVersion 30 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile( 'proguard-android-optimize.txt' ), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion. VERSION_1_8 targetCompatibility JavaVersion. VERSION_1_8 } } dependencies { implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'com.google.android.material:material:1.2.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.3' testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' }
material 버전을 1.5.0 에서 1.2.0 으로 변경 하나 잘 됩니다. 물론 1.4.0 로 낮추어도 됩니다.
2. buildToolsVersion 낮추기
다른건 그대로 두고 buildToolsVersion 만 낮추어서 해결해 봅니다.
Android Studio 에서 Gradle 을 열고 오른쪽 상단을 보면 Open (Ctrl+Alt+Shift+S) 가 있는데
이걸 누르면 창이 하나 뜨고
여기서 Build Tools Version 을 확장하여 31.0.0 대신 하나 낮은걸 선택 합니다.
android { compileSdkVersion 31 buildToolsVersion '30.0.3' defaultConfig { applicationId "copycoding.tistory.test" minSdkVersion 16 targetSdkVersion 31 versionCode 1 versionName "1.0"
그리고 실행하면 다른 오류가 발생 합니다.
android:exported 이게 문제라는 군요. 참조하라는 링크를 따라가보면 설명이 있습니다.
https://developer.android.com/guide/topics/manifest/activity-element#exported
어째든 android:exported 를 Manifest 에 추가하고 값을 넣으면 됩니다. 만일 false 를 넣으면 앱이 생성은 되는데 실행하려고 하면 app is’nt installed 라는 토스트만 나오니 true 를 적어 줍니다.
값을 설정하는 위치는 activity 에 해주어야 합니다.
< activity android :name =".MainActivity" android:exported="true" > <intent-filter > < action android :name ="android.intent.action.MAIN" /> < category android :name ="android.intent.category.LAUNCHER" /> </ intent-filter > </ activity >
이렇게 하면 앱을 잘 테스트할 수 있습니다.
이건 제가 간단한 테스트를 하려고 한것이고 실제로는 높은 버전으로 컴파일 해야 최신 핸드폰에서도 잘 돌아가는 앱을 만들 수 있겠죠.
- copy coding -