0.8.0 Gradle sync failed - android

So I'm trying to transfer to android studio but I've been getting this error all the time.
This is the only thing I'm getting in the log:
Error:Could not find method compile() for arguments [com.android.support:support-v4:20.0.0] on
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated#50a8e746.
Please install the Android Support Repository from the Android SDK
Manager. Open Android SDK Manager
The problem is that I have android support repo installed as well as pretty much everything else so I really don't have any idea how to fix this.
I've even tried deleting the .gradle and let it download again but it didn't fix anything.
Here's my build.gradle (I did make changes to it since I was getting a build error):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
// do not use dynamic updating.
compile 'com.android.support:support-v4:20.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Android SDK:

Don't put module-level dependencies in the buildscript block. The buildscript block is for dependencies for the build system itself, i.e. if you were adding more Gradle plugins. To add dependencies for your modules, place them in the build.gradle file in the module directory.

Related

The project can be opened but can NOT be run now

I download tutorial codes from github, and I unzip it and copy paste it to where my android studio projects are. After I update to SDK 24.0.2, the project can be opened but can NOT be run now.
Pls write a bit more words for clear instructions in steps of what do I do since I am new to android studio. A lot of time I don't understand the terms you experts use.
Can NOT run the project? the green triangle run button is grey so I can NOT run it.
I got these red messages from Event Log
Gradle sync failed: Unsupported method: SyncIssue.getMultiLineMessage().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
Consult IDE log for more details (Help | Show Log) (41 s 341 ms)
I tried the repo and with only a few changes in two files was able to run the project.
update the root-level build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
Updated gradle version to 4.2.1 and added google() to resolve android dependencies.
updated my gradle distribution URL in gradle-wrapper.properties.
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
Please see if the 6.7.1 is supported on your android studio or not else update to the latest as per your android studio supports, mine is the latest hence 6.7.1
That is it, just by changing these two files I was able to run that app.
Note: I just did bare minimum changes just to make the app run, ideally all the dependency and everything should be up-to-date but changing all those is out of the scope of this question.
I even committed the changes in the forked version of the app code. feel free to try
https://github.com/dk19121991/Court-Counter
Gradle is an app that Android Studio uses to manage loading the libraries of code the project is built with (among other things). But since this project you downloaded is about 5 years old, the version of Gradle in the project may not match up with what Android Studio's Android plugin can support.
Typically, the Gradle app is actually part of the project. You'll see it in the gradle/wrapper directory in the project. You can update the version by editing the file gradle-wrapper.properties, by changing the value in the distributionUrl line. I think you need to make the version at least 6.7.1 if you have a recently updated version of Android Studio, so change that line to look like this:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
The configuration of the project is in the files named build.gradle. The weird thing is, that project seems to have an incorrect duplicate of build.gradle in the root directory of the project (it looks like the one that should go in the app directory). So you can delete the contents of that build.gradle in your root directory and replace it with what would normally be there in a new project. I just copy-pasted this out of a new project. You can paste it into that file:
buildscript {
ext.kotlin_version = "1.5.0"
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And finally, you will want to update the build.gradle file that's in the app directory so it uses the version of Android you already have downloaded (probably SDK 30). So find these relevant lines in the file and change them:
compileSdkVersion 30
buildToolsVersion "30.0.3"
//...
targetSdkVersion 30
After you've made all the above updates, press the "Sync Project with Gradle Files" button near the right end of the toolbar to reload the project from Gradle. It will take a couple minutes because it will have to download the new Gradle version.

Could not find manifest-merger.jar (com.android.tools.build:manifest-merger:26.0.1)

I have a unity project I am exporting that project as android studio project while opening the android studio project I am getting this error
Gradle sync failed: Could not find manifest-merger.jar
(com.android.tools.build:manifest-merger:26.0.1).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/manifest-merger/26.0.1/manifest-merger-26.0.1.jar
I have a few old exported project that was working fine before but today they are also giving the same error.
I finally fixed the issue. This may be a workaround but it works.
So if anyone having this issue, just follow this:
Swap the position of jcenter() and google() in project gradle file and in also all the other module you have in your project. Like in mine I have crashlytics, fabric so just remember to make the changes in their build.gradle file as well:
buildscript {
repositories {
jcenter()
google()
}
}
to
buildscript {
repositories {
google()
jcenter()
}
}
Before building your project again go to your project folder and delete the .gradle folder from your project and then build your project.
Go to Publishing Settings/Build, enable Custom Gradle Template
Go to Assets/Plugins/Android/mainTemplate.gradle and change the postion from
buildscript {
repositories {
jcenter()
google()
}
to
buildscript {
repositories {
google()
jcenter()
}
Remove gradle cache and rebuild. For Mac you can run rm -rf $HOME/.gradle/caches/ in terminal.
Jcenter no longer hosts google dependencies, these can be resolved from "https://maven.google.com"
so you can simply add that to the resolvers list along with jcenter.
Regards,
Itamar
The problem is definitely having jcenter() above google().
However for me, my build.gradle was correct.
The problem happened because of one of my dependencies library had that problem.
The problem seemingly started happening out of nowhere, probably because my jar was cached.
I solved the problem by upgrading my problematic library to latest version as that contained a fix.

Synchronizing Gradle failed due to unknown issues with downloads

I have been trying to fix this error all day now. All I did in the morning was update the compiler I had on my Android Studio. That's when everything went horribly wrong. Since then I have uninstalled the compiler...
These are the types of errors I keep getting everytime I try sync gradle:
Gradle sync failed: Could not find org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.0.
Searched in the following locations:
https://maven.google.com/org/jetbrains/kotlin/kotlin-stdlib-jre8/1.2.0/kotlin-stdlib-jre8-1.2.0.pom
https://maven.google.com/org/jetbrains/kotlin/kotlin-stdlib-jre8/1.2.0/kotlin-stdlib-jre8-1.2.0.jar
Is the latest and one I can't solve... things I've tried:
To solve the other problems I physically downloaded the jar files and
put them in the respective places (which failed with kotlin 1.2.0)...
I also added this to my gradle:
.
buildscript {
repositories {
jcenter()
google()
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://jitpack.io' }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'io.fabric.tools:gradle:1.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
This fixed my other issues...
I tried running from offline mode which failed...
I tried downloading the files into the project and referencing it like this:
.
compile files('kotlin-stdlib-jre8-1.2.0.jar')
I have long since removed the compiler just stuck as to what to do... I couldn't find any way online to fix my problem
I faced this problem after updating to new Android Studio too. You need to provide the dependency with new Kotlin version explicitly. In your app level build.gradle file add:
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.30"
Also you might need to add other dependencies:
compile "org.jetbrains.kotlin:kotlin-stdlib:1.2.30"
compile "org.jetbrains.kotlin:kotlin-reflect:1.2.30"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.30"

Android Studio: Gradle Sync fail with v4 support library

I have been following the Android fragments tutorial which requests that I set up my project to work with the v4 library by following the Support Library Setup document here.
Here are the steps I followed.
1) Make sure you have downloaded the Android Support Repository using
the SDK Manager.
2) Open the build.gradle file for your application.
3) Add the support library to the dependencies section. For example,
to add the v4 support library, add the following lines:
dependencies {
...
compile "com.android.support:support-v4:24.1.1"
}
After following the three steps I receive these two errors:
Gradle project sync failed...
Error:Could not find method compile() for arguments [com.android.support:support-v4:24.1.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please install the Android Support Repository from the Android SDK Manager.
According to the Android SDK Manager, I do have the Android Support Repository installed.
I am going to continue investigating this issue as fragments appear to be a valuable tool to develop powerful Android mobile apps. Help approaching this issue would be appreciated.
As Sufian requested in the comments below, here are the contents of my build.gradle file.
// 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.1.3'
compile "com.android.support:support-v4:24.1.1"
// 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
}
Here is a screenshot of my Android Standalone SDK Manager showing that the Android Support Repository is installed.
There are two build.gradle files in your project, one rootlevel, and one for your application. You will also see a dependencies section in the other build.gradle. You need to place the compile "com.android.support:support-v4:24.1.1" in there.
You are adding compile "com.android.support:support-v4:24.1.1" in <PROJECT_ROOT>\build.gradle instead you should add the above dependency in <PROJECT_ROOT>\app\build.gradle

Installing support repository for Android Studio

I'm using Android Studio on Arch Linux and I installed the Support Repository using the SKD Manager. However whenever I try to use it I get an error saying:
Error:Could not find method compile() for arguments [com.android.support:appcompat-v7:19.1.0] on root project 'Aaaa'.
Please install the Android Support Repository from the Android SDK Manager.
I tried appcompat v7, support v4 and support v13 (I checked all of them are installed). I tried running as root and I still get the same error. The path in local.properties is pointing to the right directory. I'm no really sure what else I should change.
I created a blank activity just to try and use this repository, here is the build.gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
dependencies {
compile 'com.android.support:appcompat-v7:19.1.0'
}
You've put your dependencies block in the wrong build.gradle file. Instead of the top-level build file, put it in your module's build file instead.

Categories

Resources