私は Android アプリを持っており、モバイル アプリのインストール数を統計に表示する必要があったため、Facebook SDK を 3.0 にアップグレードしました...
その後、壁への投稿機能が機能しなくなりました
私のLogCATの結果は次のとおりです。
02-06 03:49:38.893: D/dalvikvm(3226): GC_FOR_MALLOC freed 42K, 46% free 3004K/5511K, external 13906K/15688K, paused 19ms
02-06 03:49:42.396: D/dalvikvm(3226): GC_CONCURRENT freed 1281K, 51% free 3697K/7495K, external 13906K/15688K, paused 2ms+2ms
02-06 03:50:05.309: W/dalvikvm(3226): VFY: unable to resolve static field 1967 (com_facebook_login_activity_layout) in Lcom/facebook/android/R$layout;
02-06 03:50:05.309: D/dalvikvm(3226): VFY: replacing opcode 0x60 at 0x0003
02-06 03:50:05.319: D/dalvikvm(3226): VFY: dead code 0x0005-0051 in Lcom/facebook/LoginActivity;.onCreate (Landroid/os/Bundle;)V
02-06 03:50:05.319: W/dalvikvm(3226): VFY: unable to resolve static field 1949 (com_facebook_login_activity_progress_bar) in Lcom/facebook/android/R$id;
02-06 03:50:05.319: D/dalvikvm(3226): VFY: replacing opcode 0x60 at 0x0008
02-06 03:50:05.319: D/dalvikvm(3226): VFY: dead code 0x000a-0013 in Lcom/facebook/LoginActivity;.onPause ()V
02-06 03:50:05.419: W/dalvikvm(3226): VFY: unable to resolve static field 1976 (com_facebook_internet_permission_error_title) in Lcom/facebook/android/R$string;
02-06 03:50:05.419: D/dalvikvm(3226): VFY: replacing opcode 0x60 at 0x0010
02-06 03:50:05.419: D/dalvikvm(3226): VFY: dead code 0x0012-0026 in Lcom/facebook/AuthorizationClient;.checkInternetPermission ()Z
02-06 03:50:05.439: D/Database(3226): dbopen(): path = /data/data/com.antmoves.stardome/databases/webview.db, flag = 6, cannot stat file, error message: No such file or directory
02-06 03:50:05.439: D/Database(3226): dbopen(): path = /data/data/com.antmoves.stardome/databases/webview.db, mode: delete, disk free size: 45 M, handle: 0x48fa38
02-06 03:50:05.499: D/Database(3226): dbopen(): path = /data/data/com.antmoves.stardome/databases/webviewCache.db, flag = 6, cannot stat file, error message: No such file or directory
02-06 03:50:05.509: D/Database(3226): dbopen(): path = /data/data/com.antmoves.stardome/databases/webviewCache.db, mode: delete, disk free size: 45 M, handle: 0x492808
02-06 03:50:05.599: W/dalvikvm(3226): VFY: unable to resolve static field 1943 (com_facebook_close) in Lcom/facebook/android/R$drawable;
02-06 03:50:05.599: D/dalvikvm(3226): VFY: replacing opcode 0x60 at 0x001d
02-06 03:50:05.599: D/dalvikvm(3226): VFY: dead code 0x001f-002e in Lcom/facebook/widget/WebDialog;.createCrossImage ()V
02-06 03:50:05.599: W/dalvikvm(3226): VFY: unable to resolve static field 1977 (com_facebook_loading) in Lcom/facebook/android/R$string;
02-06 03:50:05.599: D/dalvikvm(3226): VFY: replacing opcode 0x60 at 0x0024
02-06 03:50:05.599: D/dalvikvm(3226): VFY: dead code 0x0026-006d in Lcom/facebook/widget/WebDialog;.onCreate (Landroid/os/Bundle;)V
02-06 03:50:19.473: D/AndroidRuntime(3226): Shutting down VM
02-06 03:50:19.473: W/dalvikvm(3226): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0)
02-06 03:50:19.543: E/AndroidRuntime(3226): FATAL EXCEPTION: main
02-06 03:50:19.543: E/AndroidRuntime(3226): java.lang.NoClassDefFoundError: com.facebook.android.R$string
02-06 03:50:19.543: E/AndroidRuntime(3226): at com.facebook.widget.WebDialog.onCreate(WebDialog.java:188)
02-06 03:50:19.543: E/AndroidRuntime(3226): at android.app.Dialog.dispatchOnCreate(Dialog.java:339)
02-06 03:50:19.543: E/AndroidRuntime(3226): at android.app.Dialog.show(Dialog.java:249)
02-06 03:50:19.543: E/AndroidRuntime(3226): at com.facebook.AuthorizationClient$WebViewAuthHandler.tryAuthorize(AuthorizationClient.java:461)
02-06 03:50:19.543: E/AndroidRuntime(3226): at com.facebook.AuthorizationClient.tryCurrentHandler(AuthorizationClient.java:209)
02-06 03:50:19.543: E/AndroidRuntime(3226): at com.facebook.AuthorizationClient.tryNextHandler(AuthorizationClient.java:188)
02-06 03:50:19.543: E/AndroidRuntime(3226): at com.facebook.AuthorizationClient.authorize(AuthorizationClient.java:116)
02-06 03:50:19.543: E/AndroidRuntime(3226): at com.facebook.AuthorizationClient.startOrContinueAuth(AuthorizationClient.java:97)
02-06 03:50:19.543: E/AndroidRuntime(3226): at com.facebook.Session.tryLegacyAuth(Session.java:1096)
02-06 03:50:19.543: E/AndroidRuntime(3226): at com.facebook.Session.authorize(Session.java:893)
02-06 03:50:19.543: E/AndroidRuntime(3226): at com.facebook.Session.open(Session.java:957)
02-06 03:50:19.543: E/AndroidRuntime(3226): at com.facebook.Session.openForPublish(Session.java:415)
02-06 03:50:19.543: E/AndroidRuntime(3226): at com.facebook.android.Facebook.openSession(Facebook.java:319)
02-06 03:50:19.543: E/AndroidRuntime(3226): at com.facebook.android.Facebook.authorize(Facebook.java:313)
02-06 03:50:19.543: E/AndroidRuntime(3226): at com.facebook.android.Facebook.authorize(Facebook.java:221)
02-06 03:50:19.543: E/AndroidRuntime(3226): at com.antmoves.stardome.ShareOnFacebook.loginAndPostToWall(ShareOnFacebook.java:135)
02-06 03:50:19.543: E/AndroidRuntime(3226): at com.antmoves.stardome.ShareOnFacebook.share2(ShareOnFacebook.java:121)
02-06 03:50:19.543: E/AndroidRuntime(3226): at com.antmoves.stardome.ShareOnFacebook$1.onClick(ShareOnFacebook.java:59)
02-06 03:50:19.543: E/AndroidRuntime(3226): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:159)
02-06 03:50:19.543: E/AndroidRuntime(3226): at android.os.Handler.dispatchMessage(Handler.java:99)
02-06 03:50:19.543: E/AndroidRuntime(3226): at android.os.Looper.loop(Looper.java:143)
02-06 03:50:19.543: E/AndroidRuntime(3226): at android.app.ActivityThread.main(ActivityThread.java:4263)
02-06 03:50:19.543: E/AndroidRuntime(3226): at java.lang.reflect.Method.invokeNative(Native Method)
02-06 03:50:19.543: E/AndroidRuntime(3226): at java.lang.reflect.Method.invoke(Method.java:507)
02-06 03:50:19.543: E/AndroidRuntime(3226): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-06 03:50:19.543: E/AndroidRuntime(3226): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-06 03:50:19.543: E/AndroidRuntime(3226): at dalvik.system.NativeStart.main(Native Method)
Facebookの私のクラスは次のとおりです。
private static final String APP_ID = "AppID";
private static final String[] PERMISSIONS = new String[] {"publish_stream"};
private static final String TOKEN = "Tokken";
private static final String EXPIRES = "expires_in";
private static final String KEY = "facebook-credentials";
private Facebook facebook;
private String messageToPost;
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
facebook = new Facebook(APP_ID);
restoreCredentials(facebook);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.share_on_facebook);
AlertDialog.Builder alert_box=new AlertDialog.Builder(this);
alert_box.setMessage("Are you sure?");
alert_box.setPositiveButton("Yes",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
if (isNetworkAvailable())
share2();
else
Toast.makeText(getApplicationContext(), "No Internet!", Toast.LENGTH_LONG).show();
}
});
alert_box.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
doNotShare2();
}
});
alert_box.show();
setContentView(R.layout.share_on_facebook);
String facebookMessage = getIntent().getStringExtra("facebookMessage");
if (facebookMessage == null){
facebookMessage = "Test wall post";
}
messageToPost = facebookMessage;
}
@SuppressWarnings("deprecation")
public boolean saveCredentials(Facebook facebook) {
Editor editor = getApplicationContext().getSharedPreferences(KEY, Context.MODE_PRIVATE).edit();
editor.putString(TOKEN, facebook.getAccessToken());
editor.putLong(EXPIRES, facebook.getAccessExpires());
return editor.commit();
}
@SuppressWarnings("deprecation")
public boolean restoreCredentials(Facebook facebook) {
SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences(KEY, Context.MODE_PRIVATE);
facebook.setAccessToken(sharedPreferences.getString(TOKEN, null));
facebook.setAccessExpires(sharedPreferences.getLong(EXPIRES, 0));
return facebook.isSessionValid();
}
private boolean isNetworkAvailable() {
ConnectivityManager connectivityManager
= (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
if (activeNetworkInfo != null)
return activeNetworkInfo.isConnected();
return false;
}
public void doNotShare(View button){
finish();
}
@SuppressWarnings("deprecation")
public void share(View button){
if (! facebook.isSessionValid()) {
loginAndPostToWall();
}
else {
postToWall(messageToPost);
}
}
@SuppressWarnings("deprecation")
public void share2(){
if (! facebook.isSessionValid()) {
loginAndPostToWall();
}
else {
postToWall(messageToPost);
}
}
public void doNotShare2(){
finish();
}
@SuppressWarnings("deprecation")
public void loginAndPostToWall(){
try {
facebook.authorize(this, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH, new LoginDialogListener());
} catch (Exception e) {
// TODO: handle exception
Log.e("MYAPP", "exception", e);
}
//facebook.authorize(this, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH, new LoginDialogListener());
}
@SuppressWarnings("deprecation")
public void postToWall(String message){
Bundle parameters = new Bundle();
parameters.putString("message", message);
parameters.putString("description", "topic share");
try {
facebook.request("me");
String response = facebook.request("me/feed", parameters, "POST");
Log.d("Tests", "got response: " + response);
if (response == null || response.equals("") ||
response.equals("false")) {
showToast("Blank response.");
}
else {
showToast("Error!!");
}
finish();
} catch (Exception e) {
showToast("Error!!");
e.printStackTrace();
finish();
}
}
class LoginDialogListener implements DialogListener {
public void onComplete(Bundle values) {
saveCredentials(facebook);
if (messageToPost != null){
postToWall(messageToPost);
}
}
public void onFacebookError(FacebookError error) {
showToast("Authentication with Facebook failed!");
finish();
}
public void onError(DialogError error) {
showToast("Authentication with Facebook failed!");
finish();
}
public void onCancel() {
showToast("Authentication with Facebook cancelled!");
finish();
}
}
private void showToast(String message){
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
}
これを解決する方法はありますか????
皆様、お時間をありがとうございました...