Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- unity
- 노션
- 깃허브 #깃명령어
- RPG게임
- JSX
- 커밋
- 마이크작동
- button onclick
- 노션가계부
- 노션으로 가계부쓰기
- 갤럭지버즈+
- 깃허브
- React
- 블루투스마이크
- flutter오류#flutter#flutter초기세팅
- animatorcontroller
- 노션꿀팁
- Relation
- props
- 노션관계형
- 깃허브 커밋
- unrelated histories
- 유니티
- 마이크작동안됨
- 1인 게임개발
- button
- 깃허브오류
- 노션활용
- notion
Archives
- Today
- Total
광산김가네
[Android/Kotlin] build.gradle 관련 정리(업데이트 예정) 본문
프로젝트를 새로 만들때 build.gradle 파일에서 생긴 오류때문에 실행이 안되는경우도 있고,
viewBinding 등의 초기설정을 해줘야하는 경우가 많아 정리를 해보려고한다
0. build.gradle은 두가지가 있다?!
build.gradle은 패키지단위로 1개, app단위로 1개가 있다.
해당 포스팅에서 주로 다룰 내용은 app단위의 build.gradle이다
*아마 패키지단위의 build.gradle은 빌드할때 주로 만지는걸로 알고있다..기억이..가물가물..
1.구조
크게
- plugins
- android
- dependencies
부분으로 나눠져있다.
보통 처음 프로젝트를 빌드할때 내가 설정하는 build.gradle 파일은 다음과같다
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
//추가
id 'kotlin-kapt'
id 'kotlin-parcelize'
}
android {
namespace 'umc.standard.week5'
compileSdk 32
defaultConfig {
applicationId "umc.standard.week5"
minSdk 23
targetSdk 32
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
}
kotlinOptions {
jvmTarget = '1.8'
}
//추가
buildFeatures{
viewBinding true
}
}
dependencies {
//추가
def version = '1.9.0'
implementation "androidx.core:core-ktx:$version"
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation "com.google.android.material:material:$version"
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
2. viewBinding 관련 설정/오류
buildFeature 항목에 viewBinding 값을 true로 설정해야 코틀린 파일에서 바인딩을 사용하여 xml파일과 연결할 수 있다.
문제상황) 가끔! viewbinding default 이름으로 선언해줘도 아래와 같이 자동완성되거나 alt+enter를 쳐서 import하라는 파란색 자동완성 말풍선이 뜨지않을때가 있다.
그럴때는 viewbinding값을 false로 바꿔주고 sync 한후, true로 바꿔서 다시 sync해주면 해결된다
*android studio 문제라고? 한다
(추후 업데이트 예정)
'TIL(Today I Learn)' 카테고리의 다른 글
[TIL]221106 Android RecyclerView 오류 (0) | 2022.11.06 |
---|---|
[TIL]221105 - Android ListView , React (0) | 2022.11.05 |
[모각코] ReactJS 프로젝트 시작하기(4)- 검색기능 | 스크랩기능 구현하기 (0) | 2022.08.26 |
[모각코] ReactJS 프로젝트 시작하기(3)- Recoil,Router에 대해서 (0) | 2022.08.22 |
[모각코] ReactJS 프로젝트 시작하기(1) - 기능,UI/UX 구체화 (0) | 2022.08.15 |