Skip to content

Commit 7e3a7ee

Browse files
Merge branch 'NewNPM' of https://github.com/CedricGuillemet/BabylonReactNative-1 into NewNPM
2 parents 625c17b + 4773530 commit 7e3a7ee

2 files changed

Lines changed: 65 additions & 16 deletions

File tree

Apps/Playground/android/build.gradle

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,24 @@ allprojects {
2424
google()
2525
}
2626
}
27+
28+
subprojects {
29+
afterEvaluate {
30+
// Workaround for Kotlin 2.0.x / AGP 8.8.x lint incompatibility (KT-62555)
31+
// Use Kotlin's actual attribute type via reflection to avoid type conflict
32+
try {
33+
def attrClass = Class.forName(
34+
"org.jetbrains.kotlin.gradle.targets.native.toolchain.KotlinNativeBundleArtifactFormat\$KotlinNativeBundleArtifactsTypes"
35+
)
36+
def attr = Attribute.of("kotlin.native.bundle.type", attrClass)
37+
def regularValue = attrClass.enumConstants.find { it.name() == "REGULAR" } ?: attrClass.enumConstants[0]
38+
configurations.configureEach { config ->
39+
if (!config.attributes.contains(attr)) {
40+
config.attributes.attribute(attr, regularValue)
41+
}
42+
}
43+
} catch (Exception e) {
44+
logger.warn("Kotlin native bundle type workaround skipped: ${e.message}")
45+
}
46+
}
47+
}

Modules/@babylonjs/react-native/android/build.gradle

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,9 @@ android {
179179
}
180180
}
181181
}
182-
lintOptions {
183-
abortOnError false
182+
lint {
183+
abortOnError = false
184+
checkReleaseBuilds = false
184185
}
185186

186187
publishing {
@@ -220,30 +221,37 @@ android {
220221
}
221222
}
222223

223-
packagingOptions {
224-
excludes = [
225-
"**/libc++_shared.so",
226-
"**/libfbjni.so",
227-
"**/libjsi.so",
228-
"**/libreact_nativemodule_core.so",
229-
"**/libreactnativejni.so",
230-
"**/libruntimeexecutor.so",
231-
"**/libturbomodulejsijni.so",
232-
"**/libreactnative.so",
233-
"META-INF/**"
234-
]
224+
packaging {
225+
jniLibs {
226+
excludes += [
227+
"**/libc++_shared.so",
228+
"**/libfbjni.so",
229+
"**/libjsi.so",
230+
"**/libreact_nativemodule_core.so",
231+
"**/libreactnativejni.so",
232+
"**/libruntimeexecutor.so",
233+
"**/libturbomodulejsijni.so",
234+
"**/libreactnative.so",
235+
]
236+
}
237+
resources {
238+
excludes += ["META-INF/**"]
239+
}
235240
}
236241

237242
if (ENABLE_PREFAB) {
243+
// Ensure the headers directory exists at configuration time for AGP validation
244+
file("${project.buildDir}/headers/ReactNativeBabylon").mkdirs()
245+
238246
buildFeatures {
239247
prefab true
240248
prefabPublishing true
241249
}
242-
/*prefab {
250+
prefab {
243251
ReactNativeBabylon {
244252
headers "${project.buildDir}/headers/ReactNativeBabylon/"
245253
}
246-
}*/
254+
}
247255
}
248256

249257
// Create new configurations that can be referred to in dependencies.
@@ -363,6 +371,10 @@ if (ENABLE_PREFAB) {
363371
}
364372
it.path = path
365373
}
374+
// Ensure the output directory exists even when no headers are found
375+
doFirst {
376+
file("${project.buildDir}/headers/ReactNativeBabylon").mkdirs()
377+
}
366378
}
367379
preBuild.dependsOn(prepareHeaders)
368380
}
@@ -387,4 +399,20 @@ configurations.extractLibs.files.each { file ->
387399
afterEvaluate {
388400
nativeBuildDependsOn(extractAARHeaders, null)
389401
nativeBuildDependsOn(extractJNIFiles, null)
402+
403+
// Workaround for Kotlin 2.0.x / AGP 8.8.x lint incompatibility (KT-62555)
404+
try {
405+
def attrClass = Class.forName(
406+
"org.jetbrains.kotlin.gradle.targets.native.toolchain.KotlinNativeBundleArtifactFormat\$KotlinNativeBundleArtifactsTypes"
407+
)
408+
def attr = Attribute.of("kotlin.native.bundle.type", attrClass)
409+
def regularValue = attrClass.enumConstants.find { it.name() == "REGULAR" } ?: attrClass.enumConstants[0]
410+
configurations.configureEach { config ->
411+
if (!config.attributes.contains(attr)) {
412+
config.attributes.attribute(attr, regularValue)
413+
}
414+
}
415+
} catch (Exception e) {
416+
logger.warn("Kotlin native bundle type workaround skipped: ${e.message}")
417+
}
390418
}

0 commit comments

Comments
 (0)