Gradle Issues in Android Studio - java

There's a Java file I'm meant to convert to Kotlin. I'm stuck with this Gradle problem and can't find my way around it. What can I do to resolve this issue?

Go to build.gradle(Module)
and inside dependencies add the following line.
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10'
It should look something like this
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta6'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Related

Failed to resolve libraries when changing from jcenter() to mavenCentral()

So I am working on an old project and Android Studio warned me to change from jcenter() to mavenCentral() as jcenter() is not beeing updated.
So this was my initial project build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.google.gms:google-services:4.3.13
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And I have changed it to the following one:
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.google.gms:google-services:4.3.13
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
With the initial build.gradle using jcenter() everything was working fine, but using mavenCentral it fails to resolve these 2 github libraries:
"Failed to resolve: com.loopeer.lib:shadow:0.0.3"
"Failed to resolve: com.vatsal.imagezoomer:image-zoomer:1.0.2"
I don´t know why with jcenter() I don´t have any problem and using mavenCentral() yes, could there be any solution or maybe they can be only working with jcenter()?
The curious thing is that for example I have searched for information of one of this libraries and supposedly it should work with mavenCentral -> "ImageZoomer is available in the MavenCentral, so getting it as simple as adding it as a dependency" (This is what it is said in this github library)

Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom'

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.

ERROR: Gradle DSL method not found: 'compile()'

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.

Android Studio Error "lint-gradle-api-26.1.2 not found

When I run my App, AS comes up with this error. Says that the file was not found at https://repo.jfrog.org/artifactory/libs-release-bintray/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar?referrer. Please help! Putting google() repo doesn't work.
I ran into this issue as well. Basically, the issue is that mentioned jar file is no longer in jcenter. I resolved by changing the order of search in our app build.gradle:
buildscript {
repositories {
maven {
url 'https://dl.google.com/dl/android/maven2'
}
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}

Android studio error:Error:(23, 0) Could not find method android() for arguments on root project

I reinstalled android studio, I am using the same project with android studio in another PC so the code is probably fine!
It is the full error:
Error:(23, 0) Could not find method android() for arguments [build_1z9k6ruj47plglocgqknjnoag$_run_closure3#133cf914] on root project 'allthingsvegan-android-9d296805dc64' of type org.gradle.api.Project.
Open File
The solutions I've found on the internet was including changing the code.. So they are not relevant to me
Thanks!!
build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-beta1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android {
buildToolsVersion '24.0.1'
}
It is the top-level build.gradle file.
In this file you can't use this block:
android {
buildToolsVersion '24.0.1'
}
Remove this block.
you need to apply the android plugin:
apply plugin: 'com.android.application'
this needs to be done after buildscript like this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-beta1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'com.android.application'
android {
buildToolsVersion '24.0.1'
}
uncomment android tag present in build.gradle(Project:android-start)
rebuild the gradle it asks to update .
Update the gradle then sync it works

Categories

Resources