OvalMoney / react-native-fitness

A React Native module to interact with Apple Healthkit and Google Fit.
MIT License
341 stars 68 forks source link

App crash on bundleRelease version #95

Closed ricardodolnl closed 3 years ago

ricardodolnl commented 3 years ago

The app crashed on Android when a users wants to choose a google account (on the oAuth screen). This only happens on the bundleRelease version and not on debug or the apk production version (so really only on the bundle release version that you'd upload to play console). The app also already has a OAuth 2.0 Client ID with the scopes activity.read and location.read.

The weird thing is that I can't really debug it that well because the release version works, just not when I upload and install it via play console. ./gradlew installRelease works fine ./gradlew bundleRelease and uploading to play console and installing it makes the app crash when clicking the on an account in the oAuth screen.

02-22 10:51:41.211  6670  6724 E AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
02-22 10:51:41.211  6670  6724 E AndroidRuntime: Process: com.example.app, PID: 6670
02-22 10:51:41.211  6670  6724 E AndroidRuntime: java.lang.NullPointerException: null reference
02-22 10:51:41.211  6670  6724 E AndroidRuntime:    at com.google.android.gms.common.internal.p.i(Unknown Source:7)
02-22 10:51:41.211  6670  6724 E AndroidRuntime:    at e.d.a.b.e.c.b(Unknown Source:0)
02-22 10:51:41.211  6670  6724 E AndroidRuntime:    at com.ovalmoney.fitness.b.a.l(Unknown Source:68)
02-22 10:51:41.211  6670  6724 E AndroidRuntime:    at com.ovalmoney.fitness.RNFitnessModule.getSteps(Unknown Source:10)
02-22 10:51:41.211  6670  6724 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
02-22 10:51:41.211  6670  6724 E AndroidRuntime:    at com.facebook.react.bridge.JavaMethodWrapper.invoke(Unknown Source:147)
02-22 10:51:41.211  6670  6724 E AndroidRuntime:    at com.facebook.react.bridge.JavaModuleWrapper.invoke(Unknown Source:21)
02-22 10:51:41.211  6670  6724 E AndroidRuntime:    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
02-22 10:51:41.211  6670  6724 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:883)
02-22 10:51:41.211  6670  6724 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:100)
02-22 10:51:41.211  6670  6724 E AndroidRuntime:    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0)
02-22 10:51:41.211  6670  6724 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:214)
02-22 10:51:41.211  6670  6724 E AndroidRuntime:    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37)
02-22 10:51:41.211  6670  6724 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:919)
Francesco-Voto commented 3 years ago

I will investigate

ricardodolnl commented 3 years ago

Nevermind I fixed it. It was a mix of multiple things.

Long story short: the Google Play Console version of the app has a different SHA-1 then the SHA-1 of the release version you need to upload. Play Console changes this SHA-1. The problem was that I did not had a OAuth 2.0 Client ID with that SHA-1 (but I did for the debug and release keystore file).

So I was actually using Fitness.getSteps() without permissions. That's why the app crashed only in the version that was installed via the play store.