New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't find Gradle (Android Studio) #845
Comments
Torturous indeed |
does the |
@breautek I can't remember exactly. It always worked before last Android Studio update or new setup. But know I see in the Android Studio path the Gradle folder. I could set the enviroment variable to this path instead of downloading gradle separatly. But currently it works with my workaround from my prev. post. But the path to |
For me I have (I'm running linux) I don't remember if I have this set because of cordova or for another reason. But cordova does search for paths for other requirements like java for example, so I can't see why it shouldn't search for plausible locations for gradle either. |
gradle lookup for windows happens here... cordova-android/bin/templates/cordova/lib/check_reqs.js Lines 90 to 113 in c35a990
It has comments about a hackish solution, so perhaps there is room for improvements here. |
On another PC (with a newer version of Android Studio) there is no In the Summary it's a bit more difficult to find the Gradle stuff for Cordova. :/ |
check_reqs.js for Windows should check Cordova won't like gradle 5 during build process so it will download version 4.10.3 to Installing gradle to |
I think there simply is no more gradle bin anymore, its a .jar in android-studio/plugins/gradle/lib and cordova is not uptodate with that change. When i add the android platform, open android studio and import exisitng gradle project i can build and run my cordova app for one time. Then when I need to do a cordova build because of the changes its complaining about the gradle bin. So there does not sem to be another way than install gradle standalone and work with its bin. |
I can confirm,
Workaround: I installed gradle 6.1 to C:\Gradle and added C:\Gradle\bin to my |
Do note that android studio doesn't officially support gradle 6 (although still may work just fine) See https://developer.android.com/studio/releases/gradle-plugin#updating-gradle |
I wish this worked on my linux install. Unbuntu 18.04 The strange thing is from the command line I can issue gradle -v and it can find it. I do not understand why cordova build android fails saying that it cannot |
Workaround: Create a symlink to the new directory using an Administrator command prompt.
|
On windows installs, as both @domske @mbayadinov stated, gradle now exists in I had to add a new path for |
Why has this not been fixed in Cordova?? Every 6 months I come back to use Cordava and it's broken.. Who is maintaining it? |
i fix this issue here https://youtu.be/54mtkVh7yXs |
I have pinned this issue, which has the help wanted label. Most of the maintainers are volunteers, unfortunately pretty overloaded, and dealing with some other requirements in the major Cordova release. This thread on the mailing list ([1]) about modernizing the cordova-android build may be of interest. |
I had to rebuild my development workstation and I revisited the topic on Linux. I'm finding that android-studio-ide-183.5692245-linux.tar.gz Android Studio v3.4.2 works fine with Cordova CLI 10.0.0. Android Studio v3.4.2 builds the App for API 29/30 and the artifacts are ok for the upcoming Google Play November deprecation (when Apps built with previous API versions are not going to be accepted anymore). The following Android Studio versions (v3.5.3, v3.6.3 and v4.0.2) don't have gradle as a standalone executable. However, the latest Android Studio v4.0.2 can be downloaded and installed to configure the general environment; and then, install $ cordova build
....
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=..../android-sdk (recommended setting)
ANDROID_HOME=..../android-sdk (DEPRECATED)
Using Android SDK: ..../android-sdk
Welcome to Gradle 6.6.1!
Here are the highlights of this release:
- Experimental build configuration caching
- Built-in conventions for handling credentials
- Java compilation supports --release flag
For more details see https://docs.gradle.org/6.6.1/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
BUILD SUCCESSFUL in 3s
1 actionable task: 1 executed
Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :app:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 14s
40 actionable tasks: 40 executed
Built the following apk(s):
..../platforms/android/app/build/outputs/apk/debug/app-debug.apk |
Thank you for your analysis @anibalsanchez So I think the best course of action is to improve the error message as simply installing android studio is no longer applicable, as the cordova error states, and ensure our documentation is updated for configuring Gradle. |
Hi Guys,
Thought: If Google are going to continually change perhaps we set our variables independently of them - say CORDOVA_JDK and CORDOVA _GRADLE and just set them once on our machine.. Many thanks for your hard work.. |
I think this is a good idea.
Also 👍
Android Studio doesn't appear to include a gradle install anymore. Even the path located in my previous comment doesn't exist anymore. I'm not sure about other OS' but on linux I had to install gradle myself. |
Not sure how I reply to my previous post? |
Short answer: There is no configuration variable that you can set to tell just cordova to use a specific JDK installation. Long answer: There are potentially some workarounds to make only Cordova use a specific JDK installation... such as providing the system variable inline with the cordova command:
I haven't tested this, but you may need to override the
Obviously this isn't ideal to type out every single time, but it could be incorporated into a build script. I personally would support a |
It turns out that most of my students already have JDK8 because of some other software they had to use..The problem is the class machines - I will try and work it through with the techs.. JDK8 appears ok for Android Studio.. Whilst not ideal it is simple just to install Gradle external to AS. So is this how a proposal is put for a change like " CORDOVA_JDK and CORDOVA _GRADLE"? It would give us some independence.. Thanks.. P |
I encountered this problem on 11/15/20. I tried adding 'GRADLE_HOME' variable to both user and system environment settings with the path to gradle (default location inside /USERS/{USER}/.gradle ) to no avail. I ended up having to install Gradle from the website (binary version) and adding that to the end of the System 'Path' variable. |
Hi, a new year - does Cordova support a newer version of Java than 8? |
No. The blocking element here to support newer versions is the android SDK, which contains programs like the |
Thanks - does this mean that all frameworks trying to output a pkg file have to have Java 8 - React - Natice OR Angular - Capacitor - View etc - this seems very strange.. |
Afaik, building android apps can be done with modern Java versions, but the android sdk tools to manage the android emulators or the android SDKs can only be used with Java 8. Because of the latter, Cordova requires Java 8. |
Actually I was thinking - can we use the Android Java Version - Open Source as I understand it.. It would be good to tell Cordova to use that and allow the system to install a modern version for other apps - as inevitably people will install Android Studio - for the emulator and convenience- I know there are emulator alternatives - just a thought.. |
We could probably use the java install included in Android studio, but we cannot rely on only this option. We still need to support environments without an AS install, generally for CI environments, for example. This is kinda off topic though and not related to gradle. AS has gradle lib files, but I don't think they have an actual executable. So I'm not sure if the same strategy would work for gradle. |
Ultimately for gradle, you need to expose |
Closing. It's now documented that Gradle needs to be installed. |
Bug Report
Problem
Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio.
What is expected to happen?
Just work. The message is wrong. Android Studio is already installed.
Leave a link to the docs for this problem. Because everything is correctly setup (by the message).
Also the enviroment path variables are set.
What does actually happen?
The Android Studio is installed and I can use it. I already installed a apk by the Studio and Flutter.
But Cordova does not work.
Information
The whole Android enviroment and JDK 1.8 (8), Ionic, Cordova etc. are installed.
I can run Android apps on my physical phone. e.g. using Flutter and the Android Studio.
It's always tortuous to bring Cordova Android to get running.
Command or Code
ionic cordova run android
Environment, Platform, Device
Running Cordova 9 with native-run of Ionic 4 on Windows 10 64bit.
Version information
Click to expand
Ionic:Ionic CLI : 5.2.5
Ionic Framework : @ionic/angular 4.9.0
@angular-devkit/build-angular : 0.801.3
@angular-devkit/schematics : 8.1.3
@angular/cli : 8.1.3
@ionic/angular-toolkit : 2.0.0
Cordova:
Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.0.0
Utility:
cordova-res : not installed
native-run : 0.2.8
System:
NodeJS : v10.16.3
npm : 6.9.0
OS : Windows 10
Checklist
Workaround
Install Gradle manually. Maybe the latest Android Studio does not include it for external usage. Whatever... Cordova should remove it from the error text. Because it's not solved by installing the Android Studio. In my case I already had and set up the environment variables. But still not worked.
The text was updated successfully, but these errors were encountered: