gradle project sync failed android studio - android

I'm trying to setup nhaarman/ListViewAnimations inside of Android Studio 1.1.0.
From Setup:
Add the following to your build.gradle:
repositories {
mavenCentral()
}
dependencies {
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0#aar'
compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0#aar'
compile 'com.nhaarman.listviewanimations:lib-core-slh:3.1.0#aar'
}
yet Android Studio says:
Gradle project sync failed. Basic functionality (e.g. editing,
debugging) will not work properly.
Error:(26, 0) Gradle DSL method not found: 'compile()'
Possible causes:<ul><li>The project 'X' may be using a version of Gradle that does not contain the method.
Gradle settings</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>

You are adding these dependencies in the top level build.gradle file.
You have to add these lines in the module build.gradle file.
root
build.gradle //top level
app
build.gradle //module level

After adding those lines to:
build.gradle (Module: app)
instead of
build.gradle (Project: app)
the error is gone.

Try this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0'
compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0'
}

Try removing #arr. worked for me.
//ListView Animations
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0'
compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0'

Related

android unresolved dependencies error when creating a new project

I have updated my Android studio, but after that, I cannot create a new project. My Android version is 2.2 beta 3.
This is an image of the error messages when attempting to create a Gradle sync project:
I was having the same problem, but I have fixed mine by removing this line of code from my Gradle module (app) level:
After removing to sync the project hopefully it will fix the problem.
Edit the dependencies in gradle app as:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.2.1'
}
This worked for me :)
1.go to settings
2.select gradle option.
3.uncheck "offline work".
4.rebuild project.
5.that's it. make sure you have a internet connection.
Try adding the dependencies repositories in Project build.gradle
allprojects {
repositories {
google()
jcenter()
"Your dependencies repositorie"
}
}

adding json dependency to a library module in android studio

I created a new library module to my project in Android Studio. A class in this new module accesses org.json.JSONObject.
I'm getting the error:
failed to resolve org.json:json:20141113
when trying to build the project.
Here's how my build.gradle file looks:
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':app')
compile files('libs/volley.jar')
compile 'org.json:json:20141113'
}
Please let me know if I'm missing anything.
Thanks.
Try adding a repository to your configuration maybe that helps.
repositories {
mavenCentral()
}
For more information see here:
User-guide: Dependency Management Basics
Test This one , Worked for me
dependencies {
implementation 'com.cedarsoftware:json-io:4.10.1'
}

Why can't I add Facebook SDK on Android Studio?

I am following the Getting Started, Facebook Android SDK.
But when I am adding the repositories and the dependencies, I get the following error:
Error: Module version com.facebook.android:facebook-android-sdk:4.1.0 depends on libraries but is not a library itself.
I tried with several versions of the SDK but I can't make it work.
This is how my gradle looks:
dependencies{
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
}
repositories{
mavenCentral()
}
I am using the BuildTools 22.0.1
I hope someone can orient my with this issue.
Regards
compile 'com.facebool.android:facebook-android-sdk:4.1.0' Is the facebool correct or is that an error? If that's an error then that could be your issue. Also if you can't get it to compile from a maven source try downloading a jar and putting it in your local library. Then go into the project structure and go to the module you want to add this library to and click on the dependencies tab and there is a plus icon to add a library from file.
In you build.gradle(Project:Your-Project-Name) replace jCentral() with mavenCentral() in both (allproject/repos and buildscript/repos) then sync your gradle.
Hope this helps.

Can't add External Library in Android Studio?

I Added a External Library to my project by following
this method. and tried this method too this method too.
Gradle build got Finished and i got this line added to my build.gradle
compile 'com.github.castorflex.smoothprogressbar:library-circular:1.0.1'
Now i am trying to import this library in my class. But i can't do this. I took a look at the files and they are located in the build directory under the exploded-aar. so i added #aar to the compile line. Still there are no changes.
How can i import this library to my class or where i am going wrong?
Thanks in Advance
Well, you don't need to download anything or point your dependency to a file.
This dependency, as most of the dependencies you use, can automatically fetched from JCenter, biggest repository for Java and Android components.
All you need to do is:
Add JCenter as your dependencies repository.
Declare that you need the library-circular dependency. This can be found and copy/pasted from the file icon in particular package/version in JCenter.
Resync your Android Studio project with your Gradle build file. This is the 'sync' button in Gradle pane in Android Studio.
Here's what your build.gradle should include:
repositories {
jcenter()
}
dependencies {
compile(group: 'com.github.castorflex.smoothprogressbar', name: 'library-circular', version: '1.0.1', ext: 'aar')
}
in build. gradle put following code
dependencies {
compile fileTree (dir: 'libs', include: ['*.jar'])
}
Did you add the dependencies?
You can do so in the following way -
dependencies {
compile files('insert ParentFolder/external_library_name with the extension here')
}
Add it to build.gradle based in the app folder
1.Put the jar file into the libs folder.
2.Right click it and hit 'Add as library'.
3.Ensure that compile files('libs/abcdef.jar') is in your build.gradle file and Finally add the dependencies.
Eg.
dependencies {
compile fileTree(dir: '../jar', include: '*.jar')
compile project(':pull-to-refresh')
compile files('libraries/abcdef.jar')
}
Hope this helps :)

Gradle Multiproject

I am trying to configure gradle for a multiproject environment.
My project structure is as follows:
MainProject
--external
--A
--B
--C
I have been able to configure the build.gradle and the settings.gradle file for the MainProject.
The problem that I have is that both subprojects A & B depend on C
In project A 's build.gradle
apply plugin: 'android-library'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project('../C')
}
Gradle says unable to find project with path ../C. What path should I put in there?
Try with:
compile project(':external:C')
For more details about project paths see section 56.5 in the Gradle user guide.

Categories

Resources