Skip to content

Commit 76aa165

Browse files
Merge pull request #9 from AdversportTeam/fix/object-already-consumed-exception
fix: resolve ObjectAlreadyConsumedException and RN 0.79 compatibility
2 parents caed92f + 690864a commit 76aa165

3 files changed

Lines changed: 21 additions & 53 deletions

File tree

android/build.gradle

Lines changed: 7 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
1-
buildscript {
2-
ext.safeExtGet = {prop, fallback ->
3-
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
4-
}
5-
repositories {
6-
google()
7-
mavenCentral()
8-
}
9-
10-
dependencies {
11-
classpath 'com.android.tools.build:gradle:7.0.4'
12-
}
1+
ext.safeExtGet = {prop, fallback ->
2+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
133
}
144

155
if (isNewArchitectureEnabled()) {
@@ -26,61 +16,26 @@ android {
2616
versionCode 1
2717
versionName "1.0"
2818
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
29-
if (isNewArchitectureEnabled()) {
30-
var appProject = rootProject.allprojects.find {it.plugins.hasPlugin('com.android.application')}
31-
externalNativeBuild {
32-
ndkBuild {
33-
arguments "APP_PLATFORM=android-21",
34-
"APP_STL=c++_shared",
35-
"NDK_TOOLCHAIN_VERSION=clang",
36-
"GENERATED_SRC_DIR=${appProject.buildDir}/generated/source",
37-
"PROJECT_BUILD_DIR=${appProject.buildDir}",
38-
"REACT_ANDROID_DIR=${appProject.rootDir}/../node_modules/react-native/ReactAndroid",
39-
"REACT_ANDROID_BUILD_DIR=${appProject.rootDir}/../node_modules/react-native/ReactAndroid/build"
40-
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
41-
cppFlags "-std=c++17"
42-
targets "rnaps_modules"
43-
}
44-
}
45-
}
46-
}
47-
if (isNewArchitectureEnabled()) {
48-
externalNativeBuild {
49-
ndkBuild {
50-
path "src/main/jni/Android.mk"
51-
}
52-
}
53-
}
54-
packagingOptions {
55-
// For some reason gradle only complains about the duplicated version of libreact_render libraries
56-
// while there are more libraries copied in intermediates folder of the lib build directory, we exclude
57-
// only the ones that make the build fail (ideally we should only include librnaps_modules but we
58-
// are only allowed to specify exclude patterns)
59-
exclude "**/libreact_render*.so"
19+
6020
}
21+
6122

6223
buildTypes {
6324
release {
64-
minifyEnabled true
65-
proguardFile 'proguard-rules.pro'
25+
minifyEnabled false
26+
consumerProguardFiles 'proguard-rules.pro'
6627
}
6728
}
6829
}
6930

7031
repositories {
71-
maven {
72-
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
73-
// Matches the RN Hello World template
74-
// https://github.com/facebook/react-native/blob/1e8f3b11027fe0a7514b4fc97d0798d3c64bc895/local-cli/templates/HelloWorld/android/build.gradle#L21
75-
url "$projectDir/../node_modules/react-native/android"
76-
}
7732
mavenCentral()
7833
google()
7934
}
8035

8136
dependencies {
8237
if (isNewArchitectureEnabled()) {
83-
implementation project(":ReactAndroid")
38+
implementation("com.facebook.react:react-android")
8439
} else {
8540
implementation 'com.facebook.react:react-native:+'
8641
}

android/src/main/java/com/adversport/rnaps/RNAPSAdLoaderModule.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,20 @@ public void onSuccess(DTBAdResponse response) {
145145

146146
sendEvent(EVENT_SUCCESS, payload);
147147
if (promise != null) {
148-
promise.resolve(responseMap);
148+
// Créer une copie pour promise.resolve car responseMap est déjà utilisé
149+
WritableMap responseCopy = Arguments.createMap();
150+
for (Map.Entry<String, List<String>> entry : customParams.entrySet()) {
151+
List<String> values = entry.getValue();
152+
StringBuilder valueBuilder = new StringBuilder();
153+
for (int i = 0; i < values.size(); i++) {
154+
valueBuilder.append(values.get(i));
155+
if (i < values.size() - 1) {
156+
valueBuilder.append(",");
157+
}
158+
}
159+
responseCopy.putString(entry.getKey(), valueBuilder.toString());
160+
}
161+
promise.resolve(responseCopy);
149162
promise = null;
150163
}
151164
}

0 commit comments

Comments
 (0)