I'm following the link . When I run the application, the warning window appears as below.
Gradle: module 'facebook' won't be compiled. Unfortunately you can't have non-Gradle Java module and Android-Gradle module in one project.
How do I solve this? Thank you in advance!
android facebook facebook-android-sdk android-gradle android-studio
If you're using Android studio 0.5.5 or later, or the latest version of Facebook SDK, it'll be much simpler than the method I wrote down below (the previous version). If you are using the latest version, you can just do it as it is.
How to use an older version of Android Studio or Facebook SDK
This method is applicable to Android Studio 0.5.4 or earlier. And it's best suited for Facebook SDK versions prior to distributing Gradle build files on Facebook. I don't know what kind of changes were made to which version of SDK.
The method of "importing SDKs to Android Studio projects" on page is not suitable for those who use Gradle-based projects (your project is Android Study)The build.gradle file for the application module will exist, which was created using the New Project wizard in .) So try following the method below instead of the method above.
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']
}
}
}
Please refer to the time when this article was written and how it was presented. Maybe classpath'com.Android.tools.build:gradle:0.6.+' You will need to replace this part with the reference value for the new Gradle plugin version. Soon you'll need a 0.7 version or a later version. Please try it first, and if you get an error message that you need the latest version of Gradle plugin, please correct that part.
5
. Make sure that Android Support Library is installed in SDK manager.
6
. Add the code below to the settings.gradle file in the main directory of the application.
include ':libraries:facebook'
7
. If your project is already open on Android Studio, click the Sync Project with Gradle Files button on the toolbar. Then you can see the Facebook module.
http://i.stack.imgur.com/l1I84.png
8
. Open the Project Structure dialog, select Modules from the left hand list, click the module for the application, and click the Dependencies tab. Press the + button to add a new dependency.
http://i.stack.imgur.com/D7OUp.png
9
. If you select "Module dependency", you will see a dialog showing the list of modules you can select, and choose ":libraries:facebook".
http://i.stack.imgur.com/KEHjw.png
10
. Once you have completed all dialogs, the Android studio will automatically align your project (no need to press the Sync Project with Gradle Files" button again) and select a new dependency. Now you can do it.
© 2024 OneMinuteCode. All rights reserved.