I am implementing twitter and facebook in my app, but the activity returns error as NoClassFoundError on SettingActivity but my activity is already in manifest, what should be the reason? Please help me out.
Error:
05-09 19:32:42.485: ERROR/AndroidRuntime(903): java.lang.NoClassDefFoundError: org.shopzilla.android.moretab.SettingActivity
05-09 19:32:42.485: ERROR/AndroidRuntime(903): at org.shopzilla.android.moretab.More$1.onClick(More.java:46)
05-09 19:32:42.485: ERROR/AndroidRuntime(903): at android.view.View.performClick(View.java:2485)
05-09 19:32:42.485: ERROR/AndroidRuntime(903): at android.view.View$PerformClick.run(View.java:9080)
05-09 19:32:42.485: ERROR/AndroidRuntime(903): at android.os.Handler.handleCallback(Handler.java:587)
05-09 19:32:42.485: ERROR/AndroidRuntime(903): at android.os.Handler.dispatchMessage(Handler.java:92)
05-09 19:32:42.485: ERROR/AndroidRuntime(903): at android.os.Looper.loop(Looper.java:123)
05-09 19:32:42.485: ERROR/AndroidRuntime(903): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-09 19:32:42.485: ERROR/AndroidRuntime(903): at java.lang.reflect.Method.invokeNative(Native Method)
05-09 19:32:42.485: ERROR/AndroidRuntime(903): at java.lang.reflect.Method.invoke(Method.java:507)
05-09 19:32:42.485: ERROR/AndroidRuntime(903): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-09 19:32:42.485: ERROR/AndroidRuntime(903): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-09 19:32:42.485: ERROR/AndroidRuntime(903): at dalvik.system.NativeStart.main(Native Method)
Code:
package org.shopzilla.android.moretab;
import java.util.List;
import net.xeomax.FBRocket.FBRocket;
import net.xeomax.FBRocket.Facebook;
import net.xeomax.FBRocket.LoginListener;
import net.xeomax.FBRocket.ServerErrorException;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.shopzilla.android.common.R;
import org.shopzilla.android.facebook.FacebookActivity;
import org.shopzilla.android.facebook.FacebookWebOAuthActivity;
import org.shopzilla.android.twitter.TwitterActivity;
import org.shopzilla.android.twitter.TwitterWebOAuthActivity;
import twitter4j.http.RequestToken;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class SettingActivity extends Activity implements LoginListener{
String bytesSent;
HttpClient httpclient;
int count1;
// List with parameters and their values
List<NameValuePair> nameValuePairs;
TextView mText;
Button btn_facebook;
Button btn_twitter;
FBRocket fbRocket;
RequestToken rToken;
String oauthVerifier;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.more_setting);
Button btn_twitter = (Button)findViewById(R.id.btn_more_setting_twitter);
Button btn_facebook = (Button)findViewById(R.id.btn_More_setting_facebook);
btn_twitter.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent(SettingActi开发者_运维技巧vity.this,TwitterActivity.class);
startActivity(intent);
//displayTwitterAuthorization();
}
});
btn_facebook.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
/*Intent intent = new Intent(SettingActivity.this,FacebookActivity.class);
startActivity(intent);*/
shareFacebook();
//displayFacebookAuthorization();
//shareFacebook();
}
});
}
public void shareFacebook() {
fbRocket = new FBRocket(SettingActivity.this, "ShopZilla",
"172619129456913");
if (fbRocket.existsSavedFacebook()) {
fbRocket.loadFacebook();
} else {
fbRocket.login(R.layout.facebook);
}
}
public void onLoginFail() {
fbRocket.displayToast("Login failed!");
fbRocket.login(R.layout.facebook);
}
public void onLoginSuccess(Facebook facebook) {
// TODO Auto-generated method stub
fbRocket.displayToast("Login success!");
try {
facebook.setStatus("This is your status");
fbRocket.displayDialog("Status Posted Successfully!! "
+ facebook.getStatus());
} catch (ServerErrorException e) {
if (e.notLoggedIn()) {
fbRocket.login(R.layout.facebook);
} else {
System.out.println(e);
}
}
}
}
Make sure you add to the manifest file each activity that you fire:
<activity android:name="org.shopzilla.android.moretab.SettingActivity" />
Try add folder "libs" (and not "lib") to the project. Then add all twitter's library to this folder and run again.
精彩评论