I had built an angular application and wanted to turn it into a native android app using cordova.
I had previously installed android-sdk using apt-get which was added to by /usr/lib folder. I also had installed Android Studio separately who's sdk-tools were located in ~/Android/Sdk.
Previously, my $ANDROID_HOME variable contained path /usr/lib but after installation of Android Studio I had changed it to <myhomedirectory>/Android/Sdk
Previously, the android-sdk tools installed had version 23, which was incompatible with the newer version of gradle, and gave me the following error upon running cordova run android (with sudo) in my project:
WARNING: The specified Android SDK Build Tools version (23.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.3.0.
Android SDK Build Tools 28.0.3 will be used.
Followed by the following error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
platforms;android-28 Android SDK Platform 28
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: /usr/lib/android-sdk
The Android Studio I installed had tools installed for both API 28 and API 29, but I did not know why it was still giving me this error, until I noticed the last line of this error, which stated that my Android SDK is being fetched from /usr/lib (the old directory). I tried checking the environment variables again, sourcing the ~/.bashrc, as well as logging out but nothing really worked.
I decided to remove the previously installed android-sdk and purge the files using apt but even then nothing happened.
I even removed the mobile folder (the project folder for cordova I created) and even restarted from scratch, but it still gave me the same error.
I am unsure why it is still picking up the wrong path from environment variable, I've even echo-ed the variable and the path is the one I set just recently, but cordova for some reason seems to disagree.
There was an issue with the permissions in the cordova project. Had to sudo chown -R <myproject>. I first noticed when I tried sudo cordova requirements instead of cordova requirements (which said I had all requirements installed). I noticed these installations were on user level not on root level, which is why upon sudo it was giving me an error. After chown-ing simply run cordova run android. You'll no longer have issues.
Related
I'm trying to set up an automated build for an Android app from Team Foundation Services, using Gradle. Almost everything is correctly set up, but the build fails each time because two modules that the app is dependent upon do not have their licenses agreed upon. This is what I'm getting as an error output:
Checking the license for package Android SDK Build-Tools 28.0.3 in
C:\Tools\AndroidSdk\licenses
License for package Android SDK Build-Tools 28.0.3 accepted.
Preparing "Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)".
Warning: Failed to read or create install properties file.
Checking the license for package Android SDK Platform 28 in
C:\Tools\AndroidSdk\licenses
License for package Android SDK Platform 28 accepted.
Preparing "Install Android SDK Platform 28 (revision: 6)".
Warning: Failed to read or create install properties file.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to install the following SDK components:
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
platforms;android-28 Android SDK Platform 28
Install the missing components using the SDK manager in Android Studio.
I've already tried pretty much everything I found on StackOverflow or other places. I deleted all licenses from %ANDROID_HOME%/Licenses folder, installed them again and agreed the terms (with sdkmanager.bat --licenses command); I added a PowerShell script that copies each license file for each module from %ANDROID_HOME%/Licenses folder to the output folder; I reinstalled the whole SDK; I've made sure that the agent has permissions to edit and delete files in the working folders. I've also tried running the build directly from the build server (without a TFS agent) and it successfully built, which is also strange.
Am I missing another thing I can do?
We fixed the issue by running an "--update" command on the sdkmanager.bat file in the folder where we have the SDK installed. A few modules from the SDK got updated and the error went away.
It is possible to have the "--update" command as a script step in the build definition on TFS, so the error does not come back eventually when one of the modules will be updated.
I am developing Android application using Ionic framework (Ionic is built on top of Apache Cordova). When I try to build my app, I get an error, which states that build tools are missing.
Error:
> No installed build tools found. Install the Android build tools version 19.1.0 or higher.
I am using windows, and I have Android SDK tools installed (at C:\tools), also I have used sdkmanager to install platform-tools (at C:\platform-tools) and android26 and android27 platforms (at C:\platforms\android-26 and C:\platforms\android-27).
My ANDROID_HOME enviroment variable is set to C:\tools and I have included all of the following locations in my path:
C:\tools
C:\tools\bin
C:\platform-tools
C:\platforms
I believe I am missing something, what do I have to do/fix for my build to succeedd. What are those build tools that I do not have installed?
You have set "ANDROID_HOME" to your sdk tools folder. This is causing an error in the relative navigation used by Cordova.
Solution: Create a new folder "SDK" in your C drive as such C:\SDK. Now add all of the sdk stuff into that directory. Finally, change your "ANDROID_HOME" path to C:\SDK
I know there are many threads like this but none of them helped.
I am using Windows 10, Cordova 7.1.0 (latest version) and I have installed Android Studio with SDK Platform 7.1.1 - API level 25 (also tried downgrading to 7.0 - API level 24). Also, I installed SDK build-tools using Android Studio SDK Manager.
Running:
cordova info
I get this message:
Android SDK is not set up properly. Make sure that the Android SDK
'tools' and 'platform-tools' directories are in the PATH variable.
'android' is not recognized as an internal or external command,
operable program or batch file.
Running
cordova requirements
I get this message:
Android SDK: not installed
Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually. Detected 'adb' command at
C:\Windows but no 'platform-tools' directory found near. Try reinstall
Android SDK or update your PATH to include valid path to
SDK\platform-tools directory. Android target: not installed cmd:
Command failed with exit code 1 Error output: 'android' is not
recognized as an internal or external command, operable program or
batch file. Gradle: not installed Could not find gradle wrapper within
Android SDK. Could not find Android SDK directory. Might need to
install Android SDK or set up 'ANDROID_HOME' env variable.
I also tried to install manually the SDK, without Android Studio, but it did not help. I am not used to working with CLI's so I may be missing something.
However, I tried upgrading Cordova, downgrading SDK and installing the latter manually. I was also confused with environment variables, I tried some things I read but none worked. Any help, appreciated.
I figured it out.
Seems that in my case, Java JDK 9 was causing the problem. Downgrading to JDK 8 gave me the solution.
In addition, I hadn't set the ANDROID_HOME variable correctly but even when I did, it did not work until downgrading to JDK 8.
Since I got some errors in my android emulator I manually updated my Android SDK using the command line sdkmanager. It seems the "old" SDK Manager does not support updates anymore. I do not have Android Studio installed (I did not need it since VS2015 installed the platform tools, too). After the update I have to use command line tools for avdmanager and sdkmanager. The "old" AVD Manager and SDK Manager do not work anymore.
However after this update Visual Studio 2015 could not compile my Codova app. I always got the error:
Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.
Before the app was building correctly.
I did set up the ANDROID_HOME variable to the SDK path (same path as in ADT_HOME). I also tried the suggestion by Abdul Rauf Mujahid to manually edit the regedit.
Both actions did not help.
The ADT_HOME variable is still a valid path.
It seems that others had similar problems Shandu
It seems that android was removed in the last update of the tools. In order to resolve this issue I had to downgrade my Andoid tools and platform-tools.
I downloaded the older revisions of sdk tools Revision 25.3.0 (March 2017) as well as platform tools Revision 25.0.3 and copied them into the relevant folders.
Now I can again compile my Cordova app
I'm using cordova 3.3.0 on Windows in cygwin, and I'm getting the following error when I try to add the android platform
Error: An error occured during creation of android sub-project.
C:\Users\Mike\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:126
throw e;
^
Please install Android target 19 (the Android newest SDK). Make sure you have the latest Android tools installed as well. Run "android" from your command-line to install/update any missing SDKs or tools.
I have the latest available versions or java, ant and the android sdk api 19 installed, as well as the latest android tools, platform-tools and build-tools but the error persists. (I tried to post an image of my SDK Manager to show this but I don't have enough reputation :(
The end of my PATH variable contains the correct locations for android tools and platform-tools as suggested here
....:/cygdrive/c/Users/Mike/bin:/cygdrive/c/Tools/apache-ant-1.9.3/bin:/cygdrive/c/Tools/sdk/platform-tools:/cygdrive/c/Tools/sdk/tools:/cygdrive/c/Program Files/Java/jdk1.7.0_51/jre/bin
The strange thing is that my project used to build correctly, but then stopped working when nothing noticeable had changed. I've fixed this before by building a new cordova project, but now I get this error with a brand new HelloWorld cordova project:
Mike#Mike-VAIO /cygdrive/c/workspaces/apps
$ cordova create test com.example.test HelloWorld
Creating a new cordova project with name "HelloWorld" and id "com.example.test" at location "C:\workspaces\apps\test"
Mike#Mike-VAIO /cygdrive/c/workspaces/apps
$ cd test
Mike#Mike-VAIO /cygdrive/c/workspaces/apps/test
$ cordova platform add android
Creating android project...
Error: An error occured during creation of android sub-project.
C:\Users\Mike\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:126
throw e;
^
Error: Please install Android target 19 (the Android newest SDK). Make sure you have the latest Android tools installed as well. Run "android" from your command-line to install/update any missing SDKs or tools.
I've tried reinstalling cordova but that doesn't help. Does anyone have any other ideas?
many thanks in advance
You should check if Target 19 really exists. Go to your android SDK folder, then to platforms and check if there is a folder called android-19.
But still this looks like cordova is not able to point out your android SDK folder or your target 19 folder.