Android 无法找到 com.facebook.katana.provider.AttributionIdProvider 的提供商信息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12670011/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed to find provider info for com.facebook.katana.provider.AttributionIdProvider
提问by Rom Freiman
Anyone knows what does this error mean? I get it in LogCat shell every time I connect with my android application to Facebook (via emulator).
有谁知道这个错误是什么意思?每次我将我的 android 应用程序连接到 Facebook(通过模拟器)时,我都会在 LogCat shell 中获取它。
The code which in charge of authorize functionality:
负责授权功能的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.authorize);
mPrefs = getPreferences(MODE_PRIVATE);
loginPref = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
String access_token = mPrefs.getString("access_token", null);
long expires = mPrefs.getLong("access_expires", 0);
if(access_token != null) {
Singelton.mFacebook.setAccessToken(access_token);
}
if(expires != 0) {
Singelton.mFacebook.setAccessExpires(expires);
}
Singelton.mFacebook.authorize(this, new String[] {"email","user_birthday"}, new DialogListener() {
@Override
public void onComplete(Bundle values) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString("access_token", Singelton.mFacebook.getAccessToken());
editor.putLong("access_expires", Singelton.mFacebook.getAccessExpires());
editor.commit();
SharedPreferences.Editor logEditor = loginPref.edit();
logEditor.putBoolean("login", true);
logEditor.commit();
addUser();
}
@Override
public void onFacebookError(FacebookError error) {
errorHandler();
}
@Override
public void onError(DialogError e) {
errorHandler();
}
@Override
public void onCancel() {
Log.d("MyApp", "Facebook cancel");
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Singelton.mFacebook.authorizeCallback(requestCode, resultCode, data);
}
回答by AnhSirk Dasarp
This can happen due to the following reasons:
这可能是由于以下原因造成的:
- You are not connected to internet
- You have not given permission for internet access ( Manifest.xml)
- You have not used a correct hashkeyfor the app
- You did not provide a correct App Id
- 您没有连接到互联网
- 您尚未授予 Internet 访问权限 (Manifest.xml)
- 您没有为应用程序使用正确的哈希键
- 您没有提供正确的 App Id
回答by Vinay S Shenoy
It just means that you don't have the Facebook app installed on your phone. Don't worry too much about it.
这只是意味着您没有在手机上安装 Facebook 应用程序。不要太担心它。
The way the Facebook SDK for Android works is that whenever you need to make a request to Facebook, the SDK checks to see if the Facebook app is already installed on your device. If it is installed, the request is made through the app. If the app is not installed, it fetches the data by itself.
适用于 Android 的 Facebook SDK 的工作方式是,每当您需要向 Facebook 发出请求时,SDK 都会检查 Facebook 应用程序是否已安装在您的设备上。如果已安装,则通过应用程序发出请求。如果未安装该应用程序,它会自行获取数据。
回答by Jraco11
If anyone's problem wasn't remedied by the four solutions, this may help. I was getting this same error when I began to use Fragments to implement the Facebook login. I was using the standard Fragment and not the support library v4 Fragments and after switching to the support library Fragment my problem went away. This may be unique to my situation but thought I'd share it just in case. Also don't forget to set the Fragment if you're using the login button method.
如果四个解决方案没有解决任何人的问题,这可能会有所帮助。当我开始使用 Fragments 来实现 Facebook 登录时,我遇到了同样的错误。我使用的是标准 Fragment 而不是支持库 v4 Fragment,在切换到支持库 Fragment 后,我的问题就消失了。这可能是我的情况所独有的,但我想我会分享它以防万一。如果您使用登录按钮方法,也不要忘记设置 Fragment。
myFacebookLoginButton.setFragment(this); //Assuming you're in a Fragment class
回答by M.ES
Simply add the following permission to the AndroidManifest.xml
只需将以下权限添加到 AndroidManifest.xml
<uses-permission android:name="android.permission.SET_DEBUG_APP"/>
回答by vrunoa
As @Vinay-S-Shenoy said, that happens when the Facebook app its not installed on the phone or the simulator. What I do, to avoid this error is to check if the Facebook app its installed before call the facebook.authorize method, an in case the facebook app its not installed I alert this message to the user.
正如@Vinay-S-Shenoy 所说,当 Facebook 应用程序未安装在手机或模拟器上时,就会发生这种情况。为了避免此错误,我所做的是在调用 facebook.authorize 方法之前检查其是否安装了 Facebook 应用程序,如果未安装 Facebook 应用程序,我会向用户发出此消息。
public boolean isFacebookAvailable() {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "Test; please ignore");
intent.setType("text/plain");
final PackageManager pm = this.getApplicationContext().getPackageManager();
for(ResolveInfo resolveInfo: pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY)){
ActivityInfo activity = resolveInfo.activityInfo;
// Log.i("actividad ->", activity.name);
if (activity.name.contains("com.facebook.katana")) {
return true;
}
}
return false;
}
回答by Penzzz
Don't forget to override onActivityResult and check if it called(for example if you using fragments)
不要忘记覆盖 onActivityResult 并检查它是否被调用(例如,如果您使用片段)
PS(maybe it will be usefull for others, i faced this trouble when was using parse facebook login =)
PS(也许它对其他人有用,我在使用 parse facebook login 时遇到了这个麻烦=)
回答by Adrien V
For me (but I work with ionic) it was because of an image missed / template error, before launch :
对我来说(但我使用离子)这是因为在启动之前丢失了图像/模板错误:
ionic cordova build android
Maybe it can help others...
也许它可以帮助其他人......
回答by Hemanth
btnFb_photo_post.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// postPhotoToWall(facebook.getAccessToken());
facebook.authorize(MyFBTestActivity.this,
new String[] { "publish_stream" },
new DialogListener() {
@Override
public void onFacebookError(FacebookError e) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(),
e.getMessage(), Toast.LENGTH_LONG).show();
}
@Override
public void onError(DialogError dialogError) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(),
dialogError.getMessage(),
Toast.LENGTH_LONG).show();
}
@Override
public void onComplete(Bundle values) {
postToWall(values.getString(Facebook.TOKEN));
}
private void postToWall(String accessToken) {
// Toast.makeText(getApplicationContext(),
// "trying", Toast.LENGTH_LONG).show();
byte[] data = null;
Bitmap bi = BitmapFactory.decodeResource(
getResources(),
R.drawable.ic_launcher
);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bi.compress(Bitmap.CompressFormat.JPEG, 100, baos);
data = baos.toByteArray();
Bundle params = new Bundle();
// if (facebook.getAccessToken() != null)
params.putString(Facebook.TOKEN,
facebook.getAccessToken()
);
params.putString("method", "photos.upload");
params.putString("caption", "www.samplelink.com");
// params.putString("message",
// "www.google.com");
params.putByteArray("picture", data);
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
mAsyncRunner.request(null, params, "POST",
new SampleUploadListener(), null);
}
@Override
public void onCancel() {
// TODO Auto-generated method stub
}
}
);
}
});
i am using this code to upload image to FB wall. try once
我正在使用此代码将图像上传到 FB 墙。尝试一次