using existing gradle wrapper while importing projects in android studio - android

I am using android studio for my android projects.I just got a problem when i imported an android studio project.The problem is that gradle is downloading wrapper 2.4 and i have 2.1.0. Is there a way to use older version by changing setting. I searched about it but i didn't find solutions specific to the problem.what i got is
How to set gradle home while importing existing project in Android studio
How to use gradle zip in local system without downloading when using gradle-wrapper
In my case, i don't have version 2.4 and want to use existing 2.1.0

Try to change the distributionUrl values with your currently version (2.1.0) and then :
./gradlew clean assemble
Remove .idea folder and all .iml files and import the project
as new one.
check this answer too:
https://stackoverflow.com/a/22366006/4409113
And: Force Android Studio to download and install gradle 1.10 or 1.1

Related

Android studio : when re-import the project it show's error and given a strange floders

while re-importing my project android studio show's plenty of errors
after cleaning and re-importing my project i have got an red circle with ā€œJā€ on my java files and i'am enable to run my project
Make sure that your gradle version is defined properly.
It seems that this project was on another PC and you imported it on your computer. I think that probably a gradle version conflict occurred and you have two options:
one is to let android studio download gradle version specified in TlaProject (gradle 2.4)
another solution is to edit app level 'build.gradle' file and change its version to a version which is available on your machine (to see which version is available on your system, please check 'gradle' folder inside installation folder of android studio)
My problem was solved by updating the version of android studio .

Need 2.8 gradle instead of 2.4

I get this error while running Android Studio:
Warning:Gradle version 2.8 is required. Current version is 2.4. If using the gradle wrapper, try editing the distributionUrl in C:\Git\SC-Wallet-Android\gradle\wrapper\gradle-wrapper.properties to gradle-2.8-all.zip
I changed the link to the proper one but Android Studio, automatically creates .gradle folder in Users folder where i can locate 2.4 version of gradle(2.8 is created aswell) if i delete 2.4 folder, when application is launched 2.4 is created again. What creates this version?
The files in .gradle are created by gradle itself. This indicates that you are still not running gradle 2.8 but 2.4 instead.
Make sure Android Studio is configured to use the gradle wrapper. See here for instructions.

Gradle version and gradle-wrapper.properties

How do I download the latest Gradle version automatically within a Android project? Do I manually change the file gradle/wrapper/gradle-wrapper.properties
...
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
...
And change 2.4 to 2.6 and run gradlew?
When I create a Android project, why is not 2.6 there from start?
How do I download the latest Gradle version automatically within a Android project? Do I manually change the file gradle/wrapper/gradle-wrapper.properties
Yes.
You have to change the gradle/wrapper/gradle-wrapper.properties
For example:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip
Then, sync the project.
Android Studio will download the new version automatically.
And change 2.4 to 2.6 and run gradlew?
First, sync the project.
When I create a Android project, why is not 2.6 there from start?
The new project is based on a template file.
For this reason, currently any new project is with 2.4 version.
You can change the template, but AS will update it with the next updates.
You can change it manualy, but I don't recommend it.Because the gradle wrapper version related to gradlew and gradlew.bat, they may need to change too.If your want to upgrade your gradle wrapper, run this in Android Studio Terminal if you using Linux:
./gradlew wrapper --gradle-version 2.10
For Windows, change the command to
gradlew wrapper --gradle-version 2.10
If you use macOs,
in android studio go
Android Studio
Preferences
Build, Execution, Deployment
Gradle, and change use gradle from: specified location
go to users/current_user
press commant+shift+dot (for show hidden files)
go to gradle folder
go to wrapper folder
open
Now gradle install all missing files, Good Luck :)

Android Studio: How to Migrate IntelliJ Project to Gradle?

I have a project that was originally from IntelliJ.
I followed the instructions below.
http://tools.android.com/tech-docs/new-build-system/migrating-from-intellij-projects
I'm not sure what to do next. When I load my project in Android Studio it still asks if I want to migrate to gradle. What did I miss?
I am able to use Gradle in the command prompt to build my project, so I assume I just need to tell Android Studio to use Gradle instead of Ant.
I next imported my existing project and it recognized it as a gradle project. I also had to change the gradle version in the gradle.build file to work with the newer version of Android Studio.

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