RuntimeException Unable to start activity ComponentInfo SignInHubActivity

Fatal Exception: java.lang.RuntimeException
Unable to start activity
ComponentInfo{com.example.demo.androidAppdemo/com.google.android.gms.auth.api.signin.
internal.SignInHubActivity}: java.lang.NullPointerException

android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2118)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2145)
android.app.ActivityThread.access$600 (ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1211)
android.os.Handler.dispatchMessage (Handler.java:99)
android.os.Looper.loop (Looper.java:137)
android.app.ActivityThread.main (ActivityThread.java:4847)
java.lang.reflect.Method.invokeNative (Method.java)
java.lang.reflect.Method.invoke (Method.java:535)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:553)
dalvik.system.NativeStart.main (NativeStart.java)

Caused by java.lang.NullPointerException
com.google.android.gms.auth.api.signin.internal.SignInHubActivity.onCreate (Unknown Source:9)
android.app.Activity.performCreate (Activity.java:5187)
android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1104)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2064)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2145)
android.app.ActivityThread.access$600 (ActivityThread.java:130)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1211)
android.os.Handler.dispatchMessage (Handler.java:99)
android.os.Looper.loop (Looper.java:137)
android.app.ActivityThread.main (ActivityThread.java:4847)
java.lang.reflect.Method.invokeNative (Method.java)
java.lang.reflect.Method.invoke (Method.java:535)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:786)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:553)
dalvik.system.NativeStart.main (NativeStart.java)

Android: how to hide progress bar in facebook login

After click of the Facebook login button, a progress bar appears with transparent background and then the Facebook activity opens.  How to disable/hide the progress circle at start of the facebook login.
I used the facebook sdk gradle version as below
implementation 'com.facebook.android:facebook-login:[4,5)'

and defined the Facebook activity in AndroidManifest.xml as suggested in the article Edit Your Resources and Manifest

 <activity android:name="com.facebook.FacebookActivity"
        android:configChanges=
                "keyboard|keyboardHidden|screenLayout|screenSize|orientation"

        android:label="@string/app_name" />

To remove indeterminate progress bar I followed link Android: How to hide progress circle in Facebook login

Define a new custom style in your /res/values/styles.xml as below

    <style name="Translucent" parent="Translucent.Base"/>

    <style name="Translucent.Base" parent="android:Theme.Translucent.NoTitleBar">
        <item name="android:progressBarStyle">@style/InvisibleProgress</item>
    </style>

Add above custom style to Facebook activity deceleration in AndroidManifest.xml
<activity
            android:name="com.facebook.FacebookActivity"
            android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:label="@string/app_name"
            android:theme="@style/Translucent"
          />
Then try to run the Project
Gives error as below:
Manifest merger failed : Attribute activity#com.facebook.FacebookActivity@theme value=(@style/Translucent) from AndroidManifest.xml:294:13-47
is also present at [com.facebook.android:facebook-common:4.36.0] AndroidManifest.xml:32:13-63 value=(@style/com_facebook_activity_theme).
Suggestion: add 'tools:replace="android:theme"' to <activity> element at AndroidManifest.xml:290:9-295:15 to override.


tools:replace="android:theme"




Attempt to invoke virtual method 'void android.widget.ImageView.setImageDrawable' on a null object reference

java.lang.RuntimeException: Unable to destroy activity
{com.example.demo.androidAppdemo/com.example.demo.androidAppdemo.MainActivity}:
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageDrawable(android.graphics.drawable.Drawable)' on a null object reference
        at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3945)
        at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3963)
        at android.app.ActivityThread.access$1700(ActivityThread.java:151)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1454)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:157)
        at android.app.ActivityThread.main(ActivityThread.java:5604)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageDrawable(android.graphics.drawable.Drawable)' on a null object reference
        at com.example.demo.androidAppdemo.V2.NavigationDrawer.NavigationDrawerFragment$2.setResource(NavigationDrawerFragment.java:594)
        at com.example.demo.androidAppdemo.V2.NavigationDrawer.NavigationDrawerFragment$2.setResource(NavigationDrawerFragment.java:588)
        at com.bumptech.glide.request.target.ImageViewTarget.setResourceInternal(ImageViewTarget.java:127)
        at com.bumptech.glide.request.target.ImageViewTarget.onLoadCleared(ImageViewTarget.java:97)
        at com.bumptech.glide.request.SingleRequest.clear(SingleRequest.java:319)
        at com.bumptech.glide.manager.RequestTracker.clearRemoveAndMaybeRecycle(RequestTracker.java:79)
        at com.bumptech.glide.manager.RequestTracker.clearRemoveAndRecycle(RequestTracker.java:66)
        at com.bumptech.glide.RequestManager.untrack(RequestManager.java:603)
        at com.bumptech.glide.RequestManager.untrackOrDelegate(RequestManager.java:571)
        at com.bumptech.glide.RequestManager.clear(RequestManager.java:559)
        at com.bumptech.glide.RequestManager.onDestroy(RequestManager.java:303)
        at com.bumptech.glide.manager.ActivityFragmentLifecycle.onDestroy(ActivityFragmentLifecycle.java:65)
        at com.bumptech.glide.manager.SupportRequestManagerFragment.onDestroy(SupportRequestManagerFragment.java:194)
        at android.support.v4.app.Fragment.performDestroy(Fragment.java:2588)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1566)
        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1759)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1827)
        at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3244)
        at android.support.v4.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:3235)
        at android.support.v4.app.Fragment.performDestroy(Fragment.java:2583)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1566)
        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1759)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1827)
        at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3244)
        at android.support.v4.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:3235)
        at android.support.v4.app.FragmentController.dispatchDestroy(FragmentController.java:265)
        at android.support.v4.app.FragmentActivity.onDestroy(FragmentActivity.java:390)
        at android.support.v7.app.AppCompatActivity.onDestroy(AppCompatActivity.java:209)
        at com.example.demo.androidAppdemo.BaseActivity.onDestroy(BaseActivity.java:867)
        at com.example.demo.androidAppdemo.MainActivity.onDestroy(MainActivity.java:783)
        at android.app.Activity.performDestroy(Activity.java:6529)
    at android.app.Instrumentation.callActivityOnDestroy(

Above error thrown while closing app-BaseActivity is being destroyed. Getting this error while setting the Profile Photo of user in the navigation drawer fragment. This error is thrown when closing the app just after app starts. This error is being thrown in the below code while setting image using setImageDrawable after the converting the image to circular image using the RoundedBitmapDrawableFactory and using Glide V4.

 GlideApp.with(NavigationDrawerFragment.this).asBitmap().load(profilePhotoUrl).centerCrop().into(new BitmapImageViewTarget(navigation_header_splash_icon) {
                    @Override
                    protected void setResource(Bitmap resource) {
                        RoundedBitmapDrawable circularBitmapDrawable =
  RoundedBitmapDrawableFactory.create(NavigationDrawerFragment.this.getResources(),resource);
                        circularBitmapDrawable.setCircular(true);
//getting error in below line
                        navigation_header_splash_icon.setImageDrawable(circularBitmapDrawable);
                    }
                });

Replace the above
    GlideApp.with(NavigationDrawerFragment.this)
                        .asBitmap()
                        .load(profilePhotoUrl)
                        .diskCacheStrategy(DiskCacheStrategy.ALL)
                        .error(R.drawable.splash_icon)
                        .placeholder(R.drawable.splash_icon)
                        .transforms(new RoundedCorner( Application.get(),dpToPx(75/2), 1))
                        .into(navigation_header_splash_icon);

or Use glide V 4 library RequestOptions to crop the image to circular image
Glide.with(NavigationDrawerFragment.this)
        .load(profilePhotoUrl)
        .apply(RequestOptions.circleCropTransform())
        .into(navigation_header_splash_icon);

Glide v4: Glide treats LayoutParams.WRAP_CONTENT as a request for an image the size of this device's screen

10-13 12:56:00.395 2255-2255/com.example.demo.androidAppdemo
I/ViewTarget: Glide treats LayoutParams.WRAP_CONTENT as a request for
an image the size of this device's screen dimensions. If you want to load
the original image and are ok with the corresponding memory cost and OOMs
(depending on the input size), use .override(Target.SIZE_ORIGINAL).

Otherwise, use LayoutParams.MATCH_PARENT,
set layout_width and layout_height to fixed dimension,
or use .override() with fixed dimensions.

Popular Posts