gpt4 book ai didi

android - makeGooglePlayServicesAvailable 在带有 Android Studio 的真实设备上崩溃的应用程序

转载 作者:太空狗 更新时间:2023-10-29 13:54:17 26 4
gpt4 key购买 nike

我在真实设备上的 Android 4.2.2 上运行 makeGooglePlayServicesAvailable,它只是崩溃并显示下面的堆栈跟踪。我不知道这是 makeGooglePlayServicesAvailable 问题还是错误消息中的其他问题?同样的代码在具有更高 Android 操作系统的模拟器上运行良好。

public class EventsActivity extends BaseActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);


GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();

int success = googleApiAvailability.isGooglePlayServicesAvailable(this);

if(success != ConnectionResult.SUCCESS)
{
googleApiAvailability.makeGooglePlayServicesAvailable(this);
}

super.onCreate(savedInstanceState);
setContentView(R.layout.drawer);
}

错误

Process: com.exposure, PID: 5713
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.EventsActivity}: java.lang.IllegalStateException: Activity has been destroyed
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2334)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
at android.app.ActivityThread.access$900(ActivityThread.java:169)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5487)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: Activity has been destroyed
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1560)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:696)
at android.support.v4.app.BackStackRecord.commitAllowingStateLoss(BackStackRecord.java:667)
at com.google.android.gms.internal.zzabm.zza(Unknown Source)
at com.google.android.gms.internal.zzaaw.zzc(Unknown Source)
at com.google.android.gms.internal.zzaaw.zzs(Unknown Source)
at com.google.android.gms.internal.zzabb.zzu(Unknown Source)
at com.google.android.gms.common.GoogleApiAvailability.makeGooglePlayServicesAvailable(Unknown Source)

最佳答案

super.onCreate() 之后调用它解决了问题。

关于android - makeGooglePlayServicesAvailable 在带有 Android Studio 的真实设备上崩溃的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41404565/

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