I followed instruction from http://developer.android.com/tools/support-library/setup.html to add the support library to my android project, but got an build error like this
Gradle: A problem occurred evaluating project ':projectname'.
No signature of method: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.compile() is applicable for argument types: (java.lang.String) values: [com.android.support:appcompat-v7:18.0.+]
Possible solutions: module(java.lang.Object)
Does anyone know the reason for that? Is it a syntax error in gradle? Below is a piece of code in my build.gradle.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
compile 'com.android.support:appcompat-v7:18.0.+'
}
}
This should be like this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
// this is for Gradle build system so it finds
// android plugin used below
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:appcompat-v7:18.0.+'
// this is for your application
}
Don't forget to install Android Support Repository in Android SDK Manager.
Related
i've been working with firebase to access an activity on my project. Everything works fine, no compilation errors. However after i go to tools > firebase i can connect to my app easily, however when i try to click Add Real time database it shows me this:
build.gradle will include these new dependencies:
compile 'com.google.firebase:firebase-database:16.0.1:15.0.0'
Since compile is deprecated i use implementation, and when i do
Implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'
i get the following error Failed to resolve: firebase-database-15.0.0
and my sync fails.
Change Root Gradle to
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
}
}
allprojects {
// ...
repositories {
// ...
google() // Google's Maven repository
}
}
And App Gradle To
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
// Getting a "Could not find" error? Make sure you have
// added the Google maven respository to your root build.gradle
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Hope This May Help You
add jcenter() in your project-level gradle.
allprojects {
repositories {
google()
jcenter()
}
}
and keep remaining as #Tomin B said.
I've deployed artifact to bintray as it whitten in documentation (using their plugin). All looks fine. It is opened in browder, structure looks fine: https://dl.bintray.com/flymob/maven/
Now I want to use it via gradle in Android Studio before publishing to jcenter(). I've read their documentation https://bintray.com/docs/usermanual/formats/formats_mavenrepositories.html#_working_with_gradle
I've tried:
buildscript {
repositories {
jcenter()
maven {
url "https://dl.bintray.com/flymob/maven"
}
}
}
and
compile 'flymob-sdk-sample:FlyMobSdk:1.3.0'
or
compile 'flymob-sdk-sample:FlyMobSdk:1.3.0#aar'
I'm getting error:
Failed to resolve: flymob-sdk-sample:FlyMobSdk:1.3.0
What am I doing wrong?
you added "https://dl.bintray.com/flymob/maven" inside the buildscript section. Those are the repos used by the buildscript (a.k.a. gradle script) only. Those are the repos where the system will find the plugins from apply plugin
to fix it is easy. Just move it to the repositories on the "root" of the script. Something like:
buildscript {
repositories {
// repos for the build script
jcenter()
... etc
}
dependencies {
// dependencies from the plugins from the build script
classpath 'com.android.tools.build:gradle:2.1.2'
... etc
}
}
apply plugin: 'android-sdk-manager'
apply plugin: ... etc
repositories {
jcenter()
maven { url "https://dl.bintray.com/flymob/maven" } <<<<< HERE
}
dependencies {
compile ... etc
compile('com.twitter.sdk.android:tweet-composer:0.8.0#aar')
{
transitive = true;
}
i got gradle from https://dev.twitter.com/twitter-kit/android/compose
But when Sync the Android Studio project following error is coming ..
Error:(53, 13) **Failed to resolve: **com.twitter.sdk.android:tweet-composer:0.8.0****
Show in FileShow in Project Structure dialog
As was described on twitter, you have to change some parts in your module build.gradle.
In your module you can use:
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// The Fabric Gradle plugin uses an open ended version to
// react quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
//Put Fabric plugin after Android plugin
apply plugin: 'io.fabric'
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
I suggest you installing the Android Studio plugin.
It helps you to configure the gradle script.
This help me
https://dev.twitter.com/twitterkit/android/installation
dependencies {
// Include all the Twitter APIs
compile 'com.twitter.sdk.android:twitter:3.0.0'
// (Optional) Monetize using mopub
compile 'com.twitter.sdk.android:twitter-mopub:3.0.0'
}
OR
enter code dependencies {
compile 'com.twitter.sdk.android:twitter-core:3.0.0'
compile 'com.twitter.sdk.android:tweet-ui:3.0.0'
compile 'com.twitter.sdk.android:tweet-composer:3.0.0'
compile 'com.twitter.sdk.android:twitter-mopub:3.0.0'
}
Here is how my application module 'app' build gradle looks like:
apply plugin: 'com.android.application'
repositories {
maven { url 'http://localhost:8080/repository/internal/' }
}
...
dependencies {
compile 'org.apache.httpcomponents:httpmime:4.2.3'
compile 'com.testpackage.networking:networking:1.0.3'
}
and it works just fine. I'm trying to use same dependency in my library module named 'librarymodule'. Here is how its build.gradle looks like:
apply plugin: 'com.android.library'
repositories {
maven {
url 'http://localhost:8080/repository/internal/'
}
}
...
dependencies {
compile 'org.apache.httpcomponents:httpmime:4.2.3'
compile 'com.testpackage.networking:networking:1.0.3'
}
The only difference is gradle plugin 'com.android.library' used here vs 'com.android.application' used in 'app' module.
Error:A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugCompile'.
Could not find com.testpackage.networking:networking:1.0.3.
Searched in the following locations:
https://jcenter.bintray.com/com/testpackage/networking/networking/1.0.3/networking-1.0.3.pom
https://jcenter.bintray.com/com/testpackage/networking/networking/1.0.3/networking-1.0.3.jar
file:/Users/myusername/Library/Android/sdk/extras/android/m2repository/com/testpackage/networking/networking/1.0.3/networking-1.0.3.pom
file:/Users/myusername/Library/Android/sdk/extras/android/m2repository/com/testpackage/networking/networking/1.0.3/networking-1.0.3.jar
file:/Users/myusername/Library/Android/sdk/extras/google/m2repository/com/testpackage/networking/networking/1.0.3/networking-1.0.3.pom
file:/Users/myusername/Library/Android/sdk/extras/google/m2repository/com/testpackage/networking/networking/1.0.3/networking-1.0.3.jar
Required by:
LibrariesApplication:app:unspecified > LibrariesApplication:librarymodule:unspecified
So, for some reason there is no http://localhost:8080/repository/internal/com/testpackage/networking/networking/1.0.3/networking-1.0.3.pom under Searched in the following locations list.
It's not only my repository problems. I can for example use
maven { url 'https://mint.splunk.com/gradle/' }
repository with dependency
compile 'com.splunk.mint:mint:4.1'
and still getting similar error
Does anyone knows how to fix that?
This is a bit strange but adding custom repository to 'allprojects' of root build.gradle actually worked!
allprojects {
repositories {
jcenter()
maven {
url 'http://localhost:8080/repository/internal/'
}
}
}
If you don't want to put the maven credentials in the project file (and you shouldn't), create a "gradle.properties" file in your home directory and put the maven credentials in that file, like:
mavenUser=myUser
mavenPassword=myPassword
Then, in your build.gradle file, use as follows:
maven {
credentials {
username mavenUser
password mavenPassword
}
url http://my.maven.url
}
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'
}