java.lang.NullPointerException issue on version 4.2
andreiasavei opened this issue · 3 comments
Issue: I added the latest version: implementation 'com.github.matomo-org:matomo-sdk-android:4.2'
And when I go to the main activity I get this error:
FATAL EXCEPTION: main
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
at my.app..ui.MainActivity$$ExternalSyntheticLambda3.onChanged
at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
at androidx.lifecycle.LiveData$1.run(LiveData.java:93)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7872)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
On an older version: 4.1.4 (works good), I don't get this error. What could be the problem? I looked in the code and I didn't find a problem of " 'int java.lang.Integer.intValue()' on a null object reference"
I strongly recommend to check my.app..ui.MainActivity$$ExternalSyntheticLambda3.onChanged
It's located locally in you code.
Without your code I can do here nothing
I tried to find out more details about the error. I followed the next steps:
- Run the application, everything is fine, no issues
- Add the library to the gradle module file: implementation 'com.github.matomo-org:matomo-sdk-android:4.2'
- Crash when opening the app, with the same error as above:
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference at my.app.ui.MainActivity$$ExternalSyntheticLambda3.onChanged(Unknown Source:6).
"Unknown Source:6" line is this
import about PackageManager: import android.content.pm.PackageManager
.
I use this import to verify some app permissions:
exemple 1:
checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
exemple 2:
override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<String>,
grantResults: IntArray
) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
}
}
Without your code I can do here nothing
nothing changed here