我正在使用 FacebookSDK 开发应用程序,现在我正在将 Facebook 登录集成到我的应用程序中。我的问题是在我的集成活动初始化时出现 NoClassDefFoundError。
有logcat输出:
05-08 17:05:16.214:E/AndroidRuntime(23671):致命异常:主要 05-08 17:05:16.214:E/AndroidRuntime(23671):进程:com.tuntzme,PID:23671 05-08 17: 05:16.214: E/AndroidRuntime(23671): java.lang.NoClassDefFoundError: com.tuntzme.controller.fragments.IntegracaoFragment$1 05-08 17:05:16.214: E/AndroidRuntime(23671): 在 com.tuntzme.controller。 Fragments.IntegracaoFragment.(IntegracaoFragment.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): 在 android.app.Activity.performCreate(Activity.java:5248) 05-08 17:05:16.214: E/AndroidRuntime(23671): 在 android.app.Instrumentation。 callActivityOnCreate(Instrumentation.java:1110) 05-08 17:05:16.214: E/AndroidRuntime(23671): 在 android.app。ActivityThread.performLaunchActivity(ActivityThread.java:2173) 05-08 17:05:16.214: E/AndroidRuntime(23671): 在 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269) 05-08 17:05:16.214: E/AndroidRuntime(23671): 在 android.app.ActivityThread.access$800(ActivityThread.java:139) 05-08 17:05:16.214: E/AndroidRuntime(23671): 在 android.app.ActivityThread$H.handleMessage( ActivityThread.java:1210) 05-08 17:05:16.214: E/AndroidRuntime(23671): 在 android.os.Handler.dispatchMessage(Handler.java:102) 05-08 17:05:16.214: E/AndroidRuntime( 23671): 在 android.os.Looper.loop(Looper.java:136) 05-08 17:05:16.214: E/AndroidRuntime(23671): 在 android.app.ActivityThread.main(ActivityThread.java:5102) 05 -08 17:05:16.214: E/AndroidRuntime(23671): 在 java.lang.reflect.Method.invokeNative(Native Method) 05-08 17:05:16.214: E/AndroidRuntime(23671): 在 java.lang.reflect.Method.invoke(Method.java:515) 05-08 17:05:16.214: E/AndroidRuntime(23671): 在 com.android.internal.os .ZygoteInit$MethodAndArgsCaller.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):在 dalvik.system.NativeStart.main(本机方法)主要(本机方法)主要(本机方法)
这是我的活动:
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);
}
}
谢谢。