react-native-batch-push icon indicating copy to clipboard operation
react-native-batch-push copied to clipboard

BatchUser.trackTransaction crash on Android

Open psyzz opened this issue 5 years ago • 1 comments

Hello,

when using

BatchUser.trackTransaction(250);

the app crashes with this error :

12-03 15:49:16.527 14310 14432 E unknown:ReactNative: java.lang.NullPointerException: Attempt to invoke interface method 'java.util.HashMap com.facebook.react.bridge.ReadableMap.toHashMap()' on a null object reference
12-03 15:49:16.527 14310 14432 E unknown:ReactNative: 	at tech.bam.RNBatchPush.RNBatchModule.userData_trackTransaction(RNBatchModule.java:575)

(BatchUser.trackLocation works fine)

"@bam.tech/react-native-batch": "6.1.0-rc.0" Batch SDK 1.18

I also tried with the new version 7.0.0-rc.0 but i got this error when compiling (but maybe it will need to open another issue ?) :

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installAPPNAMEDevelopmentDebug -PreactNativeDevServerPort=8081
/Users/USERNAME/Documents/Dev/PROJECTS/APPNAME-Azure/APPNAME-RN/node_modules/@bam.tech/react-native-batch/android/src/main/java/tech/bam/RNBatchPush/RNUtils.java:113: error: no suitable method found for put(java.lang.String,java.net.URI)
                batchEventData.put(key, URI.create(valueMap.getString("value")));
                              ^
    method com.batch.android.BatchEventData.put(java.lang.String,java.lang.String) is not applicable
      (argument mismatch; java.net.URI cannot be converted to java.lang.String)
    method com.batch.android.BatchEventData.put(java.lang.String,float) is not applicable
      (argument mismatch; java.net.URI cannot be converted to float)
    method com.batch.android.BatchEventData.put(java.lang.String,double) is not applicable
      (argument mismatch; java.net.URI cannot be converted to double)
    method com.batch.android.BatchEventData.put(java.lang.String,int) is not applicable
      (argument mismatch; java.net.URI cannot be converted to int)
    method com.batch.android.BatchEventData.put(java.lang.String,long) is not applicable
      (argument mismatch; java.net.URI cannot be converted to long)
    method com.batch.android.BatchEventData.put(java.lang.String,boolean) is not applicable
      (argument mismatch; java.net.URI cannot be converted to boolean)
    method com.batch.android.BatchEventData.put(java.lang.String,java.util.Date) is not applicable
      (argument mismatch; java.net.URI cannot be converted to java.util.Date)
/Users/USERNAME/Documents/Dev/PROJECTS/APPNAME-Azure/APPNAME-RN/node_modules/@bam.tech/react-native-batch/android/src/main/java/tech/bam/RNBatchPush/RNBatchModule.java:523: error: no suitable method found for setAttribute(java.lang.String,java.net.URI)
                editor.setAttribute(key, URI.create(url));
                      ^
    method com.batch.android.BatchUserDataEditor.setAttribute(java.lang.String,long) is not applicable
      (argument mismatch; java.net.URI cannot be converted to long)
    method com.batch.android.BatchUserDataEditor.setAttribute(java.lang.String,double) is not applicable
      (argument mismatch; java.net.URI cannot be converted to double)
    method com.batch.android.BatchUserDataEditor.setAttribute(java.lang.String,boolean) is not applicable
      (argument mismatch; java.net.URI cannot be converted to boolean)
    method com.batch.android.BatchUserDataEditor.setAttribute(java.lang.String,java.util.Date) is not applicable
      (argument mismatch; java.net.URI cannot be converted to java.util.Date)
    method com.batch.android.BatchUserDataEditor.setAttribute(java.lang.String,java.lang.String) is not applicable
      (argument mismatch; java.net.URI cannot be converted to java.lang.String)
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':bam.tech_react-native-batch:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

psyzz avatar Dec 03 '21 15:12 psyzz

Hi, trackTransaction crash is fixed in v7 https://github.com/bamlab/react-native-batch-push/releases/tag/v7.0.0

For your second issue make sure to compile using Batch sdk 1.18, clean your build folder if necessary

Minishlink avatar Dec 06 '21 16:12 Minishlink