Onesignal-android-sdk: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Integer com.onesignal.OSUtils.getNetType()

Created on 13 Jul 2019  Â·  12Comments  Â·  Source: OneSignal/OneSignal-Android-SDK

 E/AndroidRuntime: FATAL EXCEPTION: OS_REG_USER
    Process: com.example.app, PID: 19782
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Integer com.onesignal.OSUtils.getNetType()' on a null object reference
        at com.onesignal.OneSignal.registerUserTask(OneSignal.java:1286)
        at com.onesignal.OneSignal.access$1700(OneSignal.java:77)
        at com.onesignal.OneSignal$7.run(OneSignal.java:1254)
        at java.lang.Thread.run(Thread.java:764)

it can be easily reproducible by setting OneSignal.provideUserConsent(false); then lock & unlock the phone (NOKIA 5.1 plus)

build.gradle project level

classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.1.0'

build.gradle app level

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.2, 0.99.99]'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28

    defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 17
        targetSdkVersion 28
        manifestPlaceholders = [manifestApplicationId: "${applicationId}",

                                onesignal_google_project_number: "REMOTE"]

        multiDexEnabled true
        resConfigs "en"
    }

    buildTypes {

        debug{
            debuggable true
            minifyEnabled false
            resValue("string", "PORT_NUMBER", "8081")
        }
        release {
            debuggable false
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        }
    }
    dexOptions {
        javaMaxHeapSize "4g"
            jumboMode = true

    }


    repositories {
        google()
        jcenter()
        maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
        maven { url 'https://maven.google.com' }

        maven { url 'https://jitpack.io' }

        mavenCentral()
    }

    useLibrary  'org.apache.http.legacy'

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

dependencies {



    implementation fileTree(dir: 'libs', include: ['*.jar'])




    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:preference-v7:28.0.0'
    implementation 'com.android.support:customtabs:28.0.0'
    implementation 'com.android.volley:volley:1.1.1'
    implementation 'com.onesignal:OneSignal:[3.10.9, 3.99.99]'
    implementation 'com.android.support:multidex:1.0.3'



    implementation 'com.google.firebase:firebase-messaging:19.0.1'
    implementation 'com.google.firebase:firebase-core:17.0.0'
    implementation 'com.google.firebase:firebase-auth:18.0.0'
    implementation 'com.google.firebase:firebase-database:18.0.0'


    implementation 'com.google.android.libraries.places:places:1.1.0'
    implementation 'com.google.android.gms:play-services-location:17.0.0'
    implementation 'com.google.android.gms:play-services-basement:17.0.0'
    implementation 'com.google.android.gms:play-services-auth:17.0.0'


    implementation 'com.google.android.ads.consent:consent-library:1.0.7'


}
apply plugin: 'com.google.gms.google-services'


Help Wanted

Most helpful comment

@gsksarath @T-T-P @emmanuel-marty ,
We will be releasing a fix for this very soon. Thanks for your patience

All 12 comments

Howdy!
All your firebase dependencies should be on the same version (e.g: 17.0.0). Could you try setting them all to the same version?

Getting same error even i set all firebase dependencies to 17.00.

It appears you aren't actually using the latest version. Can you make sure you're using 3.11.1 please? Cheers

Ok let me know which firebase SDK version should I have to use for onesignal
3.11.1

On Tue, 23 Jul, 2019, 12:58 AM Rodrigo Gomez Palacio, <
[email protected]> wrote:

It appears you aren't actually using the latest version. Can you make sure
you're using 3.11.1 please? Cheers

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/OneSignal/OneSignal-Android-SDK/issues/800?email_source=notifications&email_token=AAU7A4SDLXT2KDCRKQWY5GTQAYC5HA5CNFSM4IC35GV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2Q5AFA#issuecomment-513921044,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAU7A4U3KF3RQPJJHDK7TV3QAYC5HANCNFSM4IC35GVQ
.

@gsksarath Thanks for the details, the crash stack trace doesn't point to a firebase issue. It's possible a change in version 3.11.0 or 3.11.1 of the OneSignal SDK could be the issue.

Can you try to reproduce the the specific crash in version 3.11.0 and 3.10.?

@jkasten2 yes, i can easily reproduce crash in both 3.11.0 and 3.11.1 too. i halted my production build because of this issue

onesignal_crash

@jkasten2 It's seems the issue #810 & #800 are same

I reverted to SDK 3.10.9 as this is extremely widespread (crashing over 10% of user sessions!) and it seems to have appeared in 3.11.0 or 3.11.1.

@jkasten2 any update on this issue?

I too am observing this issue in my Xamarin app running v3.4.0 (latest stable) but only seeing the issue occur in the Android builds. I assume getNetType() is attempting to determine the connection type and that perhaps the OS is switching at that particular point or something? At present observing on Pixel devices and all Samsung Galaxy 6/7/8 and 9 devices on multiple versions of Android.

@gsksarath @T-T-P @emmanuel-marty ,
We will be releasing a fix for this very soon. Thanks for your patience

This issue is now resolved in the just released in 3.11.2 SDK
https://github.com/OneSignal/OneSignal-Android-SDK/releases/tag/3.11.2

Was this page helpful?
0 / 5 - 0 ratings