Error: Could not find an installed version of Gradle - android-studio

I am working on an Ionic 5 project. I have installed Android Studio Bumblebee, but when I run ionic cordova run android, I get below error. To my understanding, Gradle is automatically installed when I install the Android Studio. Do I need to install Gradle additionally?
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=undefined (DEPRECATED)
Using Android SDK: C:\Users\wdwb_\AppData\Local\Android\sdk
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

Please have a look at the documentation. You might need to install Gradle according to your OS.

I fixed it by installing gradle like this (mac): brew install gradle

Related

All SDK build tool installed, but error showing "No installed build tools found. Install the Android build tools version 19.1.0 or higher." ionic

IF I build from terminal, works fine, but when I try to build using Android Studio, error showing :
No installed build tools found. Install the Android build tools version 19.1.0 or higher.
Although all build tools already installed in my Android Studio
Screenshots -

Cannot find module 'compare-func' Cordova Android

I've got a Cordova v10.0.0 project using Cordova Android v9.0.0, I'm experiencing a problem when trying to build the project for Android, I'm getting the following error:
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/Users/MYUSER/Library/Android/sdk (DEPRECATED)
Failed to instantiate ProjectBuilder builder: Error: Cannot find module 'compare-func'
I've tried removing my Node Modules folder, running a cordova clean android and re-installing with npm install. Not quite sure why I'm getting this error.
I faced the same issue and I installed compare-func npm package (Link) (npm i compare-func) and it worked for me.

ANDROID_SDK_ROOT=undefined (recommended setting) while building ionic app using Cordova for Android device

I am trying to build an ionic app for Android device with Cordova using the below command from VSCode.
ionic cordova build android --prod --release
But I'm getting this error:
cordova.cmd build android --release
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\tanmay\AppData\Local\Android\sdk (DEPRECATED)
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
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd build android --release exited with exit code 1.
I have already installed JDK, Android Studio. I also have setup the environment variable ANDROID_SDK_ROOT with the correct SDK path. But still no luck.
I am using
Android Studio 3.6.1,
Gradle 6.3,
Cordova 8.1,
on Windows 10.
I guess I am somewhere missing the setting the ANDROID_SDK_ROOT but I'm not sure where.
You can check if Java JDK, Android SDK, Gradle are properly installed before building an app.
To do so, you can run the following command :
cordova requirements android --verbose
It will show, what is missing and after that, you may install it if you haven't installed it or you may check for the correct path in the Environment Variables.
If you have an android studio installed, you need not to worry about this error on terminal, as until this error cordova will update your android package in platforms directory.
Open your Android Studio.
Select open existing project and browse to select your /platforms/android folder in
project directory.
It will open in android and will be build success
I had the same error.
I solved it by using Gradle 5.6.3 instead of the newer versions.
For anyone as dumb as I was that also thought you could setup and run a cordova project on android without having java, gradle or android studio installed: Once you installed all those things, delete your cordova project's node_modules, platforms, plugins and www folders and set them up again (i.e. rerun npm i, cordova platform add android, npm run build, etc) before trying to run the cordova project again. In my case I'm trying to run cordova run android which caused the same error that OP's getting.
NOTE: I have zero experience with cordova. I have to get a very specific cordova/webpack template up and running locally, and the advice I'm giving in this answer is what worked for me. YMMV.

Perpetual NativeScript Mac Installation Issues

