I'm trying to include Android Asynchronous Http Client and Picasso into my Android project using Gradle. Here's my build.gradle file.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
dependencies {
compile 'com.loopj.android:android-async-http:1.4.4'
compile 'com.squareup.picasso:picasso:2.1.1'
}
}
When I try to sync it, I keep getting the following error.
No signature of method: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.compile() is applicable for argument types: (java.lang.String) values: [com.loopj.android:android-async-http:1.4.4]
Possible solutions: module(java.lang.Object)
I'm very new to Android so I'm clueless on how to correct this. Can anyone please help me out? I'm using Android Studio version 0.5.8 by the way.
Thank you.
Don't include dependencies in your top-level build file. Include them in module-level build files instead. If you use the Project Structure UI instead of modifying build files directly, it will set things up properly.
Related
I'm getting error=
ERROR:
Could not find method testImplementation() for arguments [junit:junit:4.12] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Looks like you are missing android plugin definition in your gradle. Put this line at top in your gradle file.
apply plugin: 'com.android.application'
Also make sure you are using gradle version above 3.0 and have following repositories added in gradle. Try clean and build after you update your gradle.
repositories {
google()
jcenter()
}
So the problem which is occurring in your build.gradle(app), has the solution. You just remove all the testImplementation and androidTestImplementation from your dependencies. I guess you won't find any issues from there onwards. Usually in the app build.gradle only implementations of the libraries should be there. Go ahead and do it, tell me what you get after that.
dependencies{
implementation
// comment or remove all the testCompilations and androidTestCompilations and sync the gradle
//add this at the end of the line, this is for compilation of the gradle
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}
I hope it helps.
Just remove the "testCompile 'junit:junit:4.12'" from build.gradle file:
dependencies {
// .......
testCompile 'junit:junit:4.12'//remove this line
//.......
}
OR
add this line at the end of build.gradle file
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
I am trying to implement the andoridplot library in my app. I have download sample code from the github.sample is working fine. But if I am trying to import androidplot-core as a module in my project, I get this error:
Plugin with id 'com.github.dcendents.android-maven' not found.
Please suggest the appropriate answer.
Most likely you need to add the following to your buildscript section of your gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}
Just a note: The preferred way to include Androidplot is as a normal compile dependency in gradle, not as a module.
I want to compile with com.squareup.picasso:picasso:2.5.3-SNAPSHOT. But i got this error:
Error:Could not find com.squareup.picasso:picasso:2.5.3-SNAPSHOT.
Required by:
familywall-android:app:unspecified
Search in build.gradle files
Have someone experienced something similar?
The Picasso snapshot version you mentioned is not available in the standard maven repo. In your build.gradle add the following dependency to your dependencies block:
dependencies {
// 2.5.3 is no longer updated.
compile 'com.squareup.picasso:picasso:3.0.0-SNAPSHOT'
//...
}
and in the repositories block add
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
//...
}
I found the .jar here, the last version is 21. It worked!
I'm using this library in my Android app. (https://github.com/yazeed44/MultiImagePicker)
Before now, I was adding it to my project this way:
compile 'net.yazeed44.imagepicker:imagepicker:1.3.0'
The problem with importing it that way is, as far as I know, that I can't override any code because I'll lose all the changes after building the project again. (I need to change some code)
For that reason, I have downloaded the source code and I've imported the project as a module with this name: 'imagepicker'
After that, I added this line to my app build.gradle:
compile project(':imagepicker')
and this to my settings.gradle (Android Studio did it)
include ':app', ':imagepicker'
After doing that, I try to run the project and Android studio shows this error:
Gradle 'Project' project refresh failed
Error:Plugin with id 'com.github.dcendents.android-maven' not found.
Since you are using the module locally you have to add in your top-level build.gradle or in the imagepicker/build.gradle same config added in the imagepicker build.gradle project.
buildscript {
repositories {
jcenter()
}
dependencies {
//ADD THESE DEPENDENCIES
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
}
}
An alternative can be modify the imagepicker/build.gradle removing the last 2 lines. But you have to test this way.
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
If you check these files you will find the
apply plugin: 'com.github.dcendents.android-maven'
In your case you don't need these files because they are useful only to uplaod in a maven repo the aar file.
I added below code in Project:gradle.build file and its resolved the problem :
allprojects {
repositories {
jcenter()
maven {
url "https://repo.commonsware.com.s3.amazonaws.com"
}
}
}
EDIT
If you still facing after adding above maven dependencies
Change url "https://repo.commonsware.com.s3.amazonaws.com" to url "https://s3.amazonaws.com/repo.commonsware.com".
Im trying to build a simple android app using gradle build tools. but im getting an error like this
No signature of method: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.compile() is applicable for argument types: (java.lang.String) values: [org.gradle.api.plugins:gradle-android-plugin:1.2.0-SNAPSHOT]
Possible solutions: module(java.lang.Object)
ang here's a simple configuration of build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
compile 'org.gradle.api.plugins:gradle-android-plugin:1.2.0-SNAPSHOT'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
processResource {
expand (project.properties)
}
task configureDebug << {
jar.classifier = "debug"
}
task configureRelease << {
proguard.enabled = true
}
When applying a plugin you want tell you build script to use it in its classpath. It is not required for compilation so just change the configuration compile to classpath. More more information see 51.5.1. Using your plugin in another project in the Gradle user guide.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.gradle.api.plugins:gradle-android-plugin:1.2.0-SNAPSHOT'
}
}
EDIT: At the moment the plugin does not support r20 of the Android SDK. For more information see this issue.
Make sure you are writing the dependency block on your application build.gradle "YourProjectName->yourprojectname->build.gradle" in android studio hierarchy .
Use android gradle tools
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}