11-29 11:23:06.101: E/AndroidRuntime(301): at
com.mypackage.myapp.MainActivity.onCreate(MainActivity.java:41)
我通常看不到这一点,除非它是 Manifest 的问题或活动未正确初始化。唯一的问题是,它在 Manifest 中已初始化且正确、拼写、键入等。任何人都有任何其他想法,这可能是什么。
public class MainActivity extends FragmentActivity
{
public static Intent loginActivityIntent;
@Override
protected void onCreate(Bundle MainActivityState)
{
super.onCreate(MainActivityState);
setContentView(R.layout.activity_main);
Line41->loginActivityIntent = new Intent(this, LoginActivity.class);
}
}
AndroidManifest.xml
LoginActivity
<activity
android:name="com.mypackage.myapp.LoginActivity"
android:theme="@style/FullscreenTheme">
<action android:name="android.intent.action.LOGIN"/>
<category android:name="android.intent.category.DEFAULT"/>
</activity>
在这个 logcat 的顶部,它声明“无法解析 loginactivity 的超类。LoginActivity 来自 Facebook SDK,超类是 FacebookActivity,在编辑过程中它不会给我一个错误。
11-29 11:38:41.642: W/dalvikvm(330): Unable to resolve superclass of Lcom/limbones/profilelife/LoginActivity; (462)
11-29 11:38:41.683: W/dalvikvm(330): Link of class 'Lcom/limbones/profilelife/LoginActivity;' failed
11-29 11:38:41.683: W/dalvikvm(330): Unable to resolve superclass of Lcom/limbones/profilelife/PLLoginActivity; (471)
11-29 11:38:41.683: W/dalvikvm(330): Link of class 'Lcom/limbones/profilelife/PLLoginActivity;' failed
11-29 11:38:41.692: E/dalvikvm(330): Could not find class 'com.limbones.profilelife.PLLoginActivity', referenced from method com.limbones.profilelife.PLMainActivity.onCreate
11-29 11:38:41.692: W/dalvikvm(330): VFY: unable to resolve const-class 475 (Lcom/limbones/profilelife/PLLoginActivity;) in Lcom/limbones/profilelife/PLMainActivity;
11-29 11:38:41.692: D/dalvikvm(330): VFY: replacing opcode 0x1c at 0x000a
11-29 11:38:41.702: D/dalvikvm(330): VFY: dead code 0x000c-002b in Lcom/limbones/profilelife/PLMainActivity;.onCreate (Landroid/os/Bundle;)V
11-29 11:38:41.942: D/AndroidRuntime(330): Shutting down VM
11-29 11:38:41.942: W/dalvikvm(330): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
11-29 11:38:42.072: E/AndroidRuntime(330): FATAL EXCEPTION: main
11-29 11:38:42.072: E/AndroidRuntime(330): java.lang.NoClassDefFoundError: com.limbones.profilelife.PLLoginActivity
11-29 11:38:42.072: E/AndroidRuntime(330): at com.limbones.profilelife.PLMainActivity.onCreate(PLMainActivity.java:43)
11-29 11:38:42.072: E/AndroidRuntime(330): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-29 11:38:42.072: E/AndroidRuntime(330): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-29 11:38:42.072: E/AndroidRuntime(330): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-29 11:38:42.072: E/AndroidRuntime(330): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-29 11:38:42.072: E/AndroidRuntime(330): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-29 11:38:42.072: E/AndroidRuntime(330): at android.os.Handler.dispatchMessage(Handler.java:99)
11-29 11:38:42.072: E/AndroidRuntime(330): at android.os.Looper.loop(Looper.java:123)
11-29 11:38:42.072: E/AndroidRuntime(330): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-29 11:38:42.072: E/AndroidRuntime(330): at java.lang.reflect.Method.invokeNative(Native Method)
11-29 11:38:42.072: E/AndroidRuntime(330): at java.lang.reflect.Method.invoke(Method.java:521)
11-29 11:38:42.072: E/AndroidRuntime(330): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-29 11:38:42.072: E/AndroidRuntime(330): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-29 11:38:42.072: E/AndroidRuntime(330): at dalvik.system.NativeStart.main(Native Method)
11-29 11:38:44.592: I/Process(330): Sending signal. PID: 330 SIG: 9
更新:
这是我的清单中唯一不同的地方
<activity
android:name="com.facebook.LoginActivity"
android:label="">
<action android:name="android.intent.action.LOGINACTIVITY"/>
<category android:name="android.intent.category.DEFAULT"/>
</activity>
它链接到的活动只是称为 LoginActivity,我是否也应该包含前缀?
登录活动.java
package com.limbones.profilelife;
import android.os.Bundle;
import android.widget.TextView;
import com.facebook.FacebookActivity;
import com.facebook.Request;
import com.facebook.Response;
import com.facebook.SessionState;
import com.facebook.model.GraphUser;
public class LoginActivity extends FacebookActivity
{
public void onCreate(Bundle LoginActivity)
{
super.onCreate(LoginActivity);
setContentView(R.layout.facebook_login_activity);
this.openSession();
}
@Override
protected void onSessionStateChange(SessionState state, Exception exception)
{
if (state.isOpened())
{
@SuppressWarnings("unused")
Request request = Request.newMeRequest(
this.getSession(), new Request.GraphUserCallback()
{
@Override
public void onCompleted(GraphUser user, Response response)
{
if (user != null)
{
TextView welcome = (TextView) findViewById(R.id.facebookWelcome);
welcome.setText("Hello " + user.getName() + "!");
}
}
});
}
}
}
PLLoginActivity.Java
package com.limbones.profilelife;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
public class PLLoginActivity extends LoginActivity
{
public Intent registerActivityIntent;
public Intent notImplementedIntent;
public Intent facebookLoginIntent;
public void onCreate(Bundle LoginPage)
{
super.onCreate(LoginPage);
setContentView(R.layout.login_page);
registerActivityIntent = new Intent(this, PLRegisterActivity.class);
notImplementedIntent = new Intent(this, PLNotImplemented.class);
facebookLoginIntent = new Intent(this, LoginActivity.class);
}
public void backButton(View v)
{
finish();
}
public void registerButton(View v)
{
this.startActivity(registerActivityIntent);
}
public void loginButton(View v)
{
this.startActivity(notImplementedIntent);
}
public void fbLogin(View v)
{
this.startActivity(facebookLoginIntent);
}
}