gpt4 book ai didi

Android 在 GooglePlayServices(游戏)连接上崩溃

转载 作者:行者123 更新时间:2023-11-29 01:21:48 24 4
gpt4 key购买 nike

我在解决这个问题大约 10 小时,我不知道我做错了什么....

致命异常:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: onl.deepspace.zoorallye, PID: 13256
java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information.
at com.google.android.gms.common.internal.zzj$zza.zzc(Unknown Source)
at com.google.android.gms.common.internal.zzj$zza.zzw(Unknown Source)
at com.google.android.gms.common.internal.zzj$zzc.zzqN(Unknown Source)
at com.google.android.gms.common.internal.zzj$zzb.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5569)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:931)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:726)

Log 没有提供任何重要信息


我环顾谷歌,我可以修复一些错误。但是应用总是在这里崩溃:

achievements.googleApiClient.connect();

MainActivity(重要部分):

Achievements achievements;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

...

//Init Achievements
achievements = new Achievements(this);
achievements.googleApiClient.connect(); //**AppCrash**
}

@Override
protected void onStart() {
super.onStart();
}

@Override
protected void onStop() {
super.onStop();
achievements.googleApiClient.disconnect();
}

成就.java:

public class Achievements implements GoogleApiClient.OnConnectionFailedListener, GoogleApiClient.ConnectionCallbacks{

public GoogleApiClient googleApiClient;
private Activity activity;

public Achievements(Activity activity){
this.activity = activity;

googleApiClient = new GoogleApiClient.Builder(activity)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Games.API)
.addScope(Games.SCOPE_GAMES)
.build();
}

private void signIn(GoogleApiClient signinClient) {
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(signinClient);
activity.startActivityForResult(signInIntent, 0);
}

@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
if(connectionResult.getErrorCode() == ConnectionResult.SIGN_IN_REQUIRED){
signIn(Tools.getSigninClient(activity));
}
Toast.makeText(activity, connectionResult.getErrorMessage(), Toast.LENGTH_SHORT).show();
Log.e(Const.LOGTAG, connectionResult.getErrorMessage());
}

@Override
public void onConnected(@Nullable Bundle bundle) {
Log.i(Const.LOGTAG, "Play Service (Games) Connected");
}

@Override
public void onConnectionSuspended(int i) {
}
}

AndroidManifest.xml:

     <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="onl.deepspace.zoorallye">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application
android:allowBackup="true"
android:icon="@mipmap/appicon"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.Drawer"></activity>

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.gms.games.onl.deepspace.zoorallye"
android:value="@string/google_app_id" />

</application>

最佳答案

在社区中寻找类似的帖子,发现了这个 answer , 一探究竟。开门见山,我认为这个问题的原因在于你的AndroidManifest.xml .如答案中所述,<meta-data>应该添加标签,你的在那里,但名称不同。它显示为:

android:name="com.google.android.gms.games.onl.deepspace.zoorallye"

在上面的答案中,它显示:

android:name="com.google.android.gms.games.APP_ID"

去了Google Quickstart samples并注意所有的标签都像上面那样。在您的代码中没有发现任何导致问题的其他内容。

关于Android 在 GooglePlayServices(游戏)连接上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36391556/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com