Unable to get advertising id: java.lang.NullPointerException: Attempt to read from field 'java.lang.String com.google.android.gms.ads.identifier.d.a' on a null object reference: ufv.a(:com.google.android.gms:3134)
I have searched Stack Overflow and Google for a solution but no luck; as well as the error above I was also getting the same error as Android Studio: Attempt to setOnClickListener on a null object reference, but the solution did not help and that error seems to come and go.
I am trying to implement sign in with Google following a tutorial on YouTube, I have done everything the same however my app closes on launch.
I think the error is related to this line of the code, but I am not sure.
findViewById(R.id.sign_in_button).setOnClickListener(this);
Below is the rest of the code.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_instructors);
mAuth = FirebaseAuth.getInstance();
mAuthListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if(user != null)
Log.d ("AUTH", "user Logged in: " + user.getEmail());
else
Log.d("AUTH", "user logged out.");
}};
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
findViewById(R.id.sign_in_button).setOnClickListener(this);
and the xml for the sign_in_button is:
<com.google.android.gms.common.SignInButton
android:id="@+id/sign_in_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
This is the logcat:
01-16 23:02:49.226 1757-24616/com.actionlauncher.playstore V/FA: Activity paused, time: 35229566
01-16 23:02:50.236 1757-24616/com.actionlauncher.playstore D/FA: Application backgrounded. Logging engagement
01-16 23:02:50.238 1757-24616/com.actionlauncher.playstore D/FA: Logging event (FE): _e, Bundle[{_o=auto, _et=293642}]
01-16 23:02:50.239 1757-24616/com.actionlauncher.playstore V/FA: Using measurement service
01-16 23:02:50.239 1757-24616/com.actionlauncher.playstore V/FA: Connecting to remote service
01-16 23:02:50.254 1757-24616/com.actionlauncher.playstore D/FA: Connected to remote service
01-16 23:02:50.254 1757-24616/com.actionlauncher.playstore V/FA: Processing queued up service tasks: 1
01-16 23:02:50.261 1811-24637/com.google.android.gms V/FA-SVC: Logging event: origin=auto,name=_e,params=Bundle[mParcelledData.dataSize=60]
01-16 23:02:50.271 1811-24637/com.google.android.gms D/FA-SVC: Unable to get advertising id: java.lang.NullPointerException: Attempt to read from field 'java.lang.String com.google.android.gms.ads.identifier.d.a' on a null object reference: ufv.a(:com.google.android.gms:3134)
01-16 23:02:50.289 1811-24637/com.google.android.gms V/FA-SVC: Saving event, name, data size: _e, 30
01-16 23:02:50.290 1811-24637/com.google.android.gms V/FA-SVC: Event recorded: Event{appId='com.actionlauncher.playstore', name='_e', params=Bundle[{_o=auto, _et=293642}]}
01-16 23:02:50.310 1811-24637/com.google.android.gms V/FA-SVC: Upload scheduled in approximately ms: 1956907
01-16 23:02:50.317 1811-24637/com.google.android.gms V/FA-SVC: Background event processing time, ms: 56
01-16 23:02:55.263 1757-24616/com.actionlauncher.playstore V/FA: Inactivity, disconnecting from AppMeasurementService
01-16 23:03:59.719 1757-25003/com.actionlauncher.playstore V/FA: Activity resumed, time: 35300060
01-16 23:04:05.460 1757-25003/com.actionlauncher.playstore V/FA: Activity paused, time: 35305801
01-16 23:04:06.462 1757-25003/com.actionlauncher.playstore D/FA: Application backgrounded. Logging engagement
01-16 23:04:06.466 1757-25003/com.actionlauncher.playstore D/FA: Logging event (FE): _e, Bundle[{_o=auto, _et=5741}]
01-16 23:04:06.466 1757-25003/com.actionlauncher.playstore V/FA: Using measurement service
01-16 23:04:06.466 1757-25003/com.actionlauncher.playstore V/FA: Connecting to remote service
01-16 23:04:06.474 1757-25003/com.actionlauncher.playstore D/FA: Connected to remote service
01-16 23:04:06.474 1757-25003/com.actionlauncher.playstore V/FA: Processing queued up service tasks: 1
01-16 23:04:06.478 1811-25093/com.google.android.gms V/FA-SVC: Logging event: origin=auto,name=_e,params=Bundle[mParcelledData.dataSize=60]
01-16 23:04:06.483 1811-25093/com.google.android.gms D/FA-SVC: Unable to get advertising id: java.lang.NullPointerException: Attempt to read from field 'java.lang.String com.google.android.gms.ads.identifier.d.a' on a null object reference: ufv.a(:com.google.android.gms:3134)
01-16 23:04:06.490 1811-25093/com.google.android.gms V/FA-SVC: Saving event, name, data size: _e, 29
01-16 23:04:06.490 1811-25093/com.google.android.gms V/FA-SVC: Event recorded: Event{appId='com.actionlauncher.playstore', name='_e', params=Bundle[{_o=auto, _et=5741}]}
01-16 23:04:06.529 1811-25093/com.google.android.gms V/FA-SVC: Upload scheduled in approximately ms: 1880688
01-16 23:04:06.532 1811-25093/com.google.android.gms V/FA-SVC: Background event processing time, ms: 54