Skip to content

Commit fd315e7

Browse files
cortinicoyayvery
authored andcommitted
AGP to 8.2.1 (facebook#37019)
Summary: Pull Request resolved: facebook#37019 This bumps the version of AGP to the latest stable. There was a breaking change in how buildConfig are built which I had to handle. This also requires a bump of RNGP to work correctly. Moreover, we now required Java 17 to build Android apps (as that's a AGP requirement). Changelog: [Android] [Changed] - Java to 17 and AGP to 8.0.2 Reviewed By: cipolleschi Differential Revision: D45178748 fbshipit-source-id: 0f302e1f2f2ee56bd3566202fbb5ef67c9b220db
1 parent 065acc8 commit fd315e7

File tree

13 files changed

+97
-128
lines changed

13 files changed

+97
-128
lines changed

.circleci/Dockerfiles/Dockerfile.android

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,19 @@
1414
# and build a Android application that can be used to run the
1515
# tests specified in the scripts/ directory.
1616
#
17-
FROM reactnativecommunity/react-native-android:7.0
17+
FROM reactnativecommunity/react-native-android:9.0
1818

1919
LABEL Description="React Native Android Test Image"
20-
LABEL maintainer="Héctor Ramos <hector@fb.com>"
20+
LABEL maintainer="Meta Open Source <opensource@meta.com>"
2121

2222
# set default environment variables
2323
ENV GRADLE_OPTS="-Dorg.gradle.daemon=false -Dfile.encoding=utf-8 -Dorg.gradle.jvmargs=\"-Xmx512m -XX:+HeapDumpOnOutOfMemoryError\""
2424
ENV KOTLIN_HOME="packages/react-native/third-party/kotlin"
2525

26-
ADD .buckconfig /app/.buckconfig
27-
ADD .buckjavaargs /app/.buckjavaargs
28-
ADD BUCK /app/BUCK
2926
ADD packages/react-native/Libraries /app/packages/react-native/Libraries
3027
ADD packages/react-native/ReactAndroid /app/packages/react-native/ReactAndroid
3128
ADD packages/react-native/ReactCommon /app/packages/react-native/ReactCommon
3229
ADD packages/react-native/React /app/packages/react-native/React
33-
ADD keystores /app/keystores
3430
ADD packages/react-native-codegen /app/packages/react-native-codegen
3531
ADD tools /app/tools
3632
ADD scripts /app/scripts

.circleci/config.yml

Lines changed: 64 additions & 104 deletions
Large diffs are not rendered by default.

ReactAndroid/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ android {
653653
buildFeatures {
654654
prefab true
655655
prefabPublishing !skipPrefabPublishing
656+
buildConfig true
656657
}
657658

658659
prefab {
@@ -813,6 +814,8 @@ react {
813814
}
814815

815816
kotlin {
817+
// We intentionally don't build on JDK 17 as our tests are broken due to Mockito/PowerMock
818+
// not running well on JDK 17.
816819
jvmToolchain(11)
817820
}
818821

ReactAndroid/gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ LIBEVENT_VERSION=2.1.12
3232

3333
android.useAndroidX=true
3434
android.enableJetifier=true
35+
36+
# We want to have more fine grained control on the Java version for
37+
# ReactAndroid, therefore we disable RGNP Java version alignment mechanism
38+
react.internal.disableJavaVersionAlignment=true

ReactAndroid/hermes-engine/build.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,6 @@ android {
227227
targetCompatibility = JavaVersion.VERSION_11
228228
}
229229

230-
kotlin {
231-
jvmToolchain(11)
232-
}
233-
234230
sourceSets {
235231
main {
236232
manifest.srcFile "$hermesDir/android/hermes/src/main/AndroidManifest.xml"

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
// their settings.gradle.kts file.
1212
// More on this here: https://reactnative.dev/contributing/how-to-build-from-source
1313
plugins {
14-
id("com.android.library") version "7.4.2" apply false
15-
id("com.android.application") version "7.4.2" apply false
14+
id("com.android.library") version "8.2.1" apply false
15+
id("com.android.application") version "8.2.1" apply false
1616
id("de.undercouch.download") version "5.0.1" apply false
1717
kotlin("android") version "1.8.22" apply false
1818
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
#Sat Jan 13 16:13:20 PST 2024
12
distributionBase=GRADLE_USER_HOME
23
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
45
networkTimeout=10000
56
zipStoreBase=GRADLE_USER_HOME
67
zipStorePath=wrapper/dists

packages/react-native-gradle-plugin/build.gradle.kts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dependencies {
3737
// The KGP/AGP version is defined by React Native Gradle plugin.
3838
// Therefore we specify an implementation dep rather than a compileOnly.
3939
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.22")
40-
implementation("com.android.tools.build:gradle:7.4.2")
40+
implementation("com.android.tools.build:gradle:8.2.1")
4141

4242
implementation("com.google.code.gson:gson:2.8.9")
4343
implementation("com.google.guava:guava:31.0.1-jre")
@@ -55,11 +55,14 @@ dependencies {
5555
}
5656

5757
java {
58+
// We intentionally don't build for Java 17 as users will see a cryptic bytecode version
59+
// error first. Instead we produce a Java 11-compatible Gradle Plugin, so that AGP can print their
60+
// nice message showing that JDK 11 (or 17) is required first
5861
sourceCompatibility = JavaVersion.VERSION_11
5962
targetCompatibility = JavaVersion.VERSION_11
6063
}
6164

62-
kotlin { jvmToolchain(11) }
65+
kotlin { jvmToolchain(17) }
6366

6467
tasks.withType<KotlinCompile> {
6568
kotlinOptions {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ class ReactPlugin : Plugin<Project> {
8686

8787
private fun checkJvmVersion(project: Project) {
8888
val jvmVersion = Jvm.current()?.javaVersion?.majorVersion
89-
if ((jvmVersion?.toIntOrNull() ?: 0) <= 8) {
89+
if ((jvmVersion?.toIntOrNull() ?: 0) <= 16) {
9090
project.logger.error(
9191
"""
9292
9393
********************************************************************************
9494
95-
ERROR: requires JDK11 or higher.
95+
ERROR: requires JDK17 or higher.
9696
Incompatible major version detected: '$jvmVersion'
9797
9898
********************************************************************************

0 commit comments

Comments
 (0)