Gradle Android task crashing with unclear error - android

I am trying to run a Gradle Android task generated by libGDX utility (the desktop task runs fine) in IntelliJ IDEA, but I'm only getting this nonspecific error message. What is the issue, or where are the logs, or how to enabled logs?
Information:Gradle: Executing tasks: [:core:assemble, :android:assembleDebug]
Information:24. 10. 2015 16:58 - Compilation completed with 1 error and 0 warnings in 9s 415ms
Error:Gradle: Execution failed for task ':android:proguardDebug'.
> java.io.IOException: Please correct the above warnings first.
PS: Not sure if it is relevant, but I have modified build files and ProGuard file to support Scala as described there.

I did not find a way of getting any useful logs from IntelliJ IDEA. I solved the problem by running Gradle from console.
gradlew assemble --stacktrace --info
Problem was Gradle could not find tools.jar. Adding system environment variable JAVA_HOME pointing to Java SDK directory fixed the issue.

Related

Android Execution failed for task ':app:compileDebugJavaWithJavac'. - React Native

I am working on a react native application. when I try to build the applications using react-native run-android the build fails. Here is the output of the error that occurs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 8s
253 actionable tasks: 5 executed, 248 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: ./gradlew app:installDebug
debug Error: Command failed: ./gradlew app:installDebug
at checkExecSyncError (child_process.js:607:13)
at execFileSync (child_process.js:627:13)
at runOnAllDevices (/Users/FaisalHussain/mobile/node_modules/#react-native-community/cli/build/commands/runAndroid/runOnAllDevices.js:58:39)
at buildAndRun (/Users/FaisalHussain/mobile/node_modules/#react-native-community/cli/build/commands/runAndroid/runAndroid.js:142:41)
at then.result (/Users/FaisalHussain/mobile/node_modules/#react-native-community/cli/build/commands/runAndroid/runAndroid.js:104:12)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
The application was on a old version of react native (0.48.x) I have updated it to 0.59.10.
What I have done so far:
used jetifier to resolve issues with the plugins.
checked that the build tools version matches the compile sdk version
checked if the emulator is running.
Hence I have tried everything I could to resolve this but had no luck. Please do guide me on how to resolve this issue. Looking forward to your answers.
make sure you have followed all the necessary steps from the upgrade helper https://react-native-community.github.io/upgrade-helper/?from=0.48.0&to=0.59.10
also i would suggest you to upgrade to v0.60+ because there are breaking changes after v0.59.10.
having said that
before you run the app make sure your gradle is clean
run the following command to clean your gradle cd android && ./gradle clean
then later you can navigate back to your app folder cd .. and try and run again react-native run-android
Looks like your packages not working stable with Android side. It's better be update all packages and react native version to their last stable versions.
If you face with too much error while update, you can create fresh new react native project (with same package name with your current project), install all packages (and their dependencies) and copy your current project's source code to your new project.
Android in React Native does not allow similar packages to reside in the project.
In my case I had react-native-cookies and #react-native-cookies/cookies packages that add similar code to the Kotlin file upon build. This causes issue of similar imports in java JDK.
I removed one and it worked.
SOLVED at the same issue:
My solution was at /android/build.gradle file.
Somehow, the buildscript versions were wrong.
Follow the exact same step of RN documentation and make a totally new & clean project.
And compate the /android/build.gradle file > buildscript & dependencies part.
There should be some version differences.
It matters by your own local env settings.
After changing buildToolsVersion, ndkVersion, classpath, it worked fine again!!
also, remove duplicated libraries, as #Nimantha said.

program Execution failed for task ':compileDebugJavaWithJavac

I installed Android Studio version 3.2.1 on Windows 10. My Gradle doesn't build after trying for around 2 days. I have a problem that I don't understand. When I run the program, execution fails for task :compileDebugJavaWithJavac. What can I do?
try command "gradlew assembleDebug -is" in your IDE terminal, it will tell you where your code error occurred. BTW, javac task error means your code cannot pass java compiler ,and your picture showed the errors , such as " cannot find symbol class R..."

:app:transformDexArchiveWithDexMerger IllegalStateException using AS 3.0 beta6

I've started getting following error after updating to AS 3.0 beta 6. Has anyone else come across this? I'm only seeing this error when I try to build/run from AS.....no issue if I run gradle on command line.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithDexMergerFor<BuildVariantName>Debug'.
> com.android.build.api.transform.TransformException: java.lang.IllegalStateException
Thanks to #Nabin in the comments we found out that enabling Instant Run fix that issue.
Unfortunately - other than the original poster - we had the same issue on the command line. Which means our CI doesn't run.
We found out that we can disabling the incremental dexing by setting the flag -Pandroid.useDexArchive=false. See here for more infos:
A new incremental dexing pipeline has been implemented. Now the Gradle plugin dex only the class files that have changed. It is enabled by default, but you can disable it by doing one of the following:
Passing -Pandroid.useDexArchive=false when running builds from command line e.g. ./gradlew :app:assembleDebug -Pandroid.useDexArchive=false.
Adding android.useDexArchive=false to the gradle.properties file in your root project.
Luckily we don't need incremental dexing on our CI.
Unfourtnaly it doesn't help us in Android Studio with disabled Instant Run!

Execution failed for task ':app:mockableAndroidJar'

I am using local gradle of version 2.4 and IntelliJ IDEA 14.1.3
When I run project from IntelliJ it runs fine but when execute gradle clean build command from command line it gives the flowing exception and build fails.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mockableAndroidJar'.
> java.util.zip.ZipException: invalid entry compressed size (expected 2051 but got 2050 bytes)
This looks like an old ques which is not yet answered yet.
I got into same problem, when my jar files could not be read by Android Studio and it gave me the above mentioned error.
Taking lead from the comment by -Mikhail Boyarsky I changed classpath in build.gradle file to 'com.android.tools.build:gradle:2.2.3'.
Synced project and it started working.
I solved it by changing com.android.tools.build:gradle:2.3.0 version to 2.2.3, then build it with another exception and then I changed the version back to 2.3.0.
Not sure how it works, looks like a gradle bug.

Android Studio and Gradle build error

I've been using the new preview of android studio and really like it. But recently my project won't build. I get the following error:
Gradle:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':TestProj:compileDebug'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
Question is how do I enable the stack trace so I can get to the root of the error. As it is I really have no idea what's causing this.
If you are using the Gradle Wrapper (the recommended option in Android Studio), you enable stacktrace by running gradlew compileDebug --stacktrace from the command line in the root folder of your project (where the gradlew file is).
If you are not using the gradle wrapper, you use gradle compileDebug --stacktrace instead (presumably).
You don't really need to run with --stacktrace though, running gradlew compileDebug by itself, from the command line, should tell you where the error is.
I based this information on this comment:
Android Studio new project can not run, throwing error
Similar to #joe_deniable 's answer the thing I found with my own projects was that gradle would output that kind of error when there was a misconfiguration of my system.
I discovered that by running gradlew installDebug or similar command from the terminal I got better output as to what the real problem was.
e.g. initially it turns out my JAVA_HOME was not setup correctly. Then I discovered it encountered errors because I didn't have a package space setup correctly. Etc.
The only solution I've found is to first create the project in Android Studio, then close the project, then import the project. I searched all over and could not find the root cause and all other solutions people posted didn't work.
OK seems like a caching issue of some sort. There was indeed an error in code with the R.id.some_id not being found but the editor was not picking it up displaying that there were no errors.
I installed Android Studio on an old WinXP with only for me option. After install I did the new project wizard and when opening the new project a got some Gradle error with some failed path to my instalation dir. c:/Document"#¤!"#¤ and settins/...
The I uninstalled and did a new install with option for all users (C:/Programs/..) then I opend the previous created project with no errors.
So it might be a path problem. (Just spent 10 sec debugging, so I might be wrong but it solved my gradle error)
I found this post helpful:
"It can happen when res folder contains unexpected folder names. In my case after merge mistakes I had a folder src/main/res/res. And it caused problems."
from: "https://groups.google.com/forum/#!msg/adt-dev/0pEUKhEBMIA/ZxO5FNRjF8QJ"
I used a local distribution of gradle downloaded from gradle website and used it in android studio.
It fixed the gradle build error.
Edit the gradle wrapper settings in gradle/wrapper/gradle-wrapper.properties and change gradle-1.6-bin.zip to gradle-2.4-bin.zip.
./gradle/wrapper/gradle-wrapper.properties :
#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip
It should compile without any error now.
Note: update version numbers with the most recent ones

Categories

Resources