IT BLOG

build dependencies 추가

dependencies 종류

plugins {
    id("com.android.application")
}

android { ... }

dependencies {
    // Dependency on a local library module
    implementation(project(":mylibrary"))

    // Dependency on local binaries
    implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))

    // Dependency on a remote binary
    implementation("com.example.android:app-magic:12.3")
}

dependency는 3가지 종류가 있다.

1. 로컬 라이브러리 모듈 dependency

implementation project(':mylibrary')

네이티브 템플릿 애드몹 쓸 때 이런식으로 추가하는데 새로운 모듈을 추가 할 때 요런식으로 추가를 한다.

2. 로컬 바이너리 dependency

implementation fileTree(dir: 'libs', include: ['*.jar'])

요거는 파일 경로를 읽는다.

module_name/libs/ 디렉터리 안에 jar 파일을 읽는다.

implementation files('libs/foo.jar', 'libs/bar.jar')

요렇게 따로 따로 추가도 가능하다.

3. 원격 바이너리 dependency

implementation 'com.example.android:app-magic:12.3'

이거는 흔하게 보는거니까 설명은 생략

원격 저장소

참고로 원격 바이너리 dependency 같은 경우 원래는

build.gradle 안에

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        mavenLocal()
    }
}

이런식으로 추가를 해서 가져왔었는데 바꼈다.

지금은 allprojects를 쓰지 않고

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}

이런식으로 settings.gradle 안에 dependencyResolutionManagement 에 추가를 해준다.


게시됨

카테고리

작성자

태그: