I get this error. I'm pretty confused because i check everything in sdk manager and it's all updated (i think so).
Error:(30, 0) Could not find method compile() for arguments
[com.android.support:appcompat-v7:+] on object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please install the Android Support Repository from the Android SDK
Manager. Open Android SDK Manager
Is there something wrong with my code in build.grandle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
}
or is something missing...?
You can't use the compile() DSL in the top level file.
Delete this block:
dependencies {
compile 'com.android.support:appcompat-v7:+'
}
and add the dependency in the dependencies block inside the app/build.gradle file.
You should not use "compile" when using Gradle build tools 3.0.0.
"compile" has been replaced with "implementation".
And you can't add dependencies in the project build.gradle file.
You have to add dependencies in the module build.gradle file.
So in the build.gradle file in the "app" directory, add these lines:
dependencies {
implementation 'com.android.support:appcompat-v7:+'
}
The "dependencies" block might already be there, if so, just add the contents to the original block.
Related
I got the following problem after updating the Gradle. I was not able to find any solution for it.
So please help me to solve the following problem.
Thanks in advance...
(PROBLEM-----Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom'. Received status code 406 from server: Not Acceptable)
My build.gradle file...
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
you should set build.gradle(project level)
classpath 'com.android.tools.build:gradle:4.0.1'
and in gradle-wrapper.properties file
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
then sync again project.
Android Gradle plugin 4.1.0 is not release yet. see on Google's Maven Repository. Try classpath 'com.android.tools.build:gradle:4.1.0-rc02' if you want to use 4.1.0.
I'm trying to use yelp-fusion-android library. I tried updating the gradle but no luck.
I am getting this error:
ERROR: Gradle DSL method not found: 'compile()'
Possible causes:
The project 'testProject' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file
The build file may be missing a Gradle plugin.
Apply Gradle plugin
Here is build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.google.gms:google-services:4.3.2'
compile 'io.github.ranga543:yelp-fusion-client:0.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Remove this line from the top-level file:
//compile 'io.github.ranga543:yelp-fusion-client:0.1.4'
In the app/build.gradle file you can add the same dependency:
dependencies {
...
implementation 'io.github.ranga543:yelp-fusion-client:0.1.5'
...
}
Your problem is here
compile 'io.github.ranga543:yelp-fusion-client:0.1.4'
Compile is deprecated use "Implementation" instead
and you are placing it in the wrong gradle there are 2 gradle files
please note this warning
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Place below dependency in app module instead of main project gradle.
compile 'io.github.ranga543:yelp-fusion-client:0.1.4'
and replace compile with Implementation.
e.g (In app module)
Implementation 'io.github.ranga543:yelp-fusion-client:0.1.4'
dependencies section inside buildscript is not for module dependencies. Hence. move out compile 'io.github.ranga543:yelp-fusion-client:0.1.4' from this section and create top level dependencies block and put it there as below:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.google.gms:google-services:4.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
dependencies {
compile 'io.github.ranga543:yelp-fusion-client:0.1.4'
}
Also, if you have got submodule then you can add this dependency to the sub-module.
I am trying to write a React Native version of this module https://github.com/paypal/PayPal-Cordova-Plugin
It is deprecated, but until we can transition to Braintree, we need the functionality for an existing app.
It has a dependency:
repositories{
mavenCentral()
}
dependencies {
compile('com.paypal.sdk:paypal-android-sdk:2.16.0') {
exclude group: 'io.card'
}
}
I would think that I should add this to the build.gradle file for the React Native app, but when I go there, I see this:
dependencies {
classpath("com.android.tools.build:gradle:3.4.1")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
So it seems like I should have a build.gradle file in my module directory, which I do - the same as the one above (com.paypal.sdk...)
However, it doesn't seem to be registering.
Is there a way to indicate to download this dependency? I know in iOS there is pod install - is there an equivalent method in Android?
How do I install this dependency?
EDIT: My newest plugin build.gradle is this, and it still throws an error due to the library being missing:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.paypal.sdk:paypal-android-sdk:2.16.0'
compile 'com.facebook.react:react-native:+'
}
I was trying to gradle build a plain Java Android project. It was an ADT project imported to Android Studio. To my astonishment, at one point Gradle tried to download the Kotlin compiler!
* What went wrong:
Execution failed for task ':app:lint'.
> Could not resolve all files for configuration ':app:lintClassPath'.
> Could not download kotlin-compiler.jar (com.android.tools.external.com-intellij:kotlin-compiler:26.2.0)
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/external/com-intellij/kotlin-compiler/26.2.0/kotlin-compiler-26.2.0.jar'.
> Read timed out
Why the heck did gradle attempt downloading a big package like the Kotlin compiler
How do I prevent that?
More generally, how do make gradle ask me before it tries to download anything or at least prevent it from downloading non-dependencies? Such things should be installed by my distro's package manager, after all!
1) Because Gradle supports linting Kotlin code, which requires parsing it, which is implemented using classes in the Kotlin compiler.
2) By not using the lint task I guess?
3) The Kotlin compiler is a dependency. Gradle requires a specific version of this dependency in a specific layout and in a specific location, and it can't use a version installed by your package manager.
change
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
to
buildscript {
repositories {
google()
maven {
url "https://maven2.google.com"
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
maven {
url "https://maven2.google.com"
}
jcenter()
}
}
In Android Stdio,We can see as following.
classpath 'com.android.tools.build:gradle:1.5.0'
I know that the this code is for gradle dependencies with jar.
But I cannot find the this jar locally.
How can I find this jar?
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Gradle caches by default will be here
~/.gradle/caches/jars-<number>/<hash of jar>/<jar name>.jar
or
~/.gradle/caches/modules-<number>/files-<number>/<group id>/<artifact id>/<version>/<file hash>/<jar name>.jar