我正在使用Facebook sdk开发一个应用程序,现在我正在将Facebook登录集成到我的应用程序中。我的问题是在我的集成活动初始化时出现NoClassDefFoundError。
有logcat输出:
05-08 17:05:16.214: E/AndroidRuntime(23671): FATAL EXCEPTION: main05-08 17:05:16.214: E/AndroidRuntime(23671): Process: com。tuntzme, PID: 2367105-08 17:05:16.214: E/AndroidRuntime(23671): java.lang.NoClassDefFoundError: com.tuntzme.controller.fragments. integracaoffragment $105-08 17:05:16.214: E/AndroidRuntime(23671): at com.tuntzme.controller.fragments. integracaoffragment .(integracaoffragment .java:24)05-08 17:05:16.214: E/AndroidRuntime(23671): at com.tuntzme.controller.activities.ActivityIntegracao.onCreate(ActivityIntegracao.java:21)05-08 17:05:16.214: E/AndroidRuntime(23671): at android.app.Activity.performCreate(Activity.java:5248)05-08 17:05:16.214: E/AndroidRuntime(23671): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)05-08 17:05:16.214: E/AndroidRuntime(23671): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2173)05-08 17:05:16.214: E/AndroidRuntime(23671): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)05-08 17:05:16.214: E/AndroidRuntime(23671): at android.app.ActivityThread.access$800(ActivityThread.java:139)05-08 17:05:16.214: E/AndroidRuntime(23671): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)05-08 17:05:16.214: E/AndroidRuntime(23671): at android.os.Handler.dispatchMessage(Handler.java:102)05-08 17:05:16.214: E/AndroidRuntime(23671): at android.os. loop .loop(loop .java:136)05-08 17:05:16.214: E/AndroidRuntime(23671): at android.app.ActivityThread.main(ActivityThread.java:5102)05-08 17:05:16.214: E/AndroidRuntime(23671): at java.lang.reflect.Method。invokeNative(本地方法)05-08 17:05:16.214: E/AndroidRuntime(23671): at java.lang.reflect.Method.invoke(Method.java:515)05-08 17:05:16.214: E/AndroidRuntime(23671): at com.android.internal.os.ZygoteInit$ methodandargscaler .run(ZygoteInit.java:785)05-08 17:05:16.214: E/AndroidRuntime(23671): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)05-08 17:05:16.214: E/AndroidRuntime(23671): at dalvik.system. native . art. exe主要(本地方法)
这是我的活动:
public class ActivityIntegracao extends ActionBarActivity {
private IntegracaoFragment integracaoFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_integracao);
if (savedInstanceState == null) {
integracaoFragment = new IntegracaoFragment();
getSupportFragmentManager().beginTransaction().add(R.id.container, integracaoFragment).commit();
} else {
integracaoFragment = (IntegracaoFragment) getSupportFragmentManager()
.findFragmentById(R.id.container);
}
}
public static class IntegracaoFragment extends Fragment {
private static final String TAG = "IntegracaoFragment";
private LoginButton loginButton;
private UiLifecycleHelper uiHelper;
private Session.StatusCallback callback = new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
onSessionStateChange(session, state, exception);
}
};
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
uiHelper = new UiLifecycleHelper(getActivity(), callback);
uiHelper.onCreate(savedInstanceState);
};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_integracao, container, false);
LoginButton authButton = (LoginButton) rootView.findViewById(R.id.authButton);
authButton.setFragment(this);
TuntzMeApplication.instance().setFacebookLoginButton(authButton);
return rootView;
}
@Override
public void onResume() {
super.onResume();
Session session = Session.getActiveSession();
if (session != null &&
(session.isOpened() || session.isClosed()) ) {
onSessionStateChange(session, session.getState(), null);
}
uiHelper.onResume();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
uiHelper.onActivityResult(requestCode, resultCode, data);
}
@Override
public void onPause() {
super.onPause();
uiHelper.onPause();
}
@Override
public void onDestroy() {
super.onDestroy();
uiHelper.onDestroy();
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
uiHelper.onSaveInstanceState(outState);
}
private void onSessionStateChange(Session session, SessionState state, Exception exception) {
if (state.isOpened()) {
// Abrir activity map
Log.i(TAG, "Logged in...");
} else if (state.isClosed()) {
Log.i(TAG, "Logged out...");
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_sincronizacao, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
谢谢。
我已经解决了这个问题,问题是我的构建补丁,似乎我不小心手动添加FacebookSDK到Java BuildPath,这是导致问题的原因。谢谢大家