Skip to content

Commit

Permalink
Merge pull request #607 from AppsFlyerSDK/dev/DELIVERY-82509/minor-fi…
Browse files Browse the repository at this point in the history
…xes-and-6.16.0-Update

A 6.16.0 update and minor fixes
  • Loading branch information
al-af authored Feb 23, 2025
2 parents 09bcf03 + b94a9b6 commit b12a6b7
Show file tree
Hide file tree
Showing 20 changed files with 153 additions and 88 deletions.
69 changes: 69 additions & 0 deletions Docs/RN_ExpoInstallation.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,75 @@ expo install react-native-appsflyer
],
...
```
### Fix for build failure with RN 0.76 and Expo 52
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.

### Handling dataExtractionRules Conflict

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.

<b>Solution:</b> Creating a Custom Plugin to Modify `AndroidManifest.xml`

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.

Steps to Implement the Custom Plugin:
1. Create the Plugin File:
- In your project’s root directory, create a file named withCustomAndroidManifest.js.
2. Define the Plugin Function:
- In withCustomAndroidManifest.js, define a function that uses Expo’s withAndroidManifest to modify the manifest. This function will remove the conflicting dataExtractionRules attribute.

```js
// withCustomAndroidManifest.js
const { withAndroidManifest } = require('@expo/config-plugins');

module.exports = function withCustomAndroidManifest(config) {
return withAndroidManifest(config, async (config) => {
const androidManifest = config.modResults;
const manifest = androidManifest.manifest;

// Ensure xmlns:tools is present in the <manifest> tag
if (!manifest.$['xmlns:tools']) {
manifest.$['xmlns:tools'] = 'http://schemas.android.com/tools';
}

const application = manifest.application[0];

// Add tools:replace attribute for dataExtractionRules and fullBackupContent
application['$']['tools:replace'] = 'android:dataExtractionRules, android:fullBackupContent';

// Set dataExtractionRules and fullBackupContent as attributes within <application>
application['$']['android:dataExtractionRules'] = '@xml/secure_store_data_extraction_rules';
application['$']['android:fullBackupContent'] = '@xml/secure_store_backup_rules';

return config;
});
};

```

3. Update app.json or app.config.js:
- In your app configuration file, include the custom plugin to ensure it’s executed during the build process.

```json
// app.json
{
"expo": {
// ... other configurations ...
"plugins": [
"./withCustomAndroidManifest.js",
[
"react-native-appsflyer",
{
"shouldUseStrictMode": true
}
]
]
}
}
```

By implementing this custom plugin, you can resolve the dataExtractionRules conflict without directly modifying the AndroidManifest.xml.

## The AD_ID permission for android apps
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,
to allow the SDK to collect the Android Advertising ID on apps targeting API 33.
Expand Down
6 changes: 0 additions & 6 deletions android/.project
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<filteredResources>
Expand Down
5 changes: 3 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ buildscript {
apply plugin: 'com.android.library'

android {
namespace "com.appsflyer.reactnative"
compileSdkVersion safeExtGet('compileSdkVersion', 34)
buildToolsVersion safeExtGet('buildToolsVersion', '34.0.0')

defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 16)
minSdkVersion safeExtGet('minSdkVersion', 21)
targetSdkVersion safeExtGet('targetSdkVersion', 34)
versionCode 1
versionName "1.0"
Expand Down Expand Up @@ -54,5 +55,5 @@ repositories {
dependencies {
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
implementation "com.android.installreferrer:installreferrer:${safeExtGet('installReferrerVersion', '2.1')}"
api "com.appsflyer:af-android-sdk:${safeExtGet('appsflyerVersion', '6.15.2')}"
api "com.appsflyer:af-android-sdk:${safeExtGet('appsflyerVersion', '6.16.0')}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class RNAppsFlyerConstants {

final static String PLUGIN_VERSION = "6.15.3";
final static String PLUGIN_VERSION = "6.16.0";
final static String NO_DEVKEY_FOUND = "No 'devKey' found or its empty";
final static String UNKNOWN_ERROR = "AF Unknown Error";
final static String SUCCESS = "Success";
Expand Down
1 change: 1 addition & 0 deletions demos/appsflyer-react-native-app/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ android {
keyPassword 'android'
}
}
namespace 'com.appsflyerexample'
buildTypes {
debug {
signingConfig signingConfigs.debug
Expand Down
2 changes: 1 addition & 1 deletion demos/appsflyer-react-native-app/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ buildscript {
}
dependencies {
//classpath("com.android.tools.build:gradle:4.2.1")
classpath("com.android.tools.build:gradle:7.1.3")
classpath('com.android.tools.build:gradle:8.2.0')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
3 changes: 3 additions & 0 deletions demos/appsflyer-react-native-app/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ android.enableJetifier=true

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.93.0
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Sep 01 10:19:20 IDT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 6 additions & 1 deletion demos/appsflyer-react-native-app/components/AppsFlyer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ const initOptions = {
export function AFInit() {
if (Platform.OS == 'ios') {
appsFlyer.setCurrentDeviceLanguage("EN");
appsFlyer.disableSKAD(true);
}

appsFlyer.anonymizeUser(true);
appsFlyer.enableTCFDataCollection(true);

appsFlyer.setAppInviteOneLinkID('oW4R');
appsFlyer.initSdk(initOptions, null, null);
}
Expand All @@ -35,7 +40,7 @@ export function AFLogEvent(name, values) {
export function AFLogAdRevenue(){
const adRevenueData = {
monetizationNetwork: 'AF-AdNetwork',
mediationNetwork: MEDIATION_NETWORK.IRONSOURCE,
mediationNetwork: MEDIATION_NETWORK.DIRECT_MONETIZATION_NETWORK,
currencyIso4217Code: 'USD',
revenue: 1.23,
additionalParameters : {
Expand Down
Loading

0 comments on commit b12a6b7

Please sign in to comment.