I use Android Studio 3.1.2 with Gradle 4.4 and have to force Gradle to do off-line work, because when I use it normally (on-line), it takes to long to sync and fails. At first I got this error:
No cached version of com.android.tools.build:gradle:3.1.2 available for offline mode.
Disable Gradle 'offline mode' and sync project
So I downloaded gradle-3.1.2.jar, put it in <project root>/libs/ and change build.gradle of my project to this state:
buildscript {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
Now it seems that previous error is solved but another one is raised:
Unable to load class 'com.android.tools.lint.gradle.api.ToolingRegistryProvider'.
Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)</li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)</li><li>Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.</li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
How I can solve this problem?
Edit
I know the normal way is working on-line, at least for the first build. But there must be a way to add it off-line. Isn't there such way?
This is from android studio manual from this link.
Turn on Offline Mode for Gradle: If you have limited bandwitch, turn
on Offline Mode to prevent Gradle from attempting to download missing
dependencies during your build. When Offline Mode is on, Gradle will
issue a build failure if you are missing any dependencies, instead of
attempting to download them. To turn on Offline Mode, proceed as
follows:
Click File > Settings (on a Mac, Android Studio > Preferences) to
open the Settings dialog.
In the left pane, expand Build, Execution, Deployment and then click
Gradle.
Under Global Gradle settings, check the Offline work checkbox.
Click Apply or OK for your changes to take effect.
In android studio Go to setting menu > Built,Execution and development option > Gradle > mark/unmark on your offline work option and sync your project.try this.
Related
My project was successfully building and all of a sudden I got the below error in Android studio.
Unable to find method 'org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal.getPublishableFiles()Lorg/gradle/api/file/FileCollection;'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
I tried clearing the local dependency cache and rebuilding the project. But still the error persists.
I am using android studio v4.0 with build tools v29.0.2.
Is it because gradle can't download the dependency from maven repo?
Is it because there is an error in configuring maven in my 'respositories' list?
How can I get more information on this error?
Try to update the com.jfrog.artifactory version.
My resolution for this was to update the artifactory version like #disha4mourya suggested - add this block to your project's build.gradle, directly after your buildscript block:
plugins {
id "com.jfrog.artifactory" version "4.18.3"
}
I'd like to be able to work on my project offline. So I disable offline mode, press the "sync project with gradle files" button, then enable offline mode and try to build. However, every time I do, I get the error:
FAILURE: Build failed with an exception.
*What went wrong:
Could not determine the dependencies of task ':app:compileDebugRenderscript'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not resolve androidx.fragment:fragment:[1.2.0].
Required by
project :app > androidx.fragment:fragment-ktx:1.2.0
> No cached version listing for androidx.fragment:fragment:[1.2.0] available for offline mode.
> No cached version listing for androidx.fragment:fragment:[1.2.0] available for offline mode.
I've also tried invalidate cache/restart and then gradle sync before enabling offline mode, with the same result.
I'm running Android Studio 3.6.3
gradle-wrapper.properties contains the fololowing:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
How can I make androidx.fragment:fragment available for offline mode?
There is most likely a dependency resolution problem. When multiple components use the same dependency but with a different version, Gradle goes online to figure out which version to use. That obviously doesn't work in offline mode.
I assume you're using a different fragment dependency (androidx.fragment:fragment) somewhere else, that is selected by default in online mode. Now in offline mode, since no such inspection is possible, Gradle looks for version 1.2.0 (needed by androidx.fragment:fragment-ktx:1.2.0) and can't find it because if was never downloaded/cached.
Better solution is to try making your dependencies refer to the same versions of conflicting sub-dependencies. You can inspect your dependency tree with ./gradlew app:dependencies and update dependencies that are clashing so they use the same versions (if possible).
The other solution is to enforce dependencies in Gradle. You can add something like this to your build.gradle file:
configurations.all {
resolutionStrategy {
if (project.gradle.startParameter.offline) {
// x.y.z being the version that Gradle picks in the online mode.
force 'androidx.fragment:fragment:x.y.z'
}
}
}
I had updated my android studio to version 3.0 and when I tried to build an existing code which works fine in previous version of android studio shows below error.
Error:Could not download compiler.jar (com.android.databinding:compiler:2.3.0): No cached version available for offline mode
My grade version is
classpath 'com.android.tools.build:gradle:2.3.0'
Please help me...
Disable Offline Mode.
Go to File > Settings > type gradle in search > select Gradle under Build Tools > uncheck Offline work
Also, make sure that your internet connection is working properly.
It really seems that you are offline, theres a option on the settings tab for supporting offline mode, it's probably checked, uncheck the box and try again
i also had the same issue solved by using
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
and then goto Build>cleanproject then all worked fine in my side
for more info check https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#update_gradle
I have read through all of the existing stack questions relating to this and their solutions did not help me.
This problem has been evident since all AS updates above 2.3.
Creating a new project is ok and builds
I've attempted to copy all values from the 'new project' but it still persists
The error:
Error:Unable to load class 'org.gradle.api.internal.component.Usage'.
Possible causes for this unexpected error include:Gradle's
dependency cache may be corrupt (this sometimes occurs after a network
connection timeout.) Re-download dependencies
and sync project (requires network)The state of a Gradle
build process (daemon) may be corrupt. Stopping all Gradle daemons may
solve this problem. Stop Gradle build
processes (requires restart)Your project may be using a
third-party plugin which is not compatible with the other plugins in
the project or the version of Gradle requested by the
project.In the case of corrupt Gradle processes, you can
also try closing the IDE and then killing all Java processes.
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip
Project build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha5'
classpath "io.realm:realm-gradle-plugin:0.89.1"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Settings Gradle
Use default gradle wrapper
Module Settings
Compile Sdk Version: API 26
Build Tools Version: 26.0.0
I believe these are all the latest available.
And I have tried invalidate caches & restart / rebooting the machine
I tried all the above suggestions for deleting cache and nothing worked for me. In the end, the problem was the plugin com.novoda:bintray-release:0.4.0. When I upgraded it to 0.5.0, it worked.
I would take a hard look at your gradle plugins!
Delete Gradle cache C:/users/<yourname>/.gradle (delete the whole directory actually). Then upgrade Gradle and try again.
Or if you are using Gradle wrapper go into properties and upgrade the version of the wrapper ./gradle/wrapper/gradle-wrapper.properties
Your question doesn't specify the versions, then I assume this might be your problem.
Edit: Check if your plugins are still Compatible with your version of Gradle
io.realm:realm-gradle-plugin:0.89.1 seems a bit old there is a version 3.5.0 already
Since Gradle 3.4 Usage was renamed to UsageContext and maybe one of your plugins, or dependencies is not compatible with Gradle 4.1-milestone that you are using by looking at the distribution Url.
I installed Android Studio Today,When I Create New Project,the Gradle failed to sync project,(Android Studio 1.2 (JDK 1.7), Windows)
Error:Unable to find method 'org.apache.commons.io.FileUtils.deleteQuietly(Ljava/io/File;)Z'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
I did the above two steps, it doesn't work,When I Click Redownload dependencies,nothing happened(With Internet Connection)
// 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.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
When I update my android studio, I got the same problem. Here is the solution I found: On the project tree "app", right click mouse button to get the context menu. Select "open module setting", on the tree "app" - "properties" tab, select the existing "build tools version". The gradle will start to build.