Setting up gradle and gradle plugin and dependencies in in android studio - android

After installing arctic fox on linux, I tried to create a new project but was told there was no gradle and it wanted to download one. Not having a great internet connection I downloaded gradle 6.9.2 and I pointed the gradle to the folder.
It's apparently not enough to just have gradle but it needs a plugin as well. Which gets specified in project structure - project. None of the options in project structure work but manually setting version 3.5.3 in the build.gradle does.
The issue I have now is that I have no idea where the 3.5.3 comes from? Is there a folder where all these plugins are installed where one can check what is available?
I'm having the same issue with other dependencies where just starting a new project requires that I re-download all the dependencies again despite the fact that I can open another project and it builds just fine.

The plugin version depend on gradle plugin. You can see version require docs from here: https://developer.android.google.cn/studio/releases/gradle-plugin
And plugin will be downloaded from google maven repository: https://maven.google.com/web/index.html#com.android.tools.build:gradle
You can also find them on your local maven cache directory.

Related

What is gradle plugin (for example gradle plugin 4.1.1)?And Where is it stored on computer?

I am using Android Studio. And I have come across the term called gradle plugin. I know what the gradle is and I have already downloaded it on my pc. Actually I want to know where does the gradle plugin 4.1.1 go after the project build successfully. I am successfully to use gradle locally into my project but when it comes to use gradle plugin I have to connect my computer to the internet everytime I create a new project. Is there any way I can use gradle plugin locally?
At least one time you should need to sync with your gradle plugins when you creating a new project then after you can use offline gradle option

Android Studio 3.1 Stable. Build Successful but Can Not Resolve Error

I have updated to Android Studio 3.1 Stable Version today(27 March 2018).
I have an old project. With new studio version, it gets build successful and app gets installed on Emulator, but the on the IDE, Activity file shows
Can Not resolver Error
.
gradle file app module
Project level gradle file
I spent a long time on this yesterday after migrating from Android Studio 2.3 to 3.1. Tried everything from other answers to similar questions. Google's maven repository was correctly configured, tried invalidating caches and restarting, restarted the computer, etc.
The one thing that worked for me was closing Android Studio, deleting the .idea folder from my root folder and starting Android Studio again. Since I had everything checked into git before starting the upgrade I was able to do:
rm -rf .idea/
git checkout .idea
So I ended up with my original idea project files, but you should be fine if you can't revert to your checked in idea files. After reopening Android Studio it recreated some of the files I ended up deleting and everything worked again. Hope that helps others with the same problem.
This answer is old but basically suggests the same thing so I guess this problem keeps showing up. https://stackoverflow.com/a/21100896/791560
I was able to Fix:
https://developer.android.com/studio/build/dependencies.html#google-maven
From Android Studio 3.1, if we are working on Old projects built on 3.0 or lower, you need to add maven repository at top level build.gradle file. i.e., add google() under repositories of all projects.
For new projects, it gets added automatically.
App level, build tools version should be at min 27.0.3
Make sure compilesdk version and support library version are the same version level.

error:Connection reset (Gradle sync failed: Connection reset)

I am importing constraint-layout-start to android studio 3.0. I have kept in androidstudioproject folder that's the the path where all my android studio projects are stored. after importing its showing connection reset error. Here is the log file link: https://drive.google.com/file/d/1W1mGmIc67baZb4C5nGGecWm15ggB0Wp5/view?usp=sharing
i have all the SDK installed. tried to manually change the sdk verion to 21 which was running perfectly for my other projects, but here it didn't work.
i checked all the files are okay, i am not getting why this error occurs.
images of gradle page are given below.
build.gradle
gradle
Add google repository to your gradle file:
repositories {
maven()
//other repositories...
google()
}
Try to download from SDK manager:
SDK Manager Android Studio
Check your gradle and plugin version:
https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle
For Android studio 3.0.0
required Gradle version: 4.1
File > Project Structure > Project
required Build Tools 26.0.2
For Android Studio 3.4 Canary 8
Hope it will helpful!
Go To File>Settings>Build, Execution, Deployment>Gradle
and set your Android studio local gradle path like below image
i solve this problem in this way. be careful it causes with different problems like using proxy, dns connection windows , fire wall block , ....
anyway, i use proxy in file/settings/proxy in android studio and after that i set no proxy. after that whenever use kerio vpn or cisco gradle didnt work.
solution :open gradle.properties and remove every proxy script from there and sync gradle and work fine

Android application project in Eclipse and use gradle or maven to download JARS

