I download android studio 2.2.3 and load my project. But Gradle Build Running Stuck. It continuously shows that and i am not able to run my app. what is the issue can any one help me with that?
Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
If you are behind a proxy, create a gradle.properties file next to your build.gradle file with this :
systemProp.http.proxyHost=YOUR_PROXY
systemProp.http.proxyPort=YOUR_PORT
systemProp.http.proxyUser=USERNAME
systemProp.http.proxyPassword=PASSWORD
systemProp.https.proxyHost=YOUR_PROXY
systemProp.https.proxyPort=YOUR_PORT
systemProp.https.proxyUser=USERNAME
systemProp.https.proxyPassword=PASSWORD
systemProp.http[s].proxyUser and systemProp.http[s].proxyPassword are not required if you don't need to login for your proxy. In such a case, remove these lines.
Make sure you have a internet connection.
If you have it , so maybe android studio couldn't download classes from Jcenter. So you have to force android studio to download classes from other resource like Maven.
To do that open gradle.build file and change the two jcenter() text with mavenCentral() ("C" in maven"C"entral() must be typed in uppercase) and try syncing with gradle again.
You don't need to do that every time you open your project. Just do this every time you create a new project in Android studio.
Solutions:
1. update your Build tools.
2. Reinstall sdk.
In my case, all the executable ".exe" files in "sdk\build-tools\25.0.3" folder were corrupted by virus. solution 2 worked for my perfectly. :)
Related
Similar question: Android studio gradle stuck at Fastutil.7.2.0.jar
When I'm building my first Android App in Java, Android Studio 4.0 is always complaining:
Could not GET 'https://jcenter.bintray.com/it/unimi/dsi/fastutil/7.2.0/fastutil-7.2.0.jar'. Received status code 400 from server: Bad Request
Enable Gradle 'offline mode' and sync project
However, it's possible to download the jar with the browser.
If I remove jcenter()in build.gradle, a similar error occurs:
Could not HEAD 'https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.72/kotlin-stdlib-jdk8-1.3.72.pom'. Received status code 400 from server: Bad Request
Enable Gradle 'offline mode' and sync project
This file doesn't even exist.
I tried modifying build.gradle or setting up proxy, but neither works.
gradle.build 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.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
}
UPDATE:
Solved. Proxy's fault. Check C:\Users\USERNAME\.gradle\gradle.properties.
Make sure you have installed Command line tools
if not install from
sdk manager > sdk tools > check command line tools and apply
Error: Access is denied
I have recently installed Android Studio and I am running it from behind my organisation proxy. I have gone through 100 of links for this problem and I am not able to find the solution.
What I have done till now :
In gradle.properties I have written following lines
systemProp.http.proxyHost=sy*********om
systemProp.http.proxyPort=80
systemProp.http.proxyUser=RAGU
systemProp.http.proxyPassword=W********
systemProp.http.auth.ntlm.domain=*****om
systemProp.https.proxyHost=sy**********om
systemProp.https.proxyPort=80
systemProp.https.proxyUser=RAGU
systemProp.https.proxyPassword=W********
systemProp.https.auth.ntlm.domain=*****om
In Project Structure in JDK location I have entered the location of my jdk ie. C:\Program Files\Java\jdk1.8.0_66 instead of using the embedded JDK.
My 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.3.2'
// 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
}
My logs
you can see the logs via this link : https://drive.google.com/open?id=0B7ZLoWnEHDkac2thbXRTNEduTkZPSkFYNW56UVV3UzhmZ3NZ
Whenever I try to sync the gradle this error pops up . What can I do to resolve this error.
I had very ugly issues with gradle wrapper and gradle-wrapper.properties until i found this Gradle proxy configuration. I tested it and it worked like a sharm.The command was this
gradle -Dhttp.proxyHost=proxy -Dhttp.proxyPort=3128 -Dhttp.proxyUser=username -Dhttp.proxyPassword=password -Dhttps.proxyHost=proxy -Dhttps.proxyPort=3128 -Dhttps.proxyUser=username -Dhttps.proxyPassword=password wrapper
I ran it in the Android Studio terminal with Windows proxy disable.My PC is running on Windows 10 x64 VersiĆ³n 10.0.16299.15 with Android Studio 3.0.1
I hope this help you out there.Happy new year!!
Using the latest Android Studio 3.0 Canary 5
Here's the error:
Error:(1, 1) A problem occurred evaluating project ':app'.
Failed to apply plugin [class 'com.android.build.gradle.api.AndroidBasePlugin']
Android Gradle plugin 3.0.0-alpha5 must not be applied to project [path_to_my_project] since version 3.0.0-alpha5 was already applied to this project
Tried: cleaning, rebuilding, opening/closing. Not working.
any ideas ?
[LATER EDIT]
Solution: Migrate to Canary 8+ and all should be ok.
From this reddit thread, killing daemons fixed the problem for me.
./gradlew --stop
This worked for me:
Deactivate Configuration On Demand
In gradle.properties:
org.gradle.configureondemand=false
Then stop the daemon in a terminal window:
gradlew.bat --stop
Now everything works again.
Versions used:
Android Studio 3.0 Canary 5
gradle: gradle-4.1-milestone-1
android gradle plugin: com.android.tools.build:gradle:3.0.0-alpha5
UPDATE
After upgrading to Android Studio 3.0 Beta 2 I can reactivate Configuration on Demand and everything works fine.
Migrating the gradle version from 3.0.0-alpha5 to 3.0.0-alpha7 saved my day !!
I got the issue and realized the issue related with caches.
You have to invalidate caches of Android studio by select File-> Invalidate Caches/Restart.
It worked for me. The issue was resolved.
Open a terminal and write
./gradlew --stop
In gradle.properties make sure you don't have funny stuff
Notice that there are no custom jvmargs...
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=false
Include the google() repo in build.gradle (project one)
there's how mine look like
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
maven { url "http://objectbox.net/beta-repo/" }
}
dependencies {
classpath 'io.objectbox:objectbox-gradle-plugin:0.9.12.1'
classpath 'com.android.tools.build:gradle:3.0.0-alpha5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url 'https://jitpack.io' }
jcenter()
google()
maven { url "http://objectbox.net/beta-repo/" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
lastly the support library versions in the app build.gradle file
build.gradle
...
//----- Support Libs
implementation 'com.android.support:appcompat-v7:26.0.0-beta2'
implementation "com.android.support:design:26.0.0-beta2"
implementation "com.android.support:recyclerview-v7:26.0.0-beta2"
implementation "com.android.support:cardview-v7:26.0.0-beta2"
...
I had the same issue, I closed Android Studio and opened again, I noticed that it automatically applied these changes to the following files and everything worked fine:
build.gradle: changed the class path of Gradle from:
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
}
to
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha5'
}
gradle-wrapper.properties: from
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
to
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip
I already tried all the solutions including
Clean,
Rebuild,
Invalidate Project
But nothing is working but i figured it out.
For temporary just downgrade your gradle plugin version to stable version
classpath 'com.android.tools.build:gradle:2.3.2'
Replace your alpha line with this line. And have fun.. :)
Linux environment using jenkins android gradle project to build an error
* What went wrong:
A problem occurred configuring project ':app'.
> Could not download glide.jar (com.github.bumptech.glide:glide:3.7.0)
> Could not get resource 'https://jcenter.bintray.com/com/github/bumptech/glide/glide/3.7.0/glide-3.7.0.jar'.
> Could not GET 'https://jcenter.bintray.com/com/github/bumptech/glide/glide/3.7.0/glide-3.7.0.jar'.
> repo.jfrog.org: unknown error
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I tried to use the wget way to download the link will prompt an error, then I use the sudo way to download the link successfully. So, how can I make jenkins gradle also use the sudo download, or use other solutions
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
// Exclude the version that the android plugin depends on.
configurations.classpath.exclude group: 'com.android.tools.external.lombok'
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Please help me, thanks.
You can try upload your local library (in user/.gradle/caches) to Jenkins server, It 's work for me.
I don't think that run the build with super user rights is a good solution, because it's not seems to be possible to resolve dependencies.
Just a suggestion how to solve it: Gradle has it's own local cache for dependencies and doesn't need to download them on every build. So you may use the same Gradle distribution, which is used by Jenkins, and once build your application manually with su rights, to resolve all dependencies and cache them.
Just to note, by default dependencies with dynamic versions are cached for 24 hours only, as it's said in the official docs, but you can change it as:
configurations.all {
resolutionStrategy.cacheDynamicVersionsFor 10, 'minutes'
resolutionStrategy.cacheChangingModulesFor 4, 'hours'
}
I'm trying to import a project from GitHub and build/run it on Android Studio. I am getting the following error:
"Error:Could not create an instance of Tooling API implementation
using the specified Gradle distribution
'https://services.gradle.org/distributions/gradle-2.4-all.zip'."
I have tried the following:
Invalidate Cache and Restart
Changing the distributionURL in gradle-wrapper/properties to 2.5 etc.
Deleting build.gradle and restarting
These are ideas I got from several other posts on stackoverflow so I cannot explain why I tried these. (I'm very fairly new to Android Studio).
My build.gradle file looks 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:1.5.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 }
I was facing a similar issue, updating the Gradle version in distributionUrl solved it.
distributionUrl field is present under this directory:
project-root-directory/gradle/wrapper/gradle-wrapper.properties
Please, change
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
with
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
Then change
classpath 'com.android.tools.build:gradle:1.5.1'
with
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
It should work.
For me I think it is permission issue. From Eclipse I have also faced the same issue. On my gradle installation path (i.e. /opt/gradle) I have make it chmod as 777. So that other tool can access the same. Run the following 2 commands -
cd /opt
sudo chmod 777 -R gradle
Java versions > 9 and Gradle versions >= 5.0.0 has some code breaking changes. Here is to go around them using Eclipse. It should be similar in AndroidStudio.
Install the latest version of gradle from its distribution site
("https://services.gradle.org/distributions/") and
unzip the it on your PC.
When importing the gradle project in eclipse select the option "local installation
directory" and point to the folder where you unzip gradle.
(Bonus) if it is a LibGDX project, you need to also change the following in the Desktop
build file due to code breaking changes between gradle versions <5.0.0 and >=5.0.0.
Change "sourceSets.main.output.classesDir" to "sourceSets.main.output.classesDirs".
This is working for me and I am using LibGDX with Java 11 and Gradle 5.2.1 on Windows 10 while running Eclipse 2018-12.
Try deleting the folder gradle-2.4-all in ~/.gradle/wrapper/dists