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
Related
In Mac, I've setup Flutter in Android studio. When I'm running project it gives me error
* What went wrong:
Execution failed for task ':location:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Compilation error. See log for more details
I'm using all latest versions of Flutter, Kotlin, Gradle etc.
You need to equalize kotlin version in first row which is ext.kotlin_version = '1.6.10' to according to classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" of underlined $kotlin_version
After this, the problem will solve...
Actually I found a solution for my problem. There are 2 dependency defined in .yaml file 1. geo_location and 2. location.
After removing the location dependency from .yaml file and run command flutter pub get I can successfully build android build from Mac. This solution might not be global but solution of my problem I found this.
Thank you!
Happy coding.
I have created a Flutter project in Android Studio (Bumblebee | 2021.1.1 Patch 3). When I open the android folder in a seperate window, when the gradle syncing is being executed, it fails with the message Gradle project sync failed. Basic functionality(e.g. editing,debugging) will not work properly. I ran ./gradlew --warning-mode all in the command line and it's output is
Configure project :app
The AbstractArchiveTask.destinationDir property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the destinationDirectory property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:destinationDir for more details.
at FlutterPlugin$_addFlutterTasks_closure21$_closure47.doCall(/home/sudipta/snap/flutter/common/flutter/packages/flutter_tools/gradle/flutter.gradle:863)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
The AbstractArchiveTask.archiveName property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveFileName property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:archiveName for more details.
at FlutterPlugin$_addFlutterTasks_closure21$_closure47.doCall(/home/sudipta/snap/flutter/common/flutter/packages/flutter_tools/gradle/flutter.gradle:864)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
> Configure project :system_alert_window
WARNING: The option setting 'android.enableR8=true' is deprecated.
It will be removed in version 5.0 of the Android Gradle plugin.
You will no longer be able to disable R8
> Task :help
Welcome to Gradle 6.7.
To run a build, run gradlew <task> ...
To see a list of available tasks, run gradlew tasks
To see a list of command-line options, run gradlew --help
To see more detail about a task, run gradlew help --task <task>
For troubleshooting, visit https://help.gradle.org
The last warning is due to system_alert_window (flutter)plugin that I am using. But these deprecation warnings are causing issues in Android Studio editor so that I am unable to use code completion feature. I don't know why is this happening, since these are only warning messages.
My gradle version is 6.7 and android-gradle version is 4.1.0.
Can anyone please help?
TRY this steps-
Step 1:
Open the gradle.properties file same like given Image-
https://i.stack.imgur.com/S2Y0a.png
Step 2:
Disable android.enableR8=true by adding a # in front:
#android.enableR8=true
Alternatively, you can swap out the R8 for D8, The build system changed to using D8 instead of R8.
android.enableD8=true
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.
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.
I'm debugging Gradle issues in Android Studio and see references to "Run gradle sync", but I'm not sure how to run this command.
How do I run "Gradle sync" from Android studio or Mac terminal?
Android studio should have this button in the toolbar marked "Sync project with Gradle Files"
EDIT: I don't know when it was changed but it now looks like this:
EDIT: This is what it looks like on 3.3.1
OR by going to File -> Sync Project with Gradle Files from the menubar.
WARNING: --recompile-scripts command has been deprecated since gradle's version 5.0.
To check your gradle version, run gradle -v.
./gradlew --recompile-scripts
it will do a sync without building anything.
Alternatively, with command line in your root project
./gradlew build
It will sync and build your app, and take longer than just a Gradle sync
To see all available gradle task, use ./gradlew tasks
In Android Studio 3.3 it is here:
According to the answer https://stackoverflow.com/a/49576954/2914140 in Android Studio 3.1 it is here:
This command is moved to File > Sync Project with Gradle Files.
Keyboard shortcut lovers can add a shortcut for running gradle sync manually by going to File -> Settings -> Keymap -> Plugins -> Android Support -> Sync Project with gradle files (Right click on it to add keyboard shortcut) -> Apply -> OK and you are done. Choose any convenient key as your gradle sync shortcut which doesnot conflict with any other shortcut key, (I have choosen Shift + 5 as my gradle sync key), so next when you want to run gradle sync manually just press this keyboard shortcut key.
I presume it is referring to Tools > Android > "Sync Project with Gradle Files" from the Android Studio main menu.
gradle --recompile-scripts
seems to do a sync without building anything.
you can enable automatic building by
gradle --recompile-scripts --continuous
Please refer the docs for more info:
https://docs.gradle.org/current/userguide/gradle_command_line.html
Shortcut (Ubuntu, Windows):
Ctrl + F5
Will sync the project with Gradle files.
I think ./gradlew tasks is same with Android studio sync. Why? I will explain it.
I meet a problem when I test jacoco coverage report. When I run ./gradlew clean :Test:testDebugUnitTest in command line directly , error appear.
Error opening zip file or JAR manifest missing : build/tmp/expandedArchives/org.jacoco.agent-0.8.2.jar_5bdiis3s7lm1rcnv0gawjjfxc/jacocoagent.jar
However, if I click android studio sync firstly , it runs OK. Because the build/../jacocoagent.jar appear naturally.
I dont know why, maybe there is bug in jacoco plugin. Unit I find running .gradlew tasks makes the jar appear as well. So I can get the same result in gralde script.
Besides, gradle --recompile-scripts does not work for the problem.
I have a trouble may proof gradlew clean is not equal to ADT build clean. And Now I am struggling to get it fixed.
Here is what I got:
I set a configProductID=11111 from my gradle.properties, from my build.gradle, I add
resValue "string", "ProductID", configProductID
If I do a build clean from ADT, the resource R.string.ProductID can be generated. Then I can do bellow command successfully.
gradlew assembleDebug
But, as I am trying to setup build server, I don't want help from ADT IDE, so I need to avoid using ADT build clean. Here comes my problem.
Now I change my resource name from "ProductID" to "myProductID", I do:
gradlew clean
I get error
PS D:\work\wctposdemo> .\gradlew.bat clean
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\work\wctposdemo\app\build.gradle'
* What went wrong:
Could not compile build file 'D:\work\wctposdemo\app\build.gradle'.
> startup failed:
General error during semantic analysis: Unsupported class file major version 57
If I try with:
.\gradlew.bat --recompile-scripts
I just get error of
Unknown command-line option '--recompile-scripts'.
Anyone wants to use command line to sync projects with gradle files, please note:
Since Gradle 5.0,
The --recompile-scripts command-line option has been removed.
https://docs.gradle.org/5.0/userguide/upgrading_version_4.html#potential_breaking_changes
https://docs.gradle.org/current/userguide/command_line_interface.html
https://github.com/gradle/gradle/issues/1425
From terminal:
gradle prepareKotlinBuildScriptModel
NOTE: you can see what android studio is doing by inspecting the "Build" tab. There will be difference windows inside there. One should be "Sync"