How do I install Gradle into the Android folder of an application? - android

I am working on an application which uses Cordova to establish a Bluetooth connection between an Android phone and an Arduino. I am using the BluetoothSerial library in my application.
Whenever I execute cordova build android, it throws an error saying that it cannot find Gradle in my Android SDK installation. In an attempt to solve this, I installed Gradle through Homebrew, but Cordova did not find it.
WT0892:counter iosdev$ cordova build android
ANDROID_HOME=/Users/iosdev/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home
Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.
Looked here: /Users/iosdev/Library/Android/sdk/tools/templates/gradle/wrapper
How can I install Gradle into my Android SDK? If that's not the right way to fix this problem, how can I tell Cordova where to find Gradle?

Related

An alternative way for building a Unity project for Android

For the last few days, I have been trying to build a testing project for android using the default build method but I just keep recieving errors and not knowing how to fix them.
Short Error and Full Error Decscription. Also I am using Unity 5.6.7f1 with Admob plugins (And yes because my pc is shit so I use this version)
So I want to ask is there an alternative way for building an android app with Unity. I have heard about exporting the project to gradle and building it using Android Studio. But I don't know how.
If you know an alternative way or how to build the project with Android Studio or how to fix the error PLEASE ANSWER. I am having a nightmare with building this stupid test project to Android
The problem is your jdk(1.8.0_311) is too new to support legacy build command from Unity (5.6.7f1).
Two method to solve:
Install older jdk
if you don't know which version you should use. You may use the default jdk with Unity installer in preferences. (I'm not sure 5.6.7f1 is supported).
Export android project
You can export android project by check the "Export Project". Then use android studio to build apk.

Ionic 4 Running on Device: "Could not find an installed version of Gradle either on Android Studio or in System" Although I have it on my system

I'm trying to run a blank app of ionic 4 on my android 9 device. Already followed each step on the website and running it on browser is okay.
When I run it on my device here is what i get:
Error when running
It says I dont have gradle and android studio but here is my environment:
android sdk list,my /etc/environment,and my npm, ionic, gradle and java versions
Am I missing something guys?
This error occurs when gradle is not properly installed. I have experienced this before. try installing gradle on your system.
For some reason the ionic project does not locate the gradle, to verify that this is the case, try opening the project on android studio and you will get the warning that no gradle wrapper was found.
IDK if some of you people have the same problem, but it's because of the Gradle. Installed it the way the website said, tried both automatically with SDK manager and also the manual downloads. Still no. So I installed it using:
sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update
sudo apt-get install gradle
Then find location where it was installed then add to path. Now I can install the app on my device
Your question is not clear, are you facing error on local emulator or real mobile device?
it seems you are trying to run on local android emulator, can you please mention that where you are facing error?
Also, please do debug or production build with the help of ionic cordova build android command and try to run on your android device, generally android studio will pops up of gradle build update, which will help to generate faster sequential android build, and which needs gradle for it.

Cordova Web App

I'm trying to make an apk of the web app I made in babylonjs.
From my understanding you can use Cordova to convert a web app into an apk.
I was able to install Cordova and make its hello world apk download to my phone and open and run it just fine.
However my problem occurs when I put all of my web app files into the www folder in my Cordova project folder. After I do that Cordova gives me this error
Error: ENOENT: no such file or directory, stat '/Users/dylan/practiceApk/www/node_modules/.bin/nopt'
when I try to build the android version.
Here is some information about my setup I believe is relevant.
OS: Mac
cordova -v: 7.1.0
Cordova requirements:
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-26,android-24
Gradle: installed /Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle
cordova info also gives this error(similar error I believe to the one above):
Error retrieving Android platform information:
Android SDK is not set up properly. Make sure that the Android SDK 'tools' and 'platform-tools' directories are in the PATH variable.
Error: android: Command failed with exit code ENOENT
But I tried a lot of different things to fix this. Most of them involved making the android tools in the path (er something..?) I also downgraded from the most recent version of Cordova and android. I believe the problem is in my web app node_modules/.bin/nopt
But I don't know why its is a problem.
Also im not sure how this affects it, but I'm not hosting the website anywhere I just assumed I can used Cordova to create the web app as an apk that could be used offline, all resource are in the project folder though.
Any ideas on how to fix this? I only started using Cordova today so I don't know much about it.
Thanks for your time!
Update: I tried building an iOS version and I get the same error. I believe this is an issue with my npm setup...
It seems that when I was copying over my project to the newly made Cordova project folder I also copied the node_modules folder and didn't actually initialize npm. After initializing it and then updating it would build the app.

Gradle version to use with Android/Cordova CLI

I currently use Cordova CLI on Windows to build hybrid Android apps. I am in the process of moving my development mover to a headless Ubuntu server. Getting java, NVM, Node, Android SDK and Cordova CLI installed on Ubuntu has not been a problem. Having done so and created the customary Cordova hello world project,
cordova create hello com.example.hello HelloWorld
I proceeded to add the Android platform
cordova plaform add android
and then attempted to build
cordova build android
at which point I was told
Error: 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
Installing Gradle by following the instructions given here - I am NOT installing Android Studio and am working on a headless Ubuntu machine so automatic Gradle installation is not an option - is not a problem. However, it is not clear to me which version of Gradle I should install.
I do not want to break my current Cordova project so I am trying to replicate the current Windows/Cordova CLI setup as closely as I can
Node 8.9.2
Java 8
Gradle ???
Dipping inside the gradle-wrapper.properties file in my existing project I find
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
I have noted that when I compile the project at present there are some ominous warnings about features to be removed from future versions of Gradle that are shown. I could experiment with using gradle-2.10 but it is not entirely clearr to me that it would indeed be the right version. Hopefully, someone here will be able to point me in the right direction.
First, clean up the project
cordova clean android
Then, force the cordova to use the distribution url with the version you want, in this case: gradle-6.3
export CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL=https\\://services.gradle.org/distributions/gradle-6.3-all.zip
Then, build your application.
cordova build android --release

Import Cordova project in Android Studio

I am trying to create a Cordova project. After creating the project cordova create myProject I would like to open it in Android Studio. The problem is ... it doesn't work.
The CordovaLib will not build with various errors package android.* does not exist.
Does anyone know how to import a cordova project in Android Studio?
Unfortunately the accepted answer is a bit out of date. Using Cordova v5.3.3 (it probably works on all versions > 5) it is much the same process a building and then entering XCode for an iOS application now - the build system has moved to gradle.
Before opening in Android Studio
cordova build android
Then just open up the project using File > Open and pointing to the (yourProjectDir)/Platforms/Android directory.
If you are using an older version of the cordova android platform you might need to run
cordova platform android update
To get moved to the gradle build system which is compatible with the current version of Android Studio
Make sure you import the "platform/android" directory underneath your cordova project (and you want to Import Project, not Open Project).
You will at least need to run
cordova prepare android
before doing the import
cordova build android
will also work, but it will create some ant directories which will not be used by Android Studio and you will have to actively ignore the files when importing otherwise you will get extra libraries in your project). Although I haven't imported a Cordova app into android studio recently, it definitely works in the Community edition of Intellij which Android Studio is based on (I did it yesterday with a project built from scratch with Cordova 3.5). I can't think of any of the additional features in Android Studio that would be useful that aren't in Intellij, as most of the additions which haven't been backported to Intellij are in the preview space which isn't going to work with Cordova anyway (all it is going to preview is a blank webkit view).
All the answers above seem to refer to the cli. However, to actually have your project in android studio so that you can harness the power of the android studio, this is what I would suggest you do:
Please see my most relevant answer here...
Building Ionic framework in android studio
We have some troubles on importing Ionic project to android studio because we have add android platform with SUDO command, and because of it, android studio dont have access privileges to read files.
In my case just do sudo chmod -Rf 777 ionicFolder android studio can import project successful.
I hope this help some one with this problem.

Categories

Resources