Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(analytics-react-native): support RN 0.73 #871

Merged
merged 3 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading