I'm following Facebook SDK for Android using Android Studio. When I run my application I'm getting the below mentioned warning.
Gradle: module 'facebook' won't be compiled. Unfortunately you can't have non-Gradle Java module and Android-Gradle module in one project.
How should I solve this?
I tried @Scott Barta's answer and get the following error message.
A problem occurred configuring project ':App'. > Failed to notify project evaluation listener. > A problem occurred configuring project ':libraries:facebook'. > Failed to notify project evaluation listener. > Could not resolve all dependencies for configuration ':libraries:facebook:_DebugCompile'. > Could not find any version that matches com.android.support:support-v4:+. Required by: MyApplication2.libraries:facebook:unspecified
The Facebook SDK for Android gives you access to the following features: Facebook Login — A secure and convenient way for people to log into your app or website by using their Facebook credentials. Sharing — Enable people to post to Facebook from your app. People can share, send a message, and share to stories.
The Facebook SDK is what allows mobile app developers to integrate Facebook within a mobile app. SDK stands for software development kit, and it allows for a website or app to integrate with Facebook seamlessly. Examples of what you can do with Facebook SDK include: Facebook Login functionality.
Are Facebook, WhatsApp, and Quora-like apps created using Android Studio? Yes these apps are created using android studio. Modules of these apps are created on Android studio but the final release build id created by using build tools provided by google.
NOTE
For Android Studio 0.5.5 and later, and with later versions of the Facebook SDK, this process is much simpler than what is documented below (which was written for earlier versions of both). If you're running the latest, all you need to do is this:
Ctrl + Shift + Alt + S
and then select dependencies tab. Click on +
button and select Module Dependency. In the new window pop up select :facebook.
Instructions for older Android Studio and older Facebook SDK
This applies to Android Studio 0.5.4 and earlier, and makes the most sense for versions of the Facebook SDK before Facebook offered Gradle build files for the distribution. I don't know in which version of the SDK they made that change.
Facebook's instructions under "Import the SDK into an Android Studio Project" on their https://developers.facebook.com/docs/getting-started/facebook-sdk-for-android-using-android-studio/3.0/ page are wrong for Gradle-based projects (i.e. your project was built using Android Studio's New Project wizard and/or has a build.gradle
file for your application module). Follow these instructions instead:
Create a libraries
folder underneath your project's main directory. For example, if your project is HelloWorldProject, you would create a HelloWorldProject/libraries
folder.
Now copy the entire facebook
directory from the SDK installation into the libraries
folder you just created.
Delete the libs
folder in the facebook
directory. If you like, delete the project.properties
, build.xml
, .classpath
, and .project
. files as well. You don't need them.
Create a build.gradle
file in the facebook
directory with the following contents:
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.6.+' } } apply plugin: 'android-library' dependencies { compile 'com.android.support:support-v4:+' } android { compileSdkVersion 17 buildToolsVersion "19.0.0" defaultConfig { minSdkVersion 7 targetSdkVersion 16 } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] res.srcDirs = ['res'] } } }
Note that depending on when you're following these instructions compared to when this is written, you may need to adjust the classpath 'com.android.tools.build:gradle:0.6.+'
line to reference a newer version of the Gradle plugin. Soon we will require version 0.7 or later. Try it out, and if you get an error that a newer version of the Gradle plugin is required, that's the line you have to edit.
Make sure the Android Support Library in your SDK manager is installed.
Edit your settings.gradle
file in your application’s main directory and add this line:
include ':libraries:facebook'
If your project is already open in Android Studio, click the "Sync Project with Gradle Files" button in the toolbar. Once it's done, the facebook
module should appear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With