I am trying to incluide FaceBook Sdk 4.2 in my app. When I import this module , it´s all rigth, but when my app run the following occurs:
Error:A problem occurred configuring project ':Glam Main'.
> Could not resolve all dependencies for configuration ':Glam Main:_debugCompile'.
> Could not find com.parse.bolts:bolts-android:1.2.0.
Searched in the following locations:
file:/C:/Users/JL9/AppData/Local/Android/sdk/extras/android/m2repository/com/parse/bolts/bolts-android/1.2.0/bolts-android-1.2.0.pom
file:/C:/Users/JL9/AppData/Local/Android/sdk/extras/android/m2repository/com/parse/bolts/bolts-android/1.2.0/bolts-android-1.2.0.jar
file:/C:/Users/JL9/AppData/Local/Android/sdk/extras/google/m2repository/com/parse/bolts/bolts-android/1.2.0/bolts-android-1.2.0.pom
file:/C:/Users/JL9/AppData/Local/Android/sdk/extras/google/m2repository/com/parse/bolts/bolts-android/1.2.0/bolts-android-1.2.0.jar
Required by:
Glam Main:Glam Main:unspecified > com.facebook.android:facebook:4.2.0
gradle.Module.Glam Main:Glam Main:
apply plugin: 'com.android.application'
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
compile project(':appcompat_v7_21')
compile project(':appcompat_v7_21-cardview')
compile project(':appcompat_v7_21-recyclerview')
compile project(':httpmime-4.2.6')
compile project(':facebook')
}
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
In my module Facebook , I have added com.parse.bolts:bolts-android:1.2.0
. this module Facebook has been imported correctly because i can work with their classes.
Here my gradle.Module.Facebook
apply plugin: 'com.android.library'
repositories {
mavenCentral()
}
project.group = 'com.facebook.android'
dependencies {
compile 'com.android.support:support-v4:[22,23)'
compile 'com.parse.bolts:bolts-android:1.2.0'
}
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
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']
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
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 'Facebook Platform License'
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))
// JDK 1.8 is more strict then 1.7. Have JDK 1.8 behave like 1.7 for javadoc generation
if (org.gradle.internal.jvm.Jvm.current().getJavaVersion() == JavaVersion.VERSION_1_8) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
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}
I have read the follow post Android Studio 0.8.1 - how to use Facebook SDK? but I getnt resolve my problem. Thanks.
Update 1
I have modified gradle.Module.Glam Main:Glam Main. I added this sentences:
allprojects {
repositories {
jcenter()
}
}
Now i have this error
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
Error:Execution failed for task ':Glam Main:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe'' finished with non-zero exit value 2
You can add the latest Facebook SDK via Gradle dependency:
Take a look to my build.gradle file:
https://github.com/lalongooo/permutas-sep/blob/master/app/build.gradle