I could really use someone's help on this as I have been troubleshooting this for a really long time now with no remediation.
The issue is simply installing the NativeScript CLI onto my OSX Yosemite Mac. I followed the steps according to NS' website (installing proper Node.JS version, downloaded Xcode 7.2 (due to OS constraints), installed JSDK, installed NS Sidekick, installed Android Studio w/ proper SDK along with every other required dependancy.
However, when I run "sudo npm i -g nativescript --unsafe-perm" (otherwise it will throw a EACCES error), I get the following log with it saying I missing all of these dependencies I know I have but it is claiming I don't.
The biggest kick is that while it still will say NativeScript successfully installed, whenever I run any tns command (like tns doctor), the bash command cannot be found.
I have made sure to follow the directions of adding NS to my path as well as my Android and Java SDKs. Here is the full log:
jsmbp:~ Js$ sudo npm i -g nativescript --unsafe-perm
Password:
/Users/Jmsquillaro/.npm-packages/bin/nativescript -> /Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript/bin/tns
/Users/Jmsquillaro/.npm-packages/bin/tns -> /Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript/bin/tns
> fsevents#1.1.2 install /Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript/node_modules/fsevents
> node install
[fsevents] Success: "/Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript/node_modules/fsevents/lib/binding/Release/node-v48-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
> nativescript#3.3.1 postinstall /Users/Jmsquillaro/.npm-packages/lib/node_modules/nativescript
> node postinstall.js
WARNING: adb from the Android SDK is not installed or is not configured properly.
For Android-related operations, the NativeScript CLI will use a built-in version of adb.
To avoid possible issues with the native Android emulator, Genymotion or connected
Android devices, verify that you have installed the latest Android SDK and
its dependencies as described in http://developer.android.com/sdk/index.html#Requirements
TIP: To avoid setting up the necessary environment variables, you can use the Homebrew package manager to install the Android SDK and its dependencies.
WARNING: The Android SDK is not installed or is not configured properly.
You will not be able to build your projects for Android and run them in the native emulator.
To be able to build for Android and run apps in the native emulator, verify that you have
installed the latest Android SDK and its dependencies as described in http://developer.android.com/sdk/index.html#Requirements
TIP: To avoid setting up the necessary environment variables, you can use the Homebrew package manager to install the Android SDK and its dependencies.
WARNING: CocoaPods is not installed or is not configured properly.
You will not be able to build your projects for iOS if they contain plugin with CocoaPod file.
To be able to build such projects, verify that you have installed CocoaPods.
The ANDROID_HOME environment variable is not set or it points to a non-existent directory. You will not be able to perform any build-related operations for Android.
To be able to perform Android build-related operations, set the ANDROID_HOME variable to point to the root of your Android SDK installation directory.
Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 22 or later.
Run $ sdkmanager to manage your Android SDK versions.
You need to have the Android SDK Build-tools installed on your system. You can install any version in the following range: '>=23 <=26'.
Run $ sdkmanager from your command-line to install required Android Build Tools. In case you already have them installed, make sure ANDROID_HOME environment variable is set correctly.
You need to have Android SDK 22 or later and the latest Android Support Repository installed on your system.
Run $ sdkmanager to manage the Android Support Repository. In case you already have it installed, make sure ANDROID_HOME environment variable is set correctly.
Error executing command 'javac'. Make sure you have installed The Java Development Kit (JDK) and set JAVA_HOME environment variable.
You will not be able to build your projects for Android.
To be able to build for Android, verify that you have installed The Java Development Kit (JDK) and configured it according to system requirements as
described in http://docs.nativescript.org/setup/ns-cli-setup/ns-setup-os-x.html#system-requirements
There seem to be issues with your configuration.
? Do you want to visit the official documentation? No
? Do you want to run the setup script? No
Your components are up-to-date:
nativescript,tns-core-modules,tns-android,tns-ios
Autocompletion is already enabled
Installation successful. You are good to go. Connect with us on http://twitter.com/NativeScript.
+ nativescript#3.3.1
added 692 packages in 156.18s
jsmbp:~ Js$ tns doctor
-bash: tns: command not found
What can I do to fix this? npm also declares "rollbackFailedOptional" every time I try to reinstall after I uninstall it. Is npm caching a broken version and can I force it to do a genuine "reinstall?" It has been so frustrating as everything looks messed up and I really don't want to give up on NS. Let me know your thoughts and thank you!
Begin by installing node.js correctly. I've you are having to you --unsafe-perm that means, the node.js installation is not done right.
I suggest you install nvm using homebrew and then install node from that. Please refer to my solution in this post https://discourse.nativescript.org/t/not-installing-on-macos/3292/4

How to use a different version of Npm and Cordova

We have downloaded and installed a different Npm instance outside Visual Studio on our development machine and set the system classpath to use this version;
using this Npm, we have downloaded the latest version of Cordova (3.5.0).
Apparently, it seems that Visual Studio 2013 is using this new Npm installation and Cordova version when building; using this configuration we can correctly build and deploy to WP8, Android and iOS.
Also the plugins (enabled from the config.xml in VS) are downloaded and set in the new Cordova path.
Looking at the build log, I've however noticed that the iOS build is reporting that the 3.4.0 version of Cordova is used.
Is this kind of configuration supported?
Which is the correct way to use a different version of Cordova?
If you update Multi-Device Hybrid Apps to the CTP2, Visual Studio now uses Cordova 3.5.0 instead of 3.4.1. You should also update your instance of vs-mda-remote on your Mac to stay in sync for iOS.
There is currently not a supported way to select a version of Cordova though that is on the roadmap.

Resources