我有一個應用程序,我想添加Google Play成就。我也跟着這樣的:應用程序在googleApiClient.connect()上崩潰;
https://developers.google.com/games/services/android/init
我有這個在我的清單(用正確的ID):
<meta-data android:name="com.google.android.gms.appstate.APP_ID"
android:value="000000000000" />
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="000000000000" />
我有這樣的OnStart:
@Override
protected void onStart() {
try
{
super.onStart();
googleApiClient.connect();
}catch (Exception e)
{
Exception error;
error = e;
}
}
隨着調試運行,當「.connect()」被執行,它崩潰,並且「TRY CATCH」沒有檢測到它。 這是我的「OnCreate()」。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
googleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Games.API).addScope(Games.SCOPE_GAMES)
// add other APIs and scopes here as needed
.build();
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
lanzarFragments();
}
這是怎麼了我的 「MainActivity」 聲明:
public class MainActivity extends AppCompatActivity implements
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener
我GoogleApiClient,被宣告就像我在這裏展示:
public static GoogleApiClient googleApiClient;
我想補充一點的方法「 lanzarFragments()「,啓動一個片段。我的所有應用程序都帶有碎片,互相更換。但我只有一個Activity,Main,它有我寫的「OnCreate()」。
有關它崩潰的一些想法以及如何解決它?謝謝。
嘗試在'catch'塊中添加'e.printStackTrace();'。然後將日誌添加到您的問題。 – ZeekHuge
我之前做過的嘗試是放置一個斷點。出於這個原因,我知道這個過程不會進入catch塊。我做了你所說的,但我不知道在日誌上找到執行。我必須寫很多文字。我正在看「Android監視器」,「詳細」模式,「僅顯示選定的應用程序」。 –