3

I have a problem that keeps me busy for the last few days and I would like to get some help...

I am using intellij 13.1.3 and when I try to add the Facebook SDK as a module I get an an error

Error: Gradle: error: package com.facebook does not exist

I did everything excactly as @Scott Barta explained here: https://stackoverflow.com/a/20221453/1018192

please help me! :( thank you very very much :)

Edit 1: my build.gradle files:

facebook -> build.gradle

apply plugin: 'android-library'

dependencies {
    compile 'com.android.support:support-v4:13.0.+'
    compile files('libs/bolts.jar')
}

android {
    compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
    buildToolsVersion "19.0.0"

    defaultConfig {
        minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
        targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
    }

    lintOptions {
        abortOnError false
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
}

my_proj -> build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19.1.0'
    compile 'com.android.support:support-v4:19.1.0'
}

My_proj -> build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

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

allprojects {
    repositories {
        mavenCentral()
    }
}

My_proj -> settings.gradle

include ':my_proj'
include ':libraries:facebook'
Community
  • 1
  • 1
maryum375
  • 727
  • 1
  • 10
  • 22

2 Answers2

5

Just add it as dependency

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

use http://gradleplease.appspot.com/#facebook to get the last version

daduck
  • 276
  • 3
  • 6
1

I fixed it!!!

I just added to the my_proj.gradle the row

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19.1.0'
    compile 'com.android.support:support-v4:19.1.0'
    **compile project(':libraries:facebook')**
}

and it fixed 3 days of headache

maryum375
  • 727
  • 1
  • 10
  • 22
  • An explanation for noobs of why this was missing and what it added might be beneficial for future noobs. As it is it looks like you simply never included the FB SDK into your gradle project.... ;) – RichieHH Jul 17 '14 at 12:39