Add Facebook sdk 3.20.0 to Android Studio 0.9.2

Asked

Viewed 525 times

1

I’m having trouble adding the Facebook sdk to Androido Studio 0.9.2.

Always returns me the following messages

Failed to find: com.parse.bolts:bolts-android:1.1.2

Some solution?

I imported the module into my project.

My build.Radle file configuration

compileSdkVersion 21
buildToolsVersion '21.1.1'

minSdkVersion    10
targetSdkVersion 21

I only made this modification of the original Facebook build.Radle.

  • 2

    Have you imported facebookSDK as a module of your project? You can post the entire build.Radle please?

1 answer

2

try this solution:

  • Download the Facebook SDK(https://developers.facebook.com/docs/android/)

  • Unzip facebook-android-sdk-3.20 file. 0

  • In Android Studio perform the following operation: File menu->Import Module

  • Choose "facebook" inside the unpacked folder.

  • Go to the facebook/build.grade directory and change the content to this one:

    apply plugin: 'android-library'

    project.group = 'com.facebook.android'
    
    dependencies {
        compile 'com.android.support:support-v4:20.0.+'
        compile 'com.parse.bolts:bolts-android:1.1.2'
    }
    
    android {
        compileSdkVersion 19
        buildToolsVersion '20.0.0'
    
        defaultConfig {
            minSdkVersion 10
            targetSdkVersion 19
        }
    
        lintOptions {
            abortOnError false
        }
    
        sourceSets {
            main {
                manifest.srcFile 'AndroidManifest.xml'
                java.srcDirs = ['src']
                res.srcDirs = ['res']
            }
        }
    }
    
    apply plugin: 'maven'
    apply plugin: 'signing'
    
    def isSnapshot = version.endsWith('-SNAPSHOT')
    def ossrhUsername = hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
    def ossrhPassword = hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
    
    task setVersion {
        // The version will be derived from source
        project.version = null
        def sdkVersionFile = file('src/com/facebook/FacebookSdkVersion.java')
        sdkVersionFile.eachLine{
            def matcher = (it =~ /(?:.*BUILD = \")(.*)(?:\".*)/)
            if (matcher.matches()) {
              project.version = matcher[0][1]
              return
            }
        }
        if (project.version.is('unspecified')) {
          throw new GradleScriptException('Version could not be found.', null)
        }
    }
    
    uploadArchives {
        repositories.mavenDeployer {
            beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
    
            repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
                authentication(userName: ossrhUsername, password: ossrhPassword)
            }
    
            snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
                authentication(userName: ossrhUsername, password: ossrhPassword)
            }
    
            pom.project {
                name 'Facebook-Android-SDK'
                artifactId = 'facebook-android-sdk'
                packaging 'aar'
                description 'Facebook Android SDK'
                url 'https://github.com/facebook/facebook-android-sdk'
    
                scm {
                    connection 'scm:[email protected]:facebook/facebook-android-sdk.git'
                    developerConnection 'scm:[email protected]:facebook/facebook-android-sdk.git'
                    url 'https://github.com/facebook/facebook-android-sdk'
                }
    
                licenses {
                    license {
                        name 'The Apache Software License, Version 2.0'
                        url 'https://github.com/facebook/facebook-android-sdk/blob/master/LICENSE.txt'
                        distribution 'repo'
                    }
                }
    
                developers {
                    developer {
                        id 'facebook'
                        name 'Facebook'
                    }
                }
            }
        }
    }
    
    uploadArchives.dependsOn(setVersion)
    
    signing {
        required { !isSnapshot && gradle.taskGraph.hasTask("uploadArchives") }
        sign configurations.archives
    }
    
    task androidJavadocs(type: Javadoc) {
        source = android.sourceSets.main.java.srcDirs
        classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    }
    
    task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
        classifier = 'javadoc'
        from androidJavadocs.destinationDir
    }
    
    task androidSourcesJar(type: Jar) {
        classifier = 'sources'
        from android.sourceSets.main.java.sourceFiles
    }
    
    artifacts {
        archives androidSourcesJar
        archives androidJavadocsJar
    }
    
    afterEvaluate {
        androidJavadocs.classpath += project.android.libraryVariants.toList().first().javaCompile.classpath
    }
    
  • Click your project and press F4, go to 'dependencies' tab, click '+', 'module dependency' and select your imported Facebook project.

  • Now just take a Resync and a rebuild

Browser other questions tagged

You are not signed in. Login or sign up in order to post.