앱 없는 라이브러리 프로젝트 만들기

Jonghwan Choi·2023년 2월 2일
0

Android

목록 보기
5/9

1. 프로젝트 생성

Android Studio에서 상단 메뉴의 File > New > New Project 로 들어가 No Activity 선택하여 프로젝트 생성

2. gradle 문서 편집

좌측 탭의 뷰를 Android 에서 Project 로 변경

app 모듈의 build.gradle 문서를 열고 아래처럼 복사하여 프로젝트의 build.gradle 문서에 붙여넣기

프로젝트의 build.gradle 문서를 아래처럼 편집


이걸 빼먹으면 Task 'assembleDebug' not found in project 컴파일 에러가 난다.

완성된 프로젝트의 build.gradle

plugins {
    id 'com.android.library' version '7.3.1'
    id 'org.jetbrains.kotlin.android' version '1.7.20'
}

android {
    namespace 'com.gamepubjonghwan.mylibrary'
    compileSdk 32

    defaultConfig {
        minSdk 21
        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'
        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.6.0'
    implementation 'com.google.android.material:material:1.8.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

3. 디렉토리 수정

app폴더의 libs, src, proguard-rules.pro 잘라내기해서 프로젝트 폴더로 옮기기

상단 메뉴의 File > Project Structure 에서 app모듈 삭제

이후 좌측 탭에서 app폴더 삭제

완성된 프로젝트 폴더 구조

참고 링크

profile
유니티 게임 클라이언트 개발자를 꿈꾸는 뉴비

0개의 댓글