gpt4 book ai didi

java - google play services 无法实例化 Activity ComponentInfo java.lang.ClassNotFoundException

转载 作者:行者123 更新时间:2023-12-01 13:45:38 25 4
gpt4 key购买 nike

在我导入 google play services 和 basegamesutils 之前,一切正常。现在应用程序崩溃了,在 logcat 中我可以看到:

    12-05 07:42:49.445: E/AndroidRuntime(6223): FATAL EXCEPTION: main
12-05 07:42:49.445: E/AndroidRuntime(6223): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.kubasienki.freefall/com.kubasienki.freefall.MainActivity}: java.lang.ClassNotFoundException: com.kubasienki.freefall.MainActivity
12-05 07:42:49.445: E/AndroidRuntime(6223): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2024)
12-05 07:42:49.445: E/AndroidRuntime(6223): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
12-05 07:42:49.445: E/AndroidRuntime(6223): at android.app.ActivityThread.access$600(ActivityThread.java:140)
12-05 07:42:49.445: E/AndroidRuntime(6223): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
12-05 07:42:49.445: E/AndroidRuntime(6223): at android.os.Handler.dispatchMessage(Handler.java:99)
12-05 07:42:49.445: E/AndroidRuntime(6223): at android.os.Looper.loop(Looper.java:137)
12-05 07:42:49.445: E/AndroidRuntime(6223): at android.app.ActivityThread.main(ActivityThread.java:4898)
12-05 07:42:49.445: E/AndroidRuntime(6223): at java.lang.reflect.Method.invokeNative(Native Method)
12-05 07:42:49.445: E/AndroidRuntime(6223): at java.lang.reflect.Method.invoke(Method.java:511)
12-05 07:42:49.445: E/AndroidRuntime(6223): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
12-05 07:42:49.445: E/AndroidRuntime(6223): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
12-05 07:42:49.445: E/AndroidRuntime(6223): at dalvik.system.NativeStart.main(Native Method)
12-05 07:42:49.445: E/AndroidRuntime(6223): Caused by: java.lang.ClassNotFoundException: com.kubasienki.freefall.MainActivity
12-05 07:42:49.445: E/AndroidRuntime(6223): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
12-05 07:42:49.445: E/AndroidRuntime(6223): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
12-05 07:42:49.445: E/AndroidRuntime(6223): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-05 07:42:49.445: E/AndroidRuntime(6223): at android.app.Instrumentation.newActivity(Instrumentation.java:1057)
12-05 07:42:49.445: E/AndroidRuntime(6223): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2015)
12-05 07:42:49.445: E/AndroidRuntime(6223): ... 11 more

我的MainActivity.java:

package com.kubasienki.freefall;

import com.google.example.games.basegameutils.BaseGameActivity;
import com.kubasienki.freefall.R;
import android.os.Bundle;
import android.content.Intent;
import android.view.View;
import android.widget.Button;

public class MainActivity extends BaseGameActivity
implements View.OnClickListener {





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

// final Button button = (Button) findViewById(R.id.start);
// button.setOnClickListener(new View.OnClickListener() {
//@Override
//public void onClick(View v) {
// Intent intent = new Intent(MainActivity.this, Fall.class);

// startActivity(intent);

// }
// });

//final Button button1 = (Button) findViewById(R.id.howto);
// button1.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Intent intent1 = new Intent(MainActivity.this, HowTo.class);
//
// startActivity(intent1);

// }
// });
findViewById(R.id.sign_in_button).setOnClickListener(this);
findViewById(R.id.sign_out_button).setOnClickListener(this);
findViewById(R.id.howto).setOnClickListener(this);
findViewById(R.id.start).setOnClickListener(this);



}

@Override
public void onSignInFailed() {
findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
findViewById(R.id.sign_out_button).setVisibility(View.GONE);


}

@Override
public void onSignInSucceeded() {
findViewById(R.id.sign_in_button).setVisibility(View.GONE);
findViewById(R.id.sign_out_button).setVisibility(View.VISIBLE);


}

@Override
public void onClick(View view) {
if (view.getId() == R.id.sign_in_button) {
// start the asynchronous sign in flow
beginUserInitiatedSignIn();
}
else if (view.getId() == R.id.sign_out_button) {
// sign out.
signOut();

// show sign-in button, hide the sign-out button
findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
findViewById(R.id.sign_out_button).setVisibility(View.GONE);
}
else if(view.getId() == R.id.howto){
Intent intent1 = new Intent(MainActivity.this, HowTo.class);

startActivity(intent1);
}
else if(view.getId() == R.id.start){
Intent intent = new Intent(MainActivity.this, Fall.class);

startActivity(intent);}
}

//@Override
//public boolean onCreateOptionsMenu(Menu menu) {
// // Inflate the menu; this adds items to the action bar if it is present.
// getMenuInflater().inflate(R.menu.main, menu);
// return true;
//}

}

和 list :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kubasienki.freefall"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

<activity
android:name="com.kubasienki.freefall.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.kubasienki.freefall.Fall"
android:label="@string/app_name"
android:parentActivityName="com.kubasienki.freefall.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.kubasienki.freefall.MainActivity" />
</activity>
<activity
android:name="com.kubasienki.freefall.HowTo"
android:label="@string/app_name"
android:parentActivityName="com.kubasienki.freefall.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.kubasienki.freefall.MainActivity" />
</activity>
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="@string/app_id" />
</application>

</manifest>

我检查过的内容:

  1. 导入了 google-play-services_lib 和 BaseGameUtils
  2. 检查构建路径

最佳答案

对我有帮助的是:1.教程中是在ids.xml中注册app_id,然后使用app_id形式文件strings.xml。2.我添加了:

<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />

到Manifest.xml

关于java - google play services 无法实例化 Activity ComponentInfo java.lang.ClassNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20393528/

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