Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NullPointerException issue on version 4.2 #483

Open
andreiasavei opened this issue Mar 18, 2024 · 3 comments
Open

java.lang.NullPointerException issue on version 4.2 #483

andreiasavei opened this issue Mar 18, 2024 · 3 comments

Comments

@andreiasavei
Copy link

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"

@hannesa2
Copy link
Collaborator

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

@andreiasavei
Copy link
Author

andreiasavei commented Mar 19, 2024

I tried to find out more details about the error. I followed the next steps:

  1. Run the application, everything is fine, no issues
  2. Add the library to the gradle module file: implementation 'com.github.matomo-org:matomo-sdk-android:4.2'
  3. 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) {   
        }
    }

@hannesa2
Copy link
Collaborator

Without your code I can do here nothing

nothing changed here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants