Android导入Facebook SDK [英] Android Importing Facebook SDK

查看:56
本文介绍了Android导入Facebook SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将近3-4天,我一直在尝试在我的应用程序中添加Facebook登录/共享选项,但我完全无法这样做,我在执行的每个步骤中都会遇到错误.

I've been trying to add a facebook login/share option in my app for almost 3-4 days and I'm completely unable to do so, I keep getting errors in every step I make.

我一直在关注很多教程,这是其中之一: https://developers.facebook.com/quickstarts/1855739941322466/?platform=android

I have been following alot of tutorials, and here's one of them: https://developers.facebook.com/quickstarts/1855739941322466/?platform=android

我几乎完成了所有步骤,但是我发现第一步存在问题,无法导入SDK.

I almost finished all the steps, but I see that I have an issue in the first step, can't import the SDK.

这是我的build.grade(项目:Facebookapp)

Here's my build.grade(Project: Facebookapp)

buildscript {
repositories {
    jcenter()
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'

      }
}

allprojects {
repositories {
    jcenter()
      }
 }

 task clean(type: Delete) {
delete rootProject.buildDir
}

只需添加"mavenCentral()"并删除注释行即可.

Just added the "mavenCentral()" and removed the comment lines.

这是build.grade(模块:应用)

And here's the build.grade(Module: App)

apply plugin: 'com.android.application'

android {
compileSdkVersion 19
buildToolsVersion "19.1.0"

defaultConfig {
    applicationId "com.example.hesham.facebookapp"
    minSdkVersion 19
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.android.support:support-v4:19.1.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
}

但基本上,最后一个编译行:

But basically, the last compile line:

编译'com.facebook.android:facebook-android-sdk:[4,5)'

compile 'com.facebook.android:facebook-android-sdk:[4,5)'

在R中导致错误,我无法解决.顺便说一句,这是一个新项目,因为旧项目太乱了,所以我不确定是否忘记添加一些东西,但是我相信编译行是导致所有问题的原因.希望有人能帮忙,谢谢.

causes an error in the R, which I can't solve. This is a new project by the way, because the old project was a huge mess, so I'm not sure if I forgot to add something, but I believe the compile line is what was causing all the problems. Hope if someone can help, thank you.

编辑;我也尝试过

编译'com.facebook.android:facebook-android-sdk:4.18.0'

compile 'com.facebook.android:facebook-android-sdk:4.18.0'

与我在android项目中遇到的一样,但R中仍然存在错误.

as the one I have in my android project, and still an error in the R.

推荐答案

在您的项目中,打开your_app |Gradle脚本|build.gradle (模块:应用)

In your project, open your_app | Gradle Scripts | build.gradle (Module:app)

将Maven中央存储库添加到build.gradle 在依赖之前:

Add the Maven Central Repository to build.gradle before dependencies:

repositories {
    mavenCentral()
}

compile'c​​om.facebook.android:facebook-android-sdk:4.15.0'添加到您的build.gradle (Module:app)依赖项中,而不是编译'com.facebook.android:facebook-android-sdk:[4,5)'

Add compile 'com.facebook.android:facebook-android-sdk:4.15.0' to your build.gradle (Module:app) dependencies instead of compile 'com.facebook.android:facebook-android-sdk:[4,5)'

dependencies {
    compile 'com.facebook.android:facebook-android-sdk:4.15.0'
}

直到4.22.1版,我没有收到任何错误,但是从4.23.0版开始,我得到了相同的错误.

Till version 4.22.1, I don't get any errors, but from 4.23.0 I get the same error.

这篇关于Android导入Facebook SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