I just ruined my android project. I touched the Project structure added a dependency (for gdx-tools). There weren't any dependencies before. Now Gradle cannot find find any libraries.
Error:(32, 0) Gradle: A problem occurred evaluating project ':android'.
> Could not resolve all dependencies for configuration ':android:natives'.
> A problem occurred configuring project ':core'.
> Could not open buildscript class cache for build file '..\build.gradle' (..\.gradle\caches\1.11\scripts\build_5nf261mprglcnmchu7kvpoddt6\ProjectScript\buildscript).
> Timeout waiting to lock buildscript class cache for build file '..\core\build.gradle' (..\.gradle\caches\1.11\scripts\build_5nf261mprglcnmchu7kvpoddt6\ProjectScript\buildscript). It is currently in use by another Gradle instance.
Owner PID: unknown
Our PID: 3732
Owner Operation: unknown
Our operation: Initialize cache
Lock file: ..\.gradle\caches\1.11\scripts\build_5nf261mprglcnmchu7kvpoddt6\ProjectScript\buildscript\cache.properties.lock
Anyone knows how to fix this, without generating a new project?
Exit Android Studio, clear out the Gradle cache folder whose path is in the error message, and relaunch.
There is a cache which gradle maintain for all the dependancies which we add in build.gradle file in user's directory.
In Windows:
C:\Users\Administrator.gradle\caches
In Mac:
/Users/UserName/.gradle/caches
Delete the caches folder. Now next time when you run gradle sysc then it will download all dependencies again and the problem of lock should be resolved.
This problem is also reported as an issue: https://issues.gradle.org/browse/GRADLE-2795
This lock issue happened to me when I was running
gradle run
in another bash window.
I just had to stop that to get it working again.
Related
I am a new app developer and, I am trying to build up the foundation of the knowledge by following the instructions from an online course (https://developer.android.com/codelabs/build-your-first-android-app#8) given by the android developer page in using Android Studio with Java.
After I add the lines to the project gradle file:
def nav_version = "2.3.0-alpha04"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
and to the app gradle file:
apply plugin: 'androidx.navigation.safeargs'
My project is failed to synchronize with the Gradle files. Could someone solve the error and explain this error to me? I have tried to rebuild the project, but it didn't work out.
Below is the code and the error:
Error:
class org.codehaus.groovy.ast.expr.TupleExpression cannot be cast to class org.codehaus.groovy.ast.expr.ArgumentListExpression (org.codehaus.groovy.ast.expr.TupleExpression and org.codehaus.groovy.ast.expr.ArgumentListExpression are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader #42d80b78)
class org.codehaus.groovy.ast.expr.TupleExpression cannot be cast to class org.codehaus.groovy.ast.expr.ArgumentListExpression (org.codehaus.groovy.ast.expr.TupleExpression and org.codehaus.groovy.ast.expr.ArgumentListExpression are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader #42d80b78)
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.
Code:
enter image description here
enter image description here
enter image description here
Can you try below lines As It's working fine for me.
// Add to Porject level gralde file
def nav_version = "2.3.5"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
//Add to Module level gralde file.
id "androidx.navigation.safeargs.kotlin"
Difference b/w androidx.navigation.safeargs.kotlin and androidx.navigation.safeargs
id 'androidx.navigation.safeargs' is for Java/Kotlin mixed modules
id 'androidx.navigation.safeargs.kotlin' is for pure Kotlin modules.
Plus put the plugin at the end e-g check below example
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'androidx.navigation.safeargs.kotlin'
}
Other Info, You can try below options as well.
-Check If the Gradle is on online mode not offline (Right side menu bar click on Gradle =//= check If that sign is not pressed.)
-Clean your project then rebuild
-Invalidate Cache and Restart
i'm trying to reBuild and compile my Android Studio project, it worked good before installing the new version of react-native-jumio-mobilesdk for react native. After upgrading that library to 3.9.1, i had this error and i have not been able to fix it.
> Task :react-native-jumio-mobilesdk:compileDebugKotlin FAILED
Execution failed for task ':react-native-jumio-mobilesdk:compileDebugKotlin'.
Could not resolve all files for configuration ':react-native-jumio-mobilesdk:debugCompileClasspath'.
Failed to transform bcprov-jdk15on-1.67.jar (org.bouncycastle:bcprov-jdk15on:1.67) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for JetifyTransform: C:\Users\UsuarioDA1.gradle\caches\modules-2\files-2.1\org.bouncycastle\bcprov-jdk15on\1.67\8c0998045da87dbc2f1d4b6480458ed811ca7b82\bcprov-jdk15on-1.67.jar.
> Failed to transform 'C:\Users\UsuarioDA1.gradle\caches\modules-2\files-2.1\org.bouncycastle\bcprov-jdk15on\1.67\8c0998045da87dbc2f1d4b6480458ed811ca7b82\bcprov-jdk15on-1.67.jar' using Jetifier. Reason: IllegalArgumentException, message: Unsupported class file major version 59. (Run with --stacktrace for more details.)
Please file a bug at http://issuetracker.google.com/issues/new?component=460323.
I have one entire week trying to fix it but so far I have not been able.
I appreciate your help. :D
For me the issue occured when I tried to update the firebase crashlytics gradle plugin to 2.7.1.
It was possible to fix it by setting android.jetifier.blacklist=bcprov-jdk15on in gradle.properties as mentioned here.
Try this :
clear project cache
upgrade packages for ex. in flutter we use flutter pub get
add :
android.jetifier.blacklist=bcprov-jdk15on
to your gradle.properties file and rebuild the project. if not resolved please refer to similar issue on github and google
I have following directory structure:
D:\PROJECT
+---javaGradleProject1
+---javaGradleProject2
+---javaGradleProject3
\---AndroidProject
| build.gradle
| settings.gradle
\---AndroidModule
build.gradle
Android module depends on all of java gradle projects that are at the same level in root directory as AndroidProject.
In AndroidProject/settings.gradle I have:
include ':AndroidModule'
include 'javaGradleProject1'
project(':javaGradleProject1').projectDir = new File(rootDir, '../javaGradleProject1')
include 'javaGradleProject2'
project(':javaGradleProject2').projectDir = new File(rootDir, '../javaGradleProject2')
include 'javaGradleProject2'
project(':javaGradleProject2').projectDir = new File(rootDir, '../javaGradleProject2')
And then in AndroidProject/AndroidModule/build.gradle I have dependencies set like this:
compile project(':javaGradleProject1')
compile project(':javaGradleProject2')
compile project(':javaGradleProject3')
This structure of dependency perfectly works and project builds when I invoke
gradle build
on AndroidProject/build.gradle.
But when I try to synchronize my IntelliJ with current gradle dependency settings I receive
Error: Unable to find module with Gradle path ':javaGradleProject1'
Error: Unable to find module with Gradle path ':javaGradleProject2'
Error: Unable to find module with Gradle path ':javaGradleProject3'
and because of that my project cannot be run from Run Configurations (it does not compile at all in IDE). I was trying to add these dependencies manually by hitting F4 and module dependencies but after synchronization all of my changes are overwritten (actually, IntelliJ just removes it).
Is there anything wrong in my gradle structure?
I have tested it on IntelliJ IDEA 14.1.4 and Android Studio 1.3.
I was able to solve this by deleting the settings.gradle file from every Gradle project that I wanted to use as dependency (clearing the contents of this file was not enough).
NOTE: As I have little knowledge of Gradle and Android Studio, I cannot provide information about why the presence of this file does not allow Android Studio to include the Gradle project as a module.
Add a colon (:) before the names of your modules when you add it in settings.gradle, e.g. for the first one, change this:
include 'javaGradleProject1'
project(':javaGradleProject1').projectDir = new File(rootDir, '../javaGradleProject1')
to this:
include ':javaGradleProject1'
project(':javaGradleProject1').projectDir = new File(rootDir, '../javaGradleProject1')
Now in addition to compiling, IntelliJ / Android Studio should give you code completion.
In my case I had to change the external module name to lowercase only.
Right click project, Select
"Configure Project Subset ..."
and select your module, rebuild your project.
Tried all the available solutions, and in last I have commented the include ':app' in settings.gradle and this resolved the issue in my case
In my case non of the answers above resolved it.
Finally, I went to settings.gradle file and inside the dependencyResolutionManagement block, I changed the repositoriesMode to "PREFER_PROJECT"
repositoriesMode.set(RepositoriesMode.PREFER_PROJECT)
That was all I did and it worked like magic, maybe such can help you too, you can try it out.
*THIS PART WAS MY ORIGINAL STARTING PROBLEM. PLEASE READ THE UPDATES
I have imported an android project in eclipse that apparently depends on rengwuxian.
Since I could not find the jar and did not know how else to do it, I followed the instructions in consuming-aars-eclipse and imported a second project with the artifacts from the aar as an android eclipse project as well.
Then in my original project that I got compilation errors for com.rengwuxian.materialedittext.MaterialEditText in my layout files I added this newly created from the aar project as a reference (Project->Properties->Build Path->Add Project)
The compilation errors got resolved! But in my layout files now everywhere that is defined the element com.rengwuxian.materialedittext.MaterialEditText I get errors in the resource definitions.
Eg.the following:
error: No resource identifier found for attribute 'baseColor' in
package 'com.test
The attibute it seems to complaint about is:
<com.rengwuxian.materialedittext.MaterialEditText
android:id="#+id/client"
android:layout_width="match_parent"
android:layout_height="wrap_content"
.....
android:textColor="#color/text_color"
app:baseColor="#color/text_color"
app:primaryColor="#color/text_color" />
---> app:baseColor="#color/text_color"
This #color/text_color is defined in my original application in the original application's package and apparently the classes in the aar imported project (com.rengwuxian.materialedittext.MaterialEditText) can not see/access these resources.
How can I fix this? Or is there another better way for my problem?
Note: I also tried adding a source link to the folder of my project's res/ folder but did not solve this.
Update:
I removed the reference to the project and add the classes.jar to the build path (this jar was inside the aar project). Same issue
UPDATE 2:
I found this that helps to import aars to eclipse aar-for-eclipse. I copy/pasted the code snippets (task copyJarDependencies etc) in the folder but I got an exception:
No such property: libDir for class: org.gradle.api.tasks.Copy_Decorated
So I added a def in the line `libDir = new File(project.projectDir, '/libs')
Then this worked but I got:
Could not find property 'compile' on configuration container
How can fix this? I am not sure what to declare or what is missing
Update 3:
I added apply plugin: 'java' and the compile attribute is ok now but I get:
configurations.releaseCompile.filter {it.name.endsWith 'jar'}.each { File file -> moveJarIntoLibs(file)}
How can I fix this so that it works?
I am using this project ---> https://github.com/rengwuxian/MaterialEditText
And this post ---> http://www.nodeclipse.org/projects/gradle/android/aar-for-Eclipse
I've got a similar problem with gradle but on android studio. Solution for me was to use
configurations.releaseCompile.filter {it.name.endsWith 'jar'}.each {moveJarIntoLibs(it)}
instead of:
configurations.releaseCompile.filter {it.name.endsWith 'jar'}.each { File file -> moveJarIntoLibs(file)}
And remember not to apply java and android plugin in the same project, because it won't work (see gradle with --debug --stacktrace )
After compiling my Android application using the Android Studio (Beta), I have the following error:
Error:error: Resource entry background is already defined.
res\drawable-xhdpi-v4\background.9.png:0: Originally defined here.
This occurred when I had a image file called "background" in my res folder.
I then made a 9 patch version of it and pasted it in the same folder. This meant that there was 2 files with the same name. So I unsurprisingly I had this error.
However I now deleted all instances of the background image file (including the 9 patch version and original image) in my code and layout file and I still have this error.
You could try to do one of the following:
Clean and Build or gradle clean build assemble
Invalidate and restart Android Studio
1 Build > Clean Project
2 Build > Rebuild Project
I am using Android studio and I run exactly into the same issue and none of the answers I found on the web helped me solve the problem, including the previous one. So reading through all details of the error messages and found this lines:
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\user\AppData\Local\Android\android-studio\sdk\build-tools\android-4.4W\aapt.exe package -f --no-crunch -I C:\Users\user\AppData\Local\Android\android-studio\sdk\platforms\android-20\android.jar -M C:\Users\user\AndroidStudioProjects\DartsApp\app\build\intermediates\manifests\debug\AndroidManifest.xml -S C:\Users\user\AndroidStudioProjects\DartsApp\app\build\intermediates\res\debug -A C:\Users\user\AndroidStudioProjects\DartsApp\app\build\intermediates\assets\debug -m -J C:\Users\user\AndroidStudioProjects\DartsApp\app\build\generated\source\r\debug -F C:\Users\user\AndroidStudioProjects\DartsApp\app\build\intermediates\libs\app-debug.ap_ --debug-mode --custom-package com.dartstransit.dartsapp -0 apk --output-text-symbols C:\Users\user\AndroidStudioProjects\DartsApp\app\build\intermediates\symbols\debug
Error Code:
1
Output:
res\drawable-hdpi-v4\bus_w.png:0: error: Resource entry bus_w is already defined.
res\drawable-hdpi-v4\bus_w.jpg:0: Originally defined here.
As you can see there are two files of name bus_w with different extensions on the same folder. I had already removed those files from the project and still getting the error, so I decided to check every single folder of the project that was reference in the compiler line in the error message. Finally found that there was a copy of the file bus_w.png in the folder app\build\intermediates\res\debug\drawable-mdpi-v4.
I just deleted it and voila, problem solved.
A simple Build > Rebuild project helped me
Did you try rename this file to other name? It seem one of your libraries have same resource.
I see that many devs(include me) had issue with ic_launcher too. I think you want to try mipmap instead drawable. So we will have something like this:
\res\mipmap-hdpi
\res\mipmap-mdpi
\res\mipmap-xhdpi
\res\mipmap-xxhdpi
Hope this help.
I have also encountered this error recently.Here is my solution that works,hope it will help you.
1.only keep 9 patch version image in the drawable-hdpi folder
2.make sure the code related to this problem in xml file remains the same: android:background="#drawable/msg_left"
instead of using the code:
android:background="#drawable/msg_left.9"
PS:My original image name is msg_left,and my 9 patch version image name is msg_left.9
I did the trick by moving the icon
drawable/ic_launcher
to
mipmap/ic_launcher
and it worked fine :)
In my case the problem was that I had more than one '.' in the filename. like:
a.png
a.bold.png
Solution was to rename to
a.png
a_bold.png
In our case, problem started occurring (error shows 'duplicate value for resource' in a library) when some other library was upgraded to it's latest version.
We just downgraded the version of the library that was upgraded.
Real pain was because that we have many dependencies which can be dynamically upgraded when there is a new version available in repositories. So my teammate had to go through all libs that can be dynamically upgraded and see if there is one that is recently upgraded, try to downgrade it and check if build goes fine. He identified many were upgraded on previous day. Downgrading one of them got the build back.
Conclusion we made is not to use Dynamic Versioning. Don't use dynamic versions for your dependencies.
This was the error by the way:
Task :app:generateDebugResources UP-TO-DATE
AGPBI: {"kind":"error","text":"error: duplicate value for resource \u0027attr/itemBackground\u0027 with config \u0027\u0027.","sources":[{"file":"/Users/unknownuser/.gradle/caches/transforms-1/files-1.1/singledateandtimepicker-1.2.2.aar/86ae3786d70c769e610c8a01d58aa638/res/values/values.xml","position":{"startLine":15,"startColumn":4,"startOffset":2427,"endColumn":48,"endOffset":2471}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource previously defined here.","sources":[{"file":"/Users/unknownuser/.gradle/caches/transforms-1/files-1.1/singledateandtimepicker-1.2.2.aar/86ae3786d70c769e610c8a01d58aa638/res/values/values.xml","position":{"startLine":15,"startColumn":4,"startOffset":2427,"endColumn":48,"endOffset":2471}}],"original":"","tool":"AAPT"}
Task :app:mergeDebugResources FAILED
Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
FAILURE: Build failed with an exception.