由于这行代码,我得到了 NoClassDefFoundError:
adapter = new SocialAuthAdapter(new ResponseListener());
我认为这可能是我的 ResponseListener() 方法的问题,但我找不到任何问题。这是代码:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Adapter initialization
adapter = new SocialAuthAdapter(new ResponseListener());
listview = (ListView) findViewById(R.id.listview);
listview.setAdapter(new CustomAdapter(this, adapter));
// Welcome Message
TextView textview = (TextView) findViewById(R.id.text);
textview.setText("Use SocialAuth by creating your own UI.");
textview.setTextColor(Color.WHITE);
textview.setGravity(Gravity.CENTER);
textview.setPadding(0, 30, 0, 0);
}
// To receive the response after authentication
private final class ResponseListener implements DialogListener {
@Override
public void onComplete(Bundle values) {
Log.d("Custom-UI", "Successful");
// Changing Sign In Text to Sign Out
// Code to refresh Single ListView Item : You can remove it for your
// app
View v = listview.getChildAt(pos
- listview.getFirstVisiblePosition());
TextView pText = (TextView) v.findViewById(R.id.signstatus);
pText.setText("Sign Out");
// Get the provider
final String providerName = values
.getString(SocialAuthAdapter.PROVIDER);
Log.d("Custom-UI", "providername = " + providerName);
int res = getResources().getIdentifier(providerName + "_array",
"array", CustomUI.this.getPackageName());
AlertDialog.Builder builder = new AlertDialog.Builder(CustomUI.this);
builder.setTitle("Select Options");
builder.setCancelable(true);
builder.setIcon(android.R.drawable.ic_menu_more);
builder.setSingleChoiceItems(new ArrayAdapter<String>(
CustomUI.this, R.layout.provider_options, getResources()
.getStringArray(res)), 0,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int item) {
Events(item, providerName);
}
});
dialog = builder.create();
dialog.show();
}
@Override
public void onError(SocialAuthError error) {
Log.d("Custom-UI", "Error");
error.printStackTrace();
}
@Override
public void onCancel() {
Log.d("Custom-UI", "Cancelled");
}
@Override
public void onBack() {
Log.d("Custom-UI", "Dialog Closed by pressing Back Key");
}
}
这是Logcat:
02-20 16:21:44.562: E/AndroidRuntime(932): FATAL EXCEPTION: main
02-20 16:21:44.562: E/AndroidRuntime(932): java.lang.NoClassDefFoundError: org.brickred.socialauth.android.SocialAuthAdapter
02-20 16:21:44.562: E/AndroidRuntime(932): at com.socialauth.customui.CustomUI.onCreate(CustomUI.java:70)
02-20 16:21:44.562: E/AndroidRuntime(932): at android.app.Activity.performCreate(Activity.java:5104)
02-20 16:21:44.562: E/AndroidRuntime(932): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
02-20 16:21:44.562: E/AndroidRuntime(932): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
02-20 16:21:44.562: E/AndroidRuntime(932): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
02-20 16:21:44.562: E/AndroidRuntime(932): at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-20 16:21:44.562: E/AndroidRuntime(932): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
02-20 16:21:44.562: E/AndroidRuntime(932): at android.os.Handler.dispatchMessage(Handler.java:99)
02-20 16:21:44.562: E/AndroidRuntime(932): at android.os.Looper.loop(Looper.java:137)
02-20 16:21:44.562: E/AndroidRuntime(932): at android.app.ActivityThread.main(ActivityThread.java:5039)
02-20 16:21:44.562: E/AndroidRuntime(932): at java.lang.reflect.Method.invokeNative(Native Method)
02-20 16:21:44.562: E/AndroidRuntime(932): at java.lang.reflect.Method.invoke(Method.java:511)
02-20 16:21:44.562: E/AndroidRuntime(932): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-20 16:21:44.562: E/AndroidRuntime(932): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-20 16:21:44.562: E/AndroidRuntime(932): at dalvik.system.NativeStart.main(Native Method)
任何帮助将不胜感激。