Ever since I updated my Android Studio to its 0.3.0 incarnation, this is the very first time I've created a project in it (previously, all I did was maintenance of already existing projects) and, much to my horror, something seems amiss with either Gradle or importing libs in general.
First of all, gone are all the options to mess around with Project Settings, I understand this is supposedly by design, so I don't break something, but what if Gradle isn't properly detecting the jars in my libs folder? As it stands, doesn't matter what I add there, it's never recognized by Android Studio.
Another issue I'm having is when importing modules, such as the Facebook SDK, I go over to the modules screen and import it and add it to my main module's dependencies.
It all works fine and well in the compiler, with autocomplete working as a clockwork. However, when it's time to build and run the application, the whole thing fails and I get an Error: Gradle: package com.facebook does not exist.
And this even happens if all I do is import the library, not even making any actual use of it (but again, the compiler sees absolutely no issues).
Anyone knows how to fix these errors and what can be done? Importing both jars and modules are of utmost importance for my app and I simply cannot finish it without them.
There is not much support of visial project editing at the moment, since it is still early alpha version of AndroidStudio. You have to edit your build.gradle files manually. The easiest way of create correct gradle builds file is to export them from working eclipse project. (http://developer.android.com/sdk/installing/migrate.html)
Particullary for using FacebookSDK i would use next snippet at your application build.gradle:
apply plugin: 'android'
repositories {
maven {
url "http://mente.github.io/facebook-api-android-aar"
}
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar') // this includes all .jar libs
compile 'com.facebook:facebook-android-sdk:3.5.2@aar' // this downloads facebookSDK
}
Note, that you don't need to checkout facebook sources anymore! Single line dependencies make it so much easier than it was before.
Please, update question with your build.gradle if you still have issues. Most likely problem lays there.
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