I'm using Eclipse IDE Mars and the ADT android plugin and the sdk 23, and I always encounter problems when I try to install a .JAR all the sites where I download a JAR have a sample about how to install the JAR using Maven or Gradle, I tried to install Android for Maven Eclipse 1.4.0 (m2e) plugin but had the following error The following solutions are not available: Android for Maven Eclipse 1.4.0 (id=com.android.ide.eclipse.adt.feature.group, site=http://rgladwell.github.io/m2e-android/updates/).
So I tried to install gradle plugin instead to do so I followed this question:
Is there any way to integrate Eclipse with Gradle in Android project? and I installed the Gradle IDE plugin but I don't know where to go from here since all the documentation I can find it is for too advanced users I can't find a simple tutorial in how to create an android application and use gradle to download the JARS all the info that appears is a gradle.build where you put the name of the jars similar to maven dependencies.
My questions are
1) How can I solved this problem ``The following solutions are not available: Android for Maven Eclipse 1.4.0 (id=com.android.ide.eclipse.adt.feature.group, site=http://rgladwell.github.io/m2e-android/updates/)when I try to install the maven plugin, Since I already have used Maven before and I have a lillte more experience with it than with gradle.
2) How can I use the Gradle IDE eclipse plugin to just download the JARS in my android application default project or some example about How to transform a default Android project application created by Eclipse IDE and add gradle to this project so I can download JARS. ( I don't have the Gradle_home variable in my system variables I don't know if this is necesary since if I only download the plugin).
My goal is just to use anyone of this tools to download JARS

Gradle version 1.6 is required. Current version is 1.8-20130730220035+0000

Just updated Android-Studio to version 0.2.7 an now I get the error message from the title:
In the log window there is link to the grade setup:
No matter which option I use the error message stays the same.
I deleted my ~/.gradle directory and projects **/.gradle directories.
It seems that nothing helps.
Nitpick: compile on the command-line using \opt\gradle\1.6\bin\gradle.bat build works fine.
Go to Preferences > Project Settings > Gradle and choose "Use gradle wrapper" instead of the bundled option
Open your gradle-wrapper.properties and change the distributionUrl to use 1.7 if it is not already (mine was 1.6), i.e. distributionUrl=http\://services.gradle.org/distributions/gradle-1.7-bin.zip
I managed to fix my project through some combination of invalidating Android Studio cache, deleting .idea and .gradle directories and .iml files, restarting Studio, and reimporting the project:
on Mac OSX using Homebrew, brew install gradle then pick local gradle distribution and point to /usr/local/Cellar/gradle/1.7/libexec for gradle home:
You do not want to manage gradle at a system level, it is better handled per project. Android Studio projects already setup gradle wrapper handling when creating new projects but if you have an older one you can add the same file that Android Studio does. Think of this as an gradle bootstrap file that will download the correct gradle version per project. You can also read up on Gradle Wrapper and generate a shell script called gradlew that will provide gradle-free bootstrapping.
In gradle/wrapper/gradle-wrapper.properties in your project directory make sure you have:
#
#Tue Oct 08 13:40:54 CEST 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.7-bin.zip
Then when you go into Gradle you can set it to use the gradle wrapper. This is the default when creating new projects in Android Studio.
There are at least three approaches to migration or adding Gradle properly and using the new project structure Google and Android Studio has introduced.
Create a new project and copy over the code
Export from Eclipse to Gradle (deprecated)
Import code into Android Studio (recommended)
Try to manually get everything in order by creating the correct gradle files and reorganizing the project.
For now I'm copying the files over to a new project until the tools get a bit better.
We have two computers, one of which gave that same message after upgrading to Android Studio 0.2.7. We noticed that the computer which could still build had Gradle installed independently of Android Studio.
Installing Gradle 1.6 downloaded from the Gradle web site fixed this issue on the computer that wouldn't build.
My fix was basically what Abe did but I wanted to give a bit more explanation:
Download gradle 1.6 from the gradle website
Extract somewhere on your pc/mac
Open up android studio, go to Preferences -> Gradle (left panel) -> and chooose Local gradle distribution.
Point Gradle home to the location where you extracted gradle.
This fixed the issue for me. Using the gradle wrapper and the bundled gradle distribution both failed
In my case, i updated gradle to the latest version (1.8) and then changed the gradle.build files (for my project and for the libraries i was using) like these:
dependencies {
classpath 'com.android.tools.build:gradle:0.6.1+'
}
The Synchronize files and Refresh/Invalidate cache. This seems to solve the problem. I think that Gradle in order to determine the minimum required version just reads the above value.
Here's what I did to get my project working:
Installed Gradle 1.7 on my OS (OS X users can use brew for this)
Added this to my local.properties file: sdk.dir=/Applications/Android\ Studio.app/sdk
Created gradle wrappers with gradle wrapper command.
Chose "Use gradle wrapper (recommended)" option in Android Studio.

Categories

Resources