我正在尝试将 Facebook 集成到我的应用程序中,但是在 Android Studio 中运行它时,我得到了这个:
Gradle:任务':AplikaceBeta1.0.1:mergeDebugResources'的执行失败。运行命令失败:C:\Users\David\AppData\Local\Android\android-studio\sdk\build-tools\android-4.2.2\aapt.exe s -i C:\Users\David\Desktop\facebook -android-sdk-3.5\facebook-android-sdk-3.5\samples\AplikaceBeta1.0.1Project\AplikaceBeta1.0.1\build\exploded-bundles\AplikaceBeta101ProjectLibrariesFacebookUnspecified.aar\res\drawable\com_facebook_profile_picture_blank_square.png -o C:\Users\ David\Desktop\facebook-android-sdk-3.5\facebook-android-sdk-3.5\samples\AplikaceBeta1.0.1Project\AplikaceBeta1.0.1\build\res\all\debug\drawable\com_facebook_profile_picture_blank_square.png 错误代码:42 输出: C:\Users\David\Desktop\facebook-android-sdk-3.5\facebook-android-sdk-3.5\samples\AplikaceBeta1.0.1Project\AplikaceBeta1.0。
无法打开 PNG 文件...什么?!
代码与“Android 版 Facebook SDK 入门 (Android Studio) ”指南中的代码完全相同。真的很简单,这是我的MainActivity.java:
package com.example.aplikacebeta101;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.widget.TextView;
import com.facebook.*;
import com.facebook.model.*;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// start Facebook Login
Session.openActiveSession(this, true, new Session.StatusCallback() {
// callback when session changes state
@Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
// make request to the /me API
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
// callback after Graph API response with user object
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
TextView welcome = (TextView) findViewById(R.id.welcome);
welcome.setText("Hello " + user.getName() + "!");
}
}
});
}
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
}
有任何想法吗?我知道,Android Studio 仍然是 EAP,但我认为这不是由 Android Studio 引起的。