컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Android Gradle 플러그인 2.2.0(2016년 9월)
- 종속 항목:
|
최소 버전 |
기본 버전 |
참고 |
Gradle |
2.14.1 |
2.14.1 |
자세한 내용은 Gradle 업데이트하기를 참고하세요. |
SDK 빌드 도구 |
23.0.2 |
23.0.2 |
SDK 빌드 도구를 설치 또는 구성합니다. |
- New:
-
- 성능 개선 및 새로운 기능을 포함하는 Gradle 2.14.1을 사용하고 Gradle 데몬을 사용할 때 로컬 권한 에스컬레이션을 허용하는 보안 취약점을 해결합니다. 자세한 내용은 Gradle 출시 노트를 참고하세요.
externalNativeBuild {}
DSL을 사용하여 이제 Gradle로 네이티브 소스에 연결하고 CMake나 ndk-build를 사용하여 네이티브 라이브러리를 컴파일할 수 있습니다. 네이티브 라이브러리를 빌드한 후에 APK로 패키징합니다. Gradle로 CMake 및 ndk-build를 사용하는 방법에 관한 자세한 내용은 프로젝트에 C 및 C++ 코드 추가를 읽어보세요.
- 명령줄에서 빌드를 실행하면 이제 Gradle이 누락된 SDK 구성요소나 프로젝트가 종속하는 업데이트를 자동 다운로드하려고 시도합니다.
자세한 내용은 Gradle로 누락된 패키지 자동 다운로드를 읽어보세요.
- 새로운 실험용 캐싱 기능으로 Gradle이 사전 덱싱된 라이브러리 버전을 사전 덱싱, 저장, 재사용하여 빌드 시간을 단축할 수 있습니다. 이 실험용 기능 사용에 관한 자세한 내용은 빌드 캐시 가이드를 읽어보세요.
- 작업 한 번으로 압축과 서명, zipaligning을 처리하는 새로운 기본 패키징 파이프라인을 채택해 빌드 성능을 개선합니다.
gradle.properties
파일에 android.useOldPackaging=true
를 추가하여 이전 패키징 도구를 사용하도록 되돌릴 수 있습니다. 새로운 패키징 도구를 사용하는 동안 zipalignDebug
작업은 사용할 수 없습니다. 그러나 createZipAlignTask(String taskName, File inputFile, File
outputFile)
메서드를 호출하여 직접 그 작업을 생성할 수 있습니다.
- 이제 APK 서명이 기본 JAR 서명 외에도 APK 서명 체계 v2를 사용합니다. 모든 Android 플랫폼이 그 결과로 발생하는 APK를 허용합니다. 서명 후 이러한 APK를 수정하면 v2 서명이 무효화되고 기기에 설치되지도 않습니다. 이 기능을 사용 중지하려면 모듈 수준
build.gradle
파일에 다음을 추가하세요.
Groovy
android {
...
signingConfigs {
config {
...
v2SigningEnabled false
}
}
}
Kotlin
android {
...
signingConfigs {
create("config") {
...
v2SigningEnabled = false
}
}
}
- 멀티덱스 빌드의 경우 이제 ProGuard 규칙을 사용하여 Gradle이 앱의 기본 DEX 파일로 컴파일해야 하는 클래스를 결정할 수 있습니다. 앱을 시작할 때 Android 시스템이 기본 DEX 파일을 먼저 로드하기 때문에 시작 시 특정 클래스를 기본 DEX 파일로 컴파일하여 우선순위를 정할 수 있습니다. 기본 DEX 파일용으로 특별히 ProGuard 구성 파일을 생성한 후
buildTypes.multiDexKeepProguard
를 사용하여 구성 파일의 경로를 Gradle로 전달합니다. 이 DSL을 사용하는 것은 buildTypes.proguardFiles
를 사용하는 것과 다르며 앱의 일반적인 ProGuard 규칙을 제공하지만 기본 DEX 파일의 클래스를 지정하지는 않습니다.
android:extractNativeLibs
플래그 지원을 추가하여 기기에 앱을 설치할 때 앱의 크기를 줄일 수 있습니다. 앱 매니페스트의 <application>
요소에서 이 플래그를 false
로 설정하면 Gradle이 APK로 압축되지 않고 정렬된 버전의 네이티브 라이브러리를 패키징합니다. 이로써 설치하는 동안 PackageManager
가 네이티브 라이브러리를 APK에서 기기의 파일 시스템으로 복사할 수 없고 앱의 델타 업데이트 용량이 적어지는 추가 혜택이 있습니다.
- 이제 제품 버전에
versionNameSuffix
와 applicationIdSuffix
를 지정할 수 있습니다. (문제 59614)
-
변경사항:
-
-
이제
getDefaultProguardFile
이 Gradle용 Android 플러그인이 제공하는 기본 ProGuard 파일을 반환하고 더 이상 Android SDK의 파일을 사용하지 않습니다.
- Jack 컴파일러 성능 및 기능을 개선합니다.
testCoverageEnabled
를 true
로 설정할 때 이제 Jack이 Jacoco 테스트 대상 범위를 지원합니다.
- 주석 프로세서 지원을 개선합니다. 클래스 경로의 주석 프로세서(예:
compile
종속성)가 빌드에 자동으로 적용됩니다. 모듈 수준 build.gradle
파일에서 javaCompileOptions.annotationProcessorOptions {}
DSL을 사용하여 빌드에 주석 프로세서를 지정하고 인수를 전달할 수도 있습니다.
Groovy
android {
...
defaultConfig {
...
javaCompileOptions {
annotationProcessorOptions {
className 'com.example.MyProcessor'
// Arguments are optional.
arguments = [ foo : 'bar' ]
}
}
}
}
Kotlin
android {
...
defaultConfig {
...
javaCompileOptions {
annotationProcessorOptions {
className = "com.example.MyProcessor"
// Arguments are optional.
arguments(mapOf(foo to "bar"))
}
}
}
}
컴파일 시 주석 프로세서를 적용하고 APK에는 이를 포함하지 않으려면 annotationProcessor
종속 항목 범위를 사용하세요.
Groovy
dependencies {
compile 'com.google.dagger:dagger:2.0'
annotationProcessor 'com.google.dagger:dagger-compiler:2.0'
// or use buildVariantAnnotationProcessor to target a specific build variant
}
Kotlin
dependencies {
implementation("com.google.dagger:dagger:2.0")
annotationProcessor("com.google.dagger:dagger-compiler:2.0")
// or use buildVariantAnnotationProcessor to target a specific build variant
}
설정할 수 있는 매개변수 목록을 보려면 명령줄에서 다음을 실행하세요.
java -jar /build-tools/jack.jar --help-properties
- 기본적으로 Gradle 데몬의 힙 크기가 1.5GB 이상이면 이제 Jack이 Gradle과 같은 프로세스에서 실행됩니다. 데몬 힙 크기를 조정하려면 다음을
gradle.properties
파일에 추가하세요.
# This sets the daemon heap size to 1.5GB.
org.gradle.jvmargs=-Xmx1536M
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-08-30(UTC)
[null,null,["최종 업데이트: 2025-08-30(UTC)"],[],[],null,["\u003cbr /\u003e\n\nAndroid Gradle Plugin 2.2.0 (September 2016)\n\nDependencies:\nNew:\n:\n - Uses Gradle 2.14.1, which includes performance improvements and new features, and fixes a security vulnerability that allows local privilege escalation when using the Gradle daemon. For more details, see the [Gradle release notes](https://docs.gradle.org/2.14.1/release-notes).\n - Using the [`externalNativeBuild {}`](https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.ExternalNativeBuild.html) DSL, Gradle now lets you link to your native sources and compile native libraries using CMake or ndk-build. After building your native libraries, Gradle packages them into your APK. To learn more about using CMake and ndk-build with Gradle, read [Add C and C++ Code to Your\n Project](/studio/projects/add-native-code).\n - When you [run a\n build from the command line](/studio/build/building-cmdline), Gradle now attempts to auto-download any missing SDK components or updates that your project depends on. To learn more, read [Auto-download\n missing packages with Gradle](/studio/intro/update#download-with-gradle).\n - A new experimental caching feature lets Gradle speed up build times by pre-dexing, storing, and reusing the pre-dexed versions of your libraries. To learn more about using this experimental feature, read the [Build\n Cache](/studio/build/build-cache) guide.\n - Improves build performance by adopting a new default packaging pipeline which handles zipping, signing, and [zipaligning](/studio/command-line/zipalign) in one task. You can revert to using the older packaging tools by adding `android.useOldPackaging=true` to your `gradle.properties` file. While using the new packaging tool, the `zipalignDebug` task is not available. However, you can create one yourself by calling the `createZipAlignTask(String taskName, File inputFile, File\n outputFile)` method.\n - APK signing now uses [APK Signature Scheme\n v2](/about/versions/nougat/android-7.0#apk_signature_v2) in addition to traditional JAR signing. All Android platforms accept the resulting APKs. Any modification to these APKs after signing invalidates their v2 signatures and prevents installation on a device. To disable this feature, add the following to your module-level `build.gradle` file: \n\n Groovy \n\n ```groovy\n android {\n ...\n signingConfigs {\n config {\n ...\n v2SigningEnabled false\n }\n }\n }\n \n ```\n\n Kotlin \n\n ```kotlin\n android {\n ...\n signingConfigs {\n create(\"config\") {\n ...\n v2SigningEnabled = false\n }\n }\n }\n \n ```\n - For multidex builds, you can now use ProGuard rules to determine which classes Gradle should compile into your app's *main* DEX file. Because the Android system loads the main DEX file first when starting your app, you can prioritize certain classes at startup by compiling them into the main DEX file. After you create a ProGuard configuration file specifically for your main DEX file, pass the configuration file's path to Gradle using [buildTypes.multiDexKeepProguard](https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.BuildType.html#com.android.build.gradle.internal.dsl.BuildType:multiDexKeepProguard). Using this DSL is different from using [`buildTypes.proguardFiles`](https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.BuildType.html#com.android.build.gradle.internal.dsl.BuildType:proguardFiles(java.lang.Object[])), which provides general ProGuard rules for your app and does not specify classes for the main DEX file.\n - Adds support for the `android:extractNativeLibs` flag, which can reduce the size of your app when you install it on a device. When you set this flag to `false` in the [`\u003capplication\u003e`](/guide/topics/manifest/application-element) element of your app manifest, Gradle packages uncompressed and aligned versions of your native libraries with your APK. This prevents [`PackageManager`](/reference/android/content/pm/PackageManager) from copying out your native libraries from the APK to the device's file system during installation and has the added benefit of making delta updates of your app smaller.\n - You can now specify [`versionNameSuffix`](https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.ProductFlavor.html#com.android.build.gradle.internal.dsl.ProductFlavor:versionNameSuffix) and [`applicationIdSuffix`](https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.ProductFlavor.html#com.android.build.gradle.internal.dsl.ProductFlavor:applicationIdSuffix) for product flavors. ([Issue 59614](http://b.android.com/59614))\n\n\nChanges:\n:\n - `getDefaultProguardFile` now returns the default ProGuard files that Android plugin for Gradle provides and no longer uses the ones in the Android SDK.\n - Improved Jack compiler performance and features:\n - Jack now supports Jacoco test coverage when setting [testCoverageEnabled](https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.BuildType.html#com.android.build.gradle.internal.dsl.BuildType:testCoverageEnabled) to `true`.\n - Improved support for annotation processors. Annotation processors on your classpath, such as any `compile` dependencies, are automatically applied to your build. You can also specify an annotation processor in your build and pass arguments by using the [`javaCompileOptions.annotationProcessorOptions {}`](https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.AnnotationProcessorOptions.html) DSL in your module-level `build.gradle` file: \n\n Groovy \n\n ```groovy\n android {\n ...\n defaultConfig {\n ...\n javaCompileOptions {\n annotationProcessorOptions {\n className 'com.example.MyProcessor'\n // Arguments are optional.\n arguments = [ foo : 'bar' ]\n }\n }\n }\n }\n \n ```\n\n Kotlin \n\n ```kotlin\n android {\n ...\n defaultConfig {\n ...\n javaCompileOptions {\n annotationProcessorOptions {\n className = \"com.example.MyProcessor\"\n // Arguments are optional.\n arguments(mapOf(foo to \"bar\"))\n }\n }\n }\n }\n \n ```\n\n\n If you want to apply an annotation processor at compile\n time but not include it in your APK, use the\n `annotationProcessor` dependency scope: \n\n Groovy \n\n ```groovy\n dependencies {\n compile 'com.google.dagger:dagger:2.0'\n annotationProcessor 'com.google.dagger:dagger-compiler:2.0'\n // or use buildVariantAnnotationProcessor to target a specific build variant\n }\n \n ```\n\n Kotlin \n\n ```kotlin\n dependencies {\n implementation(\"com.google.dagger:dagger:2.0\")\n annotationProcessor(\"com.google.dagger:dagger-compiler:2.0\")\n // or use buildVariantAnnotationProcessor to target a specific build variant\n }\n \n ```\n - For a list of parameters you can set, run the following from the command line: \n\n ```\n java -jar /build-tools/jack.jar --help-properties\n ```\n - By default, if the Gradle daemon's heap size is at least 1.5 GB, Jack now runs in the same process as Gradle. To adjust the daemon heap size, add the following to your `gradle.properties` file:\n\n \u003cbr /\u003e\n\n ```\n # This sets the daemon heap size to 1.5GB.\n org.gradle.jvmargs=-Xmx1536M\n ```\n\n \u003cbr /\u003e\n\n\n\u003cbr /\u003e"]]