question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BaseActivity - NullPointerException

See original GitHub issue

General information

  • SDK/Library version: 5.0.1
  • Environment: production
  • Android Version and Device: Xiaomi Mi Note 10 with Android 10

Issue description

We recently updated the drop-in UI version to the latest one to solve this issue We upgraded the drop-in-ui library from 4.3.1 to 5.0.1

Today (9th of Decembre) we got this new issue.

Crash report from Firebase Crashlytics Exception message:

Fatal Exception: java.lang.RuntimeException: Unable to resume activity {com.reducted.reducted/com.braintreepayments.api.dropin.DropInActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.braintreepayments.api.v.k.r()' on a null object reference
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4279)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4311)
       at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2047)
       at android.os.Handler.dispatchMessage(Handler.java:107)
       at android.os.Looper.loop(Looper.java:224)
       at android.app.ActivityThread.main(ActivityThread.java:7584)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

Reported cause:

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.braintreepayments.api.v.k.r()' on a null object reference
       at com.braintreepayments.api.dropin.BaseActivity.shouldRequestThreeDSecureVerification(BaseActivity.java:70)
       at com.braintreepayments.api.dropin.DropInActivity.onPaymentMethodNonceCreated(DropInActivity.java:206)
       at com.braintreepayments.api.BraintreeFragment$4.run(BraintreeFragment.java:696)
       at com.braintreepayments.api.BraintreeFragment.flushCallbacks(BraintreeFragment.java:819)
       at com.braintreepayments.api.BraintreeFragment.addListener(BraintreeFragment.java:506)
       at com.braintreepayments.api.BraintreeFragment.onResume(BraintreeFragment.java:316)
       at androidx.fragment.app.Fragment.performResume(Fragment.java:2748)
       at androidx.fragment.app.FragmentStateManager.resume(FragmentStateManager.java:373)
       at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1211)
       at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1368)
       at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1446)
       at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1509)
       at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2637)
       at androidx.fragment.app.FragmentManager.dispatchResume(FragmentManager.java:2601)
       at androidx.fragment.app.FragmentController.dispatchResume(FragmentController.java:269)
       at androidx.fragment.app.FragmentActivity.onResumeFragments(FragmentActivity.java:478)
       at androidx.fragment.app.FragmentActivity.onPostResume(FragmentActivity.java:467)
       at androidx.appcompat.app.AppCompatActivity.onPostResume(AppCompatActivity.java:204)
       at android.app.Activity.performResume(Activity.java:8080)
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4269)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4311)
       at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2047)
       at android.os.Handler.dispatchMessage(Handler.java:107)
       at android.os.Looper.loop(Looper.java:224)
       at android.app.ActivityThread.main(ActivityThread.java:7584)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

App level build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

repositories {
    maven {
        url "https://redacted.appspot.com/"
        credentials {
            username = 'redacted'
            password = 'redacted'
        }
    }
    maven {
        url "https://cardinalcommerce.bintray.com/android"
        credentials {
            username 'braintree-team-sdk@cardinalcommerce'
            password '220cc9476025679c4e5c843666c27d97cfb0f951'
        }
    }
}

android {
    ext.buildNumber = Integer.valueOf(System.getenv("GITHUB_RUN_NUMBER") ?: 1) + 1467
    ext.buildName = System.getenv("GITHUB_RUN_NUMBER") ? Integer.valueOf(System.getenv("GITHUB_RUN_NUMBER") ?: 1) + 1467 : "local"

    compileSdkVersion 29
    buildToolsVersion = '29.0.2'
    defaultConfig {
        applicationId "com.redacted.redacted"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode buildNumber
        versionName "1.14.5 ($buildName)"
        setProperty("archivesBaseName", "Redacted-$versionName")
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        buildConfigField 'String', "GDPR_KEY", '"redacted"'
    }

    signingConfigs {
        release {
            storeFile file("redacted.jks")
            storePassword "redacted"
            keyAlias "redacted"
            keyPassword "redacted"
        }
    }

    flavorDimensions "env"

    productFlavors {
        dev {
            manifestPlaceholders = [allowClearTextTraffic:true]
            buildConfigField 'String', 'BASE_URL', '"http://test.redacted.com/api/"'
            buildConfigField 'String', 'FULL_VERSION_NAME', '"' + defaultConfig.versionName + ' dev"'
            resValue 'string', 'google_maps_key', '"redacted"'
            resValue 'string', 'facebook_app_id', '"redacted"'
            resValue 'string', 'fb_login_protocol_scheme', '"redacted"'
            resValue "bool", "fcm_analytics_enabled", "false"
        }
        prod {
            manifestPlaceholders = [allowClearTextTraffic:false]
            buildConfigField 'String', 'BASE_URL', '"https://www.redacted.com/api-mobile/api/"'
            buildConfigField 'String', 'FULL_VERSION_NAME', '"' + defaultConfig.versionName + '"'
            resValue 'string', 'google_maps_key', '"redacted"'
            resValue 'string', 'facebook_app_id', '"redacted"'
            resValue 'string', 'fb_login_protocol_scheme', '"redacted"'
            resValue "bool", "fcm_analytics_enabled", "true"
        }
    }

    buildTypes {
        release {
            multiDexEnabled false
            minifyEnabled true
            shrinkResources true
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            testCoverageEnabled = true
            multiDexEnabled true
            minifyEnabled false
            shrinkResources false
            firebaseCrashlytics {
                // If you don't need crash reporting for your debug build,
                // you can speed up your build by disabling mapping file uploading.
                mappingFileUploadEnabled false
            }
        }
    }

    // Always show the result of every unit test, even if it passes.
    testOptions.unitTests.all {
        testLogging {
            events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
        }
    }

    testOptions {
        unitTests.returnDefaultValues = true
    }

    dataBinding {
        enabled true
    }

    android.applicationVariants.all { variant ->
        variant.outputs.all {
            outputFileName = "Redacted ${variant.versionName} [${variant.name}].apk"
        }
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

    lintOptions {
        warning 'InvalidPackage'
        fatal 'HardcodedText'
    }

    compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }

    kotlinOptions {
        jvmTarget = "1.8"
    }
}

// Dependency versions
// ---------------------------------------
String redactedVersion = "0.3.6"
String rxJavaVersion = "2.1.6"
String rxAndroidVersion = "2.1.1"
String rxRelayVersion = "2.0.0"
String timberVersion = "4.7.1"
String facebookVersion = "5.8.0"
String crashlyticsVersion = "17.3.0"
String daggerVersion = '2.25.4'
String glideVersion = '3.7.0'
String glideIntegrationVersion = "1.5.0"
String retrofitVersion = '2.7.1'
String gsonVersion = '2.8.0'
String braintreeVersion = "5.0.1"
String ktxVersion = '1.1.0'

// --------------------------------------

dependencies {
    implementation "com.redacted:base:$redactedVersion"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "androidx.core:core-ktx:$ktxVersion"
    implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
    implementation "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion"
    implementation "com.jakewharton.rxrelay2:rxrelay:$rxRelayVersion"
    implementation "com.jakewharton.timber:timber:$timberVersion"
    implementation "com.google.dagger:dagger:$daggerVersion"
    kapt "com.google.dagger:dagger-compiler:$daggerVersion"
    implementation "com.facebook.android:facebook-android-sdk:$facebookVersion"
    implementation "com.google.firebase:firebase-analytics:18.0.0"
    implementation "com.google.firebase:firebase-core:18.0.0"
    implementation "com.google.firebase:firebase-messaging:21.0.0"
    implementation "com.google.firebase:firebase-crashlytics:$crashlyticsVersion"

    implementation "com.braintreepayments.api:drop-in:$braintreeVersion"

    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.1.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.browser:browser:1.2.0'
    implementation 'androidx.annotation:annotation:1.1.0'
    implementation "com.google.android.gms:play-services-vision:19.0.0"
    implementation "com.google.android.gms:play-services-maps:17.0.0"
    implementation "com.google.android.gms:play-services-location:17.0.0"
    implementation "com.github.bumptech.glide:glide:$glideVersion"
    implementation("com.github.bumptech.glide:okhttp3-integration:$glideIntegrationVersion@aar") {
        exclude group: 'glide-parent'
    }

    implementation "com.squareup.okhttp3:logging-interceptor:3.8.1"
    implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
    implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
    implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
    implementation "com.google.code.gson:gson:$gsonVersion"

    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    }

    testImplementation "junit:junit:4.12"
    testImplementation "org.mockito:mockito-core:2.27.0"

    //avoid a dependency resolution issue with google-services plugin
    //https://developers.braintreepayments.com/guides/3d-secure/migration/android/v3
    components.all {
        allVariants {
            withDependencies { deps ->
                deps.each { dep ->
                    if (dep.group == 'net.minidev' && dep.name =='json-smart') {
                        dep.version {
                            prefer "2.3"
                        }
                        dep.because "resolving dependencies issue"
                    }
                }
            }
        }
    }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mathieulabbbcommented, Mar 2, 2021

Same issue for our application with braintree-android-drop-in v5.0.2.

Steps to reproduce :

  • Leave 3D Secure page (to go to your bank’s application to validate payment for example)
  • Since payment is validate, bank app redirect to 3D Secure screen but redirect to our application not occurs (links between 3D Secure page and our application seems broken)

The problem may be related to the way they handle background applications to save energy.

1reaction
soshialcommented, Feb 28, 2021

Our users were also complaining about the same problem (happens only on some devices). @sshropshire please fix. I have a feeling that this happens only when during payment user’s bank application captures focus from BraintreeDropIn Activity.

Caused by java.lang.NullPointerException
Attempt to invoke virtual method 'boolean com.braintreepayments.api.models.Configuration.isThreeDSecureEnabled()' on a null object reference

    com.braintreepayments.api.dropin.BaseActivity.shouldRequestThreeDSecureVerification (BaseActivity.java:70)
    com.braintreepayments.api.dropin.DropInActivity.onPaymentMethodNonceCreated (DropInActivity.java:206)
    com.braintreepayments.api.BraintreeFragment$4.run (BraintreeFragment.java:696)
    com.braintreepayments.api.BraintreeFragment.flushCallbacks (BraintreeFragment.java:819)
    com.braintreepayments.api.BraintreeFragment.addListener (BraintreeFragment.java:506)
    com.braintreepayments.api.BraintreeFragment.onResume (BraintreeFragment.java:316)
    androidx.fragment.app.Fragment.performResume (Fragment.java:2748)

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

BaseActivity for NavigationDrawer gives ...
I have been trying to add the NavigationDrawer to multiple Activities , but I keep running into errors. I read almost everything that...
Read more >
Need help solving a java.lang.NullPointerException error
So I'm trying to make a nav drawer and I'm making an activity for all other activities to extend from so I don't...
Read more >
NPE when creating SettingsActivity (#2160) · Issues
NullPointerException : Attempt to invoke interface method 'void androidx.appcompat.widget.DecorContentParent.setWindowCallback(android.view.
Read more >
Incremental java compilation breaks apps with Butter Knife ...
Create BaseActivity which has a setup method for the Toolbar which will be included ... NullPointerException: Attempt to invoke virtual method 'java.lang.
Read more >
ActivityManager.RunningTaskInfo
public ComponentName · baseActivity. The component of the first activity in the task, can be considered the "application" of this task.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found