我是一名新的Android程序员,我真的不明白如何解决我的问题。 我的应用名称是musteatandgo。我在我的模拟器上安装了musteatandgo.apk,有时eclipse找不到设备,有时我可以在模拟器上看到“应用程序未安装”或“应用程序(进程com.musteatandgo)已意外停止。
12-01 14:25:48.338: D/AndroidRuntime(284): Shutting down VM
12-01 14:25:48.348: W/dalvikvm(284): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
12-01 14:25:48.368: E/AndroidRuntime(284): FATAL EXCEPTION: main
12-01 14:25:48.368: E/AndroidRuntime(284): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.musteatandgo/com.musteatandgo.MainActivity}: java.lang.NullPointerException: Argument 'applicationId' cannot be null
12-01 14:25:48.368: E/AndroidRuntime(284): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.musteatandgo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.musteatandgo.MainActivity$start"
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= ".Main">
</activity>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="1390160477887243"/>
<activity android:name="com.facebook.LoginActivity" android:label="MustEatandGo"></activity>
</application>
</manifest>
主要活动
package com.musteatandgo;
import android.os.Bundle;
import android.app.Activity;
import com.facebook.*;
import com.facebook.model.*;
import android.widget.TextView;
import android.content.Intent;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// start Facebook Login
Session.openActiveSession(this, true, new Session.StatusCallback() {
// callback when session changes state
@Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
// make request to the /me API
Request.newMeRequest(session, new Request.GraphUserCallback() {
// callback after Graph API response with user object
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
TextView welcome = (TextView) findViewById(R.id.welcome);
welcome.setText("Hello " + user.getName() + "!");
}
}
});
}
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
}
答案 0 :(得分:1)
将您的清单com.musteatandgo.MainActivity$start
更改为.MainActivity