Skip to content

Commit

Permalink
fix(analytics-react-native): support RN 0.73 (#871)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mercy811 authored Sep 13, 2024
1 parent 2ac566e commit d0ae4d6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
24 changes: 23 additions & 1 deletion packages/analytics-react-native/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ buildscript {
ext.kotlinVersion = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : "1.5.30"
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
Expand All @@ -18,7 +18,29 @@ def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

def isSupportNamespace() {
def apgParsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
def agpMajorVersion = apgParsed[0].toInteger()
def agpMinorVersion = apgParsed[1].toInteger()

/**
* Namespace is added in AGP 7.3 and is required starting from AGP 8.x.
* See: https://developer.android.com/build/releases/past-releases/agp-8-0-0-release-notes#namespace-dsl
*/
return (agpMajorVersion == 7 && agpMinorVersion >= 3) || agpMajorVersion >= 8
}

android {
if (isSupportNamespace()) {
namespace "com.amplitude.reactnative"

sourceSets {
main {
manifest.srcFile "src/main/AndroidManifestNew.xml"
}
}
}

compileSdkVersion safeExtGet('compileSdkVersion', 29)
buildToolsVersion safeExtGet('buildToolsVersion', '29.0.2')
defaultConfig {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--
Remove namespace here as it's supported in build.gradle
from AGP 7.3 and is required starting from AGP 8.x.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
</manifest>

0 comments on commit d0ae4d6

Please sign in to comment.