Hey I've been trying for hours to import an Android library (BetterPickers latest commit) into my project using Gradle
After importing and setting it as module, I get compilation errors. It seems like something is wrong with dependencies in my build.gradle .
build.gradle of library project
build.gradle of main project
As you can see, Android Studio suggests an autofix but it's not helpful.
When I try to run the project/Gradle build, I get compilation errors since the library project is dependent on nineolddroids lib. When I try to add nineolddroids to the dependencies I get a different error:
Could not resolve all dependencies for configuration ':sub:bp:_DebugCompile'.
Could not find com.nineoldandroids:library:2.4.0.)
I guess both of them are derived from the same thing.
How can I fix this?
A few remarks
Using latest Android Studio (0.2.5)
Android Support Repository is installed
In the main project, the support lib is imported just fine and I get no compilation errors when using classes from support lib
Tried many ways to import the library project, including answers from here
Related
Not sure why I can't find any answers on this. If I convert my library project into an .aar using Gradle in Android Studio, does it retain all the dependencies of that module?
I'm asking because I'm trying to use a Gradle generated .aar locally, but it looks like only some of the original dependencies have been packaged. Namely, it complains that I'm missing 'OkHttp', but if I add it to the main project I get duplicate class errors.
Usually a library does not directly contain its dependencies. This does not matter whether it is an aar or a jar. Instead, the library declares its dependencies in the Gradle build file and they are resolved when someone uses the library.
Can anyone tell me whether adding a dependency in build.gradle is and then syncing it is sufficient to use a library in android studio for a project.
I am new to Android Studio. I am trying to work using the android-map-utils library. But it is giving me the following error.
`Error:(64) A problem occurred evaluating project ':library'.
> No such property: sonatypeUsername for class: org.gradle.api.internal.project.DefaultProject_Decorated`
Can anyone help me with this issue and also tell me a easy way to import libraries in android studio?
I had a similar problem while I was migrating from eclipse. I resolved my issue by using the gradle method of including the library (as opposed to importing it as a module and using it as a dependency).
Add the following dependency to your Gradle build file:
dependencies {
compile 'com.google.maps.android:android-maps-utils:0.3+'
}
source: http://googlemaps.github.io/android-maps-utils/#start
I wasn't able to comment.
Applying gradle dependency as link doesn't allow us to view it's source properly.
So if you are interested in viewing source too, in Android Studio itself
You should try adding library as a module project, i.e.,
File -> New -> Import Module -> (Dir of Library)
after importing, you'll face an error, which can be resolved from - Adding Maps Utils Module
I am trying to export our eclipse based project to android studio. Our project is pretty complex and have a long list of dependencies. I used the eclipse based export and import to android studio worked fairly ok.
Currently my build.gradle has these dependencies based on https://stackoverflow.com/a/17243377/31252 and sample build.gradle file
compile 'com.google.android.gms:play-services:4.0.30'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:19.0.+'
But I still seeing compilation errors failing on actionbarsherlock.
error: cannot find symbol class SherlockMapFragment
error: package com.google.maps.android.ui does not exist
error: cannot find symbol class SherlockMapFragment
I tried various combinations including
Tried an older play services 3.2+, this failed with problem in android manifest
Tried apklib in place of aar for actionbar sherlock
Tried - Gradle Error Could not find com.actionbarsherlock:actionbarsherlock:4.4.0 with Eclipse exported project in Android Studio
Also tried importing actionbarsherlock.jar generated elsewhere as jar file.
Import ABS project as a maven dependency module - this messed up my project structure big time.
But the above problem is still persistent. I also have slidingmenu that is throwing compile errors but first I want to tackle actionbarsherlock
Turns out there was a customization in the ABS project, I moved SherlockMapFragment class to our project and adjusted namespaces and this seem to work now
In my app I'm using Guava library. I have referenced it in my build.gradle file only as follows:
dependencies {
compile 'com.google.guava:guava:13.0.1'
}
My app rebuilds and runs fine. However when I'm trying to add a new something from Guava library then the compiler complains that it can't find the class.
For example: when I write
import com.google.common.base.Preconditions
in my new file the compiler says 'cannot resolve symbol common'.
But my old files are rebuilt fine. How so? Do I have to mess with Project|Structure? I specifically wanted to list any dependencies -only- in build.gradle.
It seems that doing a "sync project with gradle files" helps.
In Android Studio, select :
Tools > Android > Sync project with gradle files