Skip to content

Commit d12b3ff

Browse files
committed
Working Android sample app
- Updated AGP plugin, minSDK, buildtool and gradle version to fix the dex issue `[CIRCULAR REFERENCE: com.android.tools.r8.kotlin.H]` - Changed the `includeBuild` to correct path - Added network_security_config.xml to fix cleartext traffic error in new Android versions - Added babel configs to fix bundler issue
1 parent 48b6878 commit d12b3ff

File tree

10 files changed

+47
-11
lines changed

10 files changed

+47
-11
lines changed

sample/.babelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"presets": ["react-native"]
3-
}
2+
"presets": ["module:metro-react-native-babel-preset"]
3+
}

sample/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ dependencies {
164164
//
165165
// (See https://github.com/mparticle/mparticle-android-sdk for the latest version)
166166
//
167-
implementation "com.mparticle:android-core:5.1337.0-SNAPSHOT"
167+
implementation "com.mparticle:android-core:5.70.3-SNAPSHOT"
168168

169169
//
170170
// And, if you want to include kits, you can do so as follows:

sample/android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
android:allowBackup="true"
1010
android:label="@string/app_name"
1111
android:icon="@mipmap/ic_launcher"
12+
android:networkSecurityConfig="@xml/network_security_config"
1213
android:theme="@style/AppTheme">
1314
<activity
1415
android:name=".MainActivity"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<network-security-config>
3+
<base-config cleartextTrafficPermitted="true">
4+
<trust-anchors>
5+
<!-- Trust user added CAs in the Example app -->
6+
<certificates src="user" />
7+
<certificates src="system" />
8+
</trust-anchors>
9+
</base-config>
10+
</network-security-config>

sample/android/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
buildscript {
44
ext {
5-
buildToolsVersion = "31.0.0"
6-
minSdkVersion = 21
5+
buildToolsVersion = "34.0.0"
6+
minSdkVersion = 26
77
compileSdkVersion = 34
8-
targetSdkVersion = 31
8+
targetSdkVersion = 34
99

10-
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
11-
ndkVersion = "23.1.7779620"
10+
// We use NDK 25 which has both M1 support and is the side-by-side NDK version from AGP.
11+
ndkVersion = "25.1.8937393"
1212
}
1313

1414
repositories {
1515
google()
1616
mavenCentral()
1717
}
1818
dependencies {
19-
classpath("com.android.tools.build:gradle:7.3.1")
19+
classpath("com.android.tools.build:gradle:8.1.4")
2020
classpath("com.facebook.react:react-native-gradle-plugin")
2121
}
2222
}

sample/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip

sample/android/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ include ':react-native-mparticle'
33
project(':react-native-mparticle').projectDir = new File(rootProject.projectDir, '../../android')
44

55
include ':app'
6-
includeBuild('../node_modules/react-native-gradle-plugin')
6+
includeBuild('../node_modules/@react-native/gradle-plugin')

sample/babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: ['module:metro-react-native-babel-preset'],
3+
};

sample/metro.config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
2+
const path = require('path');
3+
4+
/**
5+
* Metro configuration
6+
* https://facebook.github.io/metro/docs/configuration
7+
*
8+
* @type {import('metro-config').MetroConfig}
9+
*/
10+
const config = {
11+
watchFolders: [path.resolve(__dirname, '..')],
12+
resolver: {
13+
nodeModulesPaths: [
14+
path.resolve(__dirname, 'node_modules'),
15+
],
16+
},
17+
};
18+
19+
module.exports = mergeConfig(getDefaultConfig(__dirname), config);

sample/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "@tsconfig/react-native/tsconfig.json"
3+
}

0 commit comments

Comments
 (0)