Skip to content

Commit b12a6b7

Browse files
authored
Merge pull request #607 from AppsFlyerSDK/dev/DELIVERY-82509/minor-fixes-and-6.16.0-Update
A 6.16.0 update and minor fixes
2 parents 09bcf03 + b94a9b6 commit b12a6b7

20 files changed

Lines changed: 153 additions & 88 deletions

File tree

Docs/RN_ExpoInstallation.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,75 @@ expo install react-native-appsflyer
3838
],
3939
...
4040
```
41+
### Fix for build failure with RN 0.76 and Expo 52
42+
To ensure seamless integration of the AppsFlyer plugin in your Expo-managed project, it’s essential to handle modifications to the AndroidManifest.xml correctly. Since direct edits to the AndroidManifest.xml aren’t feasible in the managed workflow, you’ll need to create a custom configuration to include the necessary changes.
43+
44+
### Handling dataExtractionRules Conflict
45+
46+
When building your Expo app with the AppsFlyer plugin, you might encounter a build error related to the `dataExtractionRules` attribute. This issue arises due to a conflict between the `dataExtractionRules `defined in your project’s `AndroidManifest.xml` and the one included in the AppsFlyer SDK.
47+
48+
<b>Solution:</b> Creating a Custom Plugin to Modify `AndroidManifest.xml`
49+
50+
To resolve this, you can create a custom Expo config plugin that modifies the AndroidManifest.xml during the build process. This approach allows you to adjust the manifest without directly editing it, maintaining compatibility with the managed workflow.
51+
52+
Steps to Implement the Custom Plugin:
53+
1. Create the Plugin File:
54+
- In your project’s root directory, create a file named withCustomAndroidManifest.js.
55+
2. Define the Plugin Function:
56+
- In withCustomAndroidManifest.js, define a function that uses Expo’s withAndroidManifest to modify the manifest. This function will remove the conflicting dataExtractionRules attribute.
57+
58+
```js
59+
// withCustomAndroidManifest.js
60+
const { withAndroidManifest } = require('@expo/config-plugins');
61+
62+
module.exports = function withCustomAndroidManifest(config) {
63+
return withAndroidManifest(config, async (config) => {
64+
const androidManifest = config.modResults;
65+
const manifest = androidManifest.manifest;
66+
67+
// Ensure xmlns:tools is present in the <manifest> tag
68+
if (!manifest.$['xmlns:tools']) {
69+
manifest.$['xmlns:tools'] = 'http://schemas.android.com/tools';
70+
}
71+
72+
const application = manifest.application[0];
73+
74+
// Add tools:replace attribute for dataExtractionRules and fullBackupContent
75+
application['$']['tools:replace'] = 'android:dataExtractionRules, android:fullBackupContent';
76+
77+
// Set dataExtractionRules and fullBackupContent as attributes within <application>
78+
application['$']['android:dataExtractionRules'] = '@xml/secure_store_data_extraction_rules';
79+
application['$']['android:fullBackupContent'] = '@xml/secure_store_backup_rules';
80+
81+
return config;
82+
});
83+
};
84+
85+
```
86+
87+
3. Update app.json or app.config.js:
88+
- In your app configuration file, include the custom plugin to ensure it’s executed during the build process.
89+
90+
```json
91+
// app.json
92+
{
93+
"expo": {
94+
// ... other configurations ...
95+
"plugins": [
96+
"./withCustomAndroidManifest.js",
97+
[
98+
"react-native-appsflyer",
99+
{
100+
"shouldUseStrictMode": true
101+
}
102+
]
103+
]
104+
}
105+
}
106+
```
107+
108+
By implementing this custom plugin, you can resolve the dataExtractionRules conflict without directly modifying the AndroidManifest.xml.
109+
41110
## The AD_ID permission for android apps
42111
In v6.8.0 of the AppsFlyer SDK, we added the normal permission com.google.android.gms.permission.AD_ID to the SDK's AndroidManifest,
43112
to allow the SDK to collect the Android Advertising ID on apps targeting API 33.

android/.project

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,13 @@
55
<projects>
66
</projects>
77
<buildSpec>
8-
<buildCommand>
9-
<name>org.eclipse.jdt.core.javabuilder</name>
10-
<arguments>
11-
</arguments>
12-
</buildCommand>
138
<buildCommand>
149
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
1510
<arguments>
1611
</arguments>
1712
</buildCommand>
1813
</buildSpec>
1914
<natures>
20-
<nature>org.eclipse.jdt.core.javanature</nature>
2115
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
2216
</natures>
2317
<filteredResources>

android/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ buildscript {
2020
apply plugin: 'com.android.library'
2121

2222
android {
23+
namespace "com.appsflyer.reactnative"
2324
compileSdkVersion safeExtGet('compileSdkVersion', 34)
2425
buildToolsVersion safeExtGet('buildToolsVersion', '34.0.0')
2526

2627
defaultConfig {
27-
minSdkVersion safeExtGet('minSdkVersion', 16)
28+
minSdkVersion safeExtGet('minSdkVersion', 21)
2829
targetSdkVersion safeExtGet('targetSdkVersion', 34)
2930
versionCode 1
3031
versionName "1.0"
@@ -54,5 +55,5 @@ repositories {
5455
dependencies {
5556
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
5657
implementation "com.android.installreferrer:installreferrer:${safeExtGet('installReferrerVersion', '2.1')}"
57-
api "com.appsflyer:af-android-sdk:${safeExtGet('appsflyerVersion', '6.15.2')}"
58+
api "com.appsflyer:af-android-sdk:${safeExtGet('appsflyerVersion', '6.16.0')}"
5859
}

android/src/main/java/com/appsflyer/reactnative/RNAppsFlyerConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
public class RNAppsFlyerConstants {
88

9-
final static String PLUGIN_VERSION = "6.15.3";
9+
final static String PLUGIN_VERSION = "6.16.0";
1010
final static String NO_DEVKEY_FOUND = "No 'devKey' found or its empty";
1111
final static String UNKNOWN_ERROR = "AF Unknown Error";
1212
final static String SUCCESS = "Success";

demos/appsflyer-react-native-app/android/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ android {
148148
keyPassword 'android'
149149
}
150150
}
151+
namespace 'com.appsflyerexample'
151152
buildTypes {
152153
debug {
153154
signingConfig signingConfigs.debug

demos/appsflyer-react-native-app/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ buildscript {
1414
}
1515
dependencies {
1616
//classpath("com.android.tools.build:gradle:4.2.1")
17-
classpath("com.android.tools.build:gradle:7.1.3")
17+
classpath('com.android.tools.build:gradle:8.2.0')
1818
// NOTE: Do not place your application dependencies here; they belong
1919
// in the individual module build.gradle files
2020
}

demos/appsflyer-react-native-app/android/gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ android.enableJetifier=true
2626

2727
# Version of flipper SDK to use with React Native
2828
FLIPPER_VERSION=0.93.0
29+
android.defaults.buildfeatures.buildconfig=true
30+
android.nonTransitiveRClass=false
31+
android.nonFinalResIds=false
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Sun Sep 01 10:19:20 IDT 2024
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

demos/appsflyer-react-native-app/components/AppsFlyer.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ const initOptions = {
2121
export function AFInit() {
2222
if (Platform.OS == 'ios') {
2323
appsFlyer.setCurrentDeviceLanguage("EN");
24+
appsFlyer.disableSKAD(true);
2425
}
26+
27+
appsFlyer.anonymizeUser(true);
28+
appsFlyer.enableTCFDataCollection(true);
29+
2530
appsFlyer.setAppInviteOneLinkID('oW4R');
2631
appsFlyer.initSdk(initOptions, null, null);
2732
}
@@ -35,7 +40,7 @@ export function AFLogEvent(name, values) {
3540
export function AFLogAdRevenue(){
3641
const adRevenueData = {
3742
monetizationNetwork: 'AF-AdNetwork',
38-
mediationNetwork: MEDIATION_NETWORK.IRONSOURCE,
43+
mediationNetwork: MEDIATION_NETWORK.DIRECT_MONETIZATION_NETWORK,
3944
currencyIso4217Code: 'USD',
4045
revenue: 1.23,
4146
additionalParameters : {

0 commit comments

Comments
 (0)