我在我的应用程序中通过FbRocket jar实现Facebook,但它给出了一些错误,因为ClassNotFound,但我不知道为什么bcoz我有alredy在库中添加了jar ........ 请帮帮我。
05-09 19:04:28.933: ERROR/AndroidRuntime(759): FATAL EXCEPTION: main
05-09 19:04:28.933: ERROR/AndroidRuntime(759): java.lang.NoClassDefFoundError: net.xeomax.FBRocket.FBRocket
05-09 19:04:28.933: ERROR/AndroidRuntime(759): at org.shopzilla.android.moretab.SettingActivity.shareFacebook(SettingActivity.java:73)
05-09 19:04:28.933: ERROR/AndroidRuntime(759): at org.shopzilla.android.moretab.SettingActivity$2.onClick(SettingActivity.java:63)
05-09 19:04:28.933: ERROR/AndroidRuntime(759): at android.view.View.performClick(View.java:2485)
05-09 19:04:28.933: ERROR/AndroidRuntime(759): at android.view.View$PerformClick.run(View.java:9080)
05-09 19:04:28.933: ERROR/AndroidRuntime(759): at android.os.Handler.handleCallback(Handler.java:587)
05-09 19:04:28.933: ERROR/AndroidRuntime(759): at android.os.Handler.dispatchMessage(Handler.java:92)
05-09 19:04:28.933: ERROR/AndroidRuntime(759): at android.os.Looper.loop(Looper.java:123)
05-09 19:04:28.933: ERROR/AndroidRuntime(759): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-09 19:04:28.933: ERROR/AndroidRuntime(759): at java.lang.reflect.Method.invokeNative(Native Method)
05-09 19:04:28.933: ERROR/AndroidRuntime(759): at java.lang.reflect.Method.invoke(Method.java:507)
05-09 19:04:28.933: ERROR/AndroidRuntime(759): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-09 19:04:28.933: ERROR/AndroidRuntime(759): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-09 19:04:28.933: ERROR/AndroidRuntime(759): at dalvik.system.NativeStart.main(Native Method)
代码:
package org.shopzilla.android.moretab;
import java.util.List;
import net.xeomax.FBRocket.FBRocket;
import net.xeomax.FBRocket.Facebook;
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{
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(SettingActivity.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);
}
}
}
}
答案 0 :(得分:0)
尝试插入:
<uses-library android:name="net.xeomax.FBRocket.FBRocket" />
在清单文件中的应用程序标记内
答案 1 :(得分:0)
在项目文件夹中编辑.Classpath文件
在该文件中添加<classpathentry kind="src" path="<location of the lib>" />
。
答案 2 :(得分:0)
将文件夹“libs”添加到项目中(而不是“lib”)。然后将所有库放入此文件夹。又跑了。