Reputation: 1221
I am having trouble building my ionic application on android on Ubuntu 16.04
This is step step what I have done in order to make it happen
in /.bashrc and /.bash_profile
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
When I hit sudo ionic cordova build android
I a getting this error:
FAILURE: Build failed with an exception.
- Where:
Script '/home/iraklis/Desktop/mus/platforms/android/CordovaLib/cordova.gradle' line: 68
- What went wrong:
A problem occurred evaluating project ':CordovaLib'.
No installed build tools found. Install the Android build tools version 19.1.0 or higher.
this here is my ionic info:
Ionic:
ionic (Ionic CLI) : 4.6.0 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.0-rc.3
@angular-devkit/build-angular : 0.12.2
@angular-devkit/schematics : 7.1.4
@angular/cli : 7.1.4
@ionic/angular-toolkit : 1.2.2
Cordova:
cordova (Cordova CLI) : 8.1.2 ([email protected])
Cordova Platforms : android 7.1.4
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.3.2, (and 9 other plugins)
System:
Android SDK Tools : 26.1.1 (/home/iraklis/Android/Sdk)
NodeJS : v10.11.0 (/usr/local/bin/node)
npm : 6.4.1
OS : Linux 4.15
I am thinking that.. maybe this here in cordova.gradle
String[] getAvailableBuildTools() {
def buildToolsDir = new File(getAndroidSdkDir(), "build-tools")
buildToolsDir.list()
.findAll { it ==~ /[0-9.]+/ }
.sort { a, b -> compareVersions(b, a) }
}
for some reason cannot find the build-tools..?
EDIT
I just noticed, when i do echo $ANDROID_HOME
it prints /home/iraklis/Android/Sdk
as expected but when i run ionic cordova build android
after building it prints ANDROID_HOME=/usr/lib/android-sdk
. How can i change that?
Upvotes: 2
Views: 7322
Reputation: 784
The proper command to install the appropriate build tools is
sdkmanager "build-tools;33.0.2"
(Of course substitute whatever version you want for 33.0.2)
Using sdkmanager packages "build-tools;33.0.2"
now in 2023 gives a package 'packages' not found
error.
Then, add the following to your path to your .zshrc or .bashrc file (or whatever rc file your shell uses
#Add Android Studio SDK to the Environment Variables
export ANDROID_SDK_ROOT="/Users/<your user folder>/Library/Android/sdk"
#ANDROID_HOME is deprecated. Do not use it anymore
#Add Android build-tools and platform-tools to the path
export PATH="$PATH:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/build-tools/33.0.2:$ANDROID_SDK_ROOT/platform-tools"
(Again, be sure to substitute whatever version you're using for the 33.0.2 above. And obviously should be replaced with your actual user-folder name.)
Upvotes: 0
Reputation: 2085
If you have brew installed, you may be able to just try this:
brew install android-sdk
This should then let you run
sdkmanager packages "build-tools;25.0.3"
Upvotes: 0
Reputation: 76569
you need to install the build-tools 25.0.3
(just assuming it may require these):
sdkmanager packages "build-tools;25.0.3"
or even several build-tools versions ...
sdkmanager packages "build-tools;25.0.3" "build-tools;26.0.3" "build-tools;27.0.3" "build-tools;28.0.3"
Upvotes: 0