'Library'에 해당하는 글 1건

안녕하세요. IT 김군입니다.

 

오늘은 AAR 확장자로 되어있는 Library를 추가하는 방법에 대해 알아보도록 하겠습니다.

 

우선 제가 오늘 포스팅을 위해 준비한 AAR 파일은 Android Beacon Library 입니다.

 

https://altbeacon.github.io/android-beacon-library/

 

Android Beacon Library

The leading library for detecting beacons on Android. What Does This Library Do? It allows Android devices to use beacons much like iOS devices do. An app can request to get notifications when one or more beacons appear or disappear. An app can also reques

altbeacon.github.io

연습용으로 필요하시다면 위 URL에서 다운로드 받으실 수 있습니다.

 

그럼 시작해보도록 하겠습니다.

 

우선 아래 파일이 제가 오늘 준비한 Library AAR 파일입니다.

 

 

1. 이 파일을 사용할 프로젝트에 있는 Libs 폴더에 넣어줍니다.

 

 

 

2. 해당 Libs 폴더에 Drag&Drop 으로 끌어다가 넣어주시면 아래와 같은 창이 생성됩니다.

 

 

3. 네 그럼 우리가 제일 잘하는 OK 버튼 누르기를 시전하면 아래와 같이 추가됩니다.

 

 

4. 파일이 정상적으로 libs 폴더에 추가되었다면 build.gradle 파일을 실행합니다.

(여기서 build.gradle 파일은 app 폴더에 속하여 있는 build.gradle 파일입니다.)

 

 

● 아래 사진 참고

 

5. 해당 파일을 열어서 아래 내용을 추가해줍니다.

 


repositories {
	flatDir{
    	dirs 'libs'
    }
}

implementation name: 'android-beacon-library-2.16.2', ext: 'aar'

 

implementation의 경우

implementation name: '확장자를 제외한 파일명', ext: 'aar'

공식으로 적어주시면 되겠습니다!

 

근데 이걸 어디에 추가하냐고요....??

build.gradle 풀소스는 아래와 같습니다.

 

추가라고 주석 달려있는 부분에 맞추어 추가해주시면 됩니다.

 


apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.1"
    defaultConfig {
        applicationId "package Name"
        minSdkVersion 28
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

// 추가 부분 Start
repositories {
    flatDir {
        dirs 'libs'
    }
}
// 추가 부분 End

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation name: 'android-beacon-library-2.16.2', ext: 'aar' // 추가 AAR Implementation
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

 

해당 부분을 추가해주시면 아래 사진과 같이 우측 상단에 Sync Now가 나옵니다.

 

 

6. 네 망설임 없이 Sync Now 바로 눌러주면 Sync이 진행되며 정상적으로 AAR 파일을 사용할 수 있습니다.

 

아래는 제가 추가한 Beacon Library AAR 파일을 import 한 모습입니다.

 

 

AAR 추가하기 참 쉽죠?

 

글로 풀고 일일이 캡쳐해서 올리려니 이게 시간이 더 걸리네요...ㅠㅠ

 

나중에 제가 기억 못할 때를 위해 열심히 적어봤습니다.

 

혹시나 도움되셨다면 아래 공감 버튼 꼭 좀 부탁드리겠습니다.

 

그럼 다음 편에서 찾아뵙겠습니다.

 

굿밤!


WRITTEN BY
IT김군
S/W 개발자 김군의 메모장

,