无法获得广告ID:java.lang.NullPointerException:尝试在空对象引用上读取字段'java.lang.String com.google.android.gms.ads.identifier.da':ufv.a( :com.google.android.gms:3134)
我搜索了Stack Overflow和谷歌的解决方案,但没有运气;以及上面的错误我也得到了相同的错误 Android Studio: Attempt to setOnClickListener on a null object reference,但解决方案没有帮助,而且这个错误似乎要来了。
我正在尝试按照YouTube上的教程实施Google登录,但我已完成所有相同操作,但我的应用程序在启动时关闭。
我认为错误与代码的这一行有关,但我不确定。
findViewById(R.id.sign_in_button).setOnClickListener(this);
以下是代码的其余部分。
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);
和sign_in_button的xml是:
<com.google.android.gms.common.SignInButton
android:id="@+id/sign_in_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
这是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