Android run - can't find build tools

greetings… :slight_smile:

the tl;dr: I’m trying to get an Ionic 3 project up and running on an Ubuntu machine, but the Android SDK is giving me hell. didn’t have problems with this on my Windows machine (at work), but I can’t figure out what’s missing from my Ubuntu machine (at home). to the best of my knowledge, I’ve got all the correct requirements, but the build commands are simply not finding them.

with regards to the Android SDK, I do not have Android Studio, so I installed the SDK using the “SDK Tools” only approach, which is extracted to ~/android-sdk/tools with the following added to my ~/.bashrc file:

export ANDROID_HOME=/home/dre/android-sdk/tools`
export PATH=$ANDROID_HOME/bin:$PATH

full $PATH output is currently:

/home/dre/android-sdk/tools/bin:/home/dre/.nvm/versions/node/v6.12.3/bin:/home/dre/bin:/home/dre/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

really hoping this is just something silly that I did, but I can’t figure it out. :frowning: all my environment info is included below.


ionic info output:

dre@mobile-monster:~/workspace/nortech/pk-du-mobile$ ionic info
cli packages: (/home/dre/.nvm/versions/node/v6.12.3/lib/node_modules)

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 8.0.0 

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 7.0.0 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node : v6.12.3
    npm  : 5.6.0 
    OS   : Linux 4.13

Environment Variables:

    ANDROID_HOME : /home/dre/android-sdk/tools

Misc:

    backend : pro

ionic cordova requirements output (obviously the iOS requirements will fail here):

dre@mobile-monster:~/workspace/nortech/pk-du-mobile$ ionic cordova requirements
> cordova requirements
Android Studio project detected


Requirements check results for android:

Java JDK: installed 1.8.0

Android SDK: installed true

Android target: installed android-27,android-26

Gradle: installed /usr/share/gradle/bin/gradle

Requirements check results for ios:
Apple macOS: not installed 
Cordova tooling for iOS requires Apple macOS

(node:3046) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Some of requirements check failed

sdkmanager --list, installed packages and available updates:

note: I tried installing the specific version the build tools are looking for, just in case… but this made no difference, which makes me suspect this is more likely to be an issue with the location of the tools, rather than the fact that they’re not installed.

dre@mobile-monster:~/workspace/nortech/pk-du-mobile$ sdkmanager --list
Warning: File /home/dre/.android/repositories.cfg could not be loaded.
Installed packages:
  Path                 | Version | Description                    | Location             
  -------              | ------- | -------                        | -------              
  build-tools;19.1.0   | 19.1.0  | Android SDK Build-Tools 19.1   | build-tools/19.1.0/  
  build-tools;27.0.3   | 27.0.3  | Android SDK Build-Tools 27.0.3 | build-tools/27.0.3/  
  patcher;v4           | 1       | SDK Patch Applier v4           | patcher/v4/          
  platform-tools       | 27.0.1  | Android SDK Platform-Tools     | platform-tools/      
  platforms;android-26 | 2       | Android SDK Platform 26        | platforms/android-26/
  platforms;android-27 | 1       | Android SDK Platform 27        | platforms/android-27/
  sources;android-26   | 1       | Sources for Android 26         | sources/android-26/  
  sources;android-27   | 1       | Sources for Android 27         | sources/android-27/  
  tools                | 26.0.1  | Android SDK Tools 26.0.1       | tools/

<snip>

Available Updates:
  ID      | Installed | Available
  ------- | -------   | -------  
  tools   | 26.0.1    | 26.1.1   
done

and then the problem when trying to run my project:

dre@mobile-monster:~/workspace/nortech/pk-du-mobile$ yarn run:android
yarn run v1.5.1
$ ionic cordova run android --device --livereload
Starting app-scripts server: --address 0.0.0.0 --port 8100 --livereload-port 35729 --dev-logger-port 53703 --nobrowser 
--iscordovaserve --platform android --target cordova - Ctrl+C to cancel
[09:46:49]  watch started ... 
[09:46:49]  build dev started ... 
[09:46:49]  clean started ... 
[09:46:49]  clean finished in 3 ms 
[09:46:49]  copy started ... 
[09:46:49]  deeplinks started ... 
[09:46:49]  deeplinks finished in 82 ms 
[09:46:49]  transpile started ... 
[09:46:53]  transpile finished in 4.53 s 
[09:46:53]  preprocess started ... 
[09:46:53]  preprocess finished in 1 ms 
[09:46:53]  webpack started ... 
[09:46:54]  copy finished in 4.91 s 
[09:47:02]  webpack finished in 8.89 s 
[09:47:02]  sass started ... 
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[09:47:04]  sass finished in 1.88 s 
[09:47:04]  postprocess started ... 
[09:47:04]  postprocess finished in 9 ms 
[09:47:04]  lint started ... 
[09:47:04]  build dev finished in 15.53 s 
[09:47:04]  watch ready in 15.61 s 
[09:47:04]  dev server running: http://localhost:8100/ 

[OK] Development server running!
     Local: http://localhost:8100
     External: http://10.0.0.120:8100
     

> cordova run android --device
Android Studio project detected

ANDROID_HOME=/home/dre/android-sdk/tools
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
studio
Subproject Path: CordovaLib
Subproject Path: app

FAILURE: Build failed with an exception.

* Where:

Script '/home/dre/workspace/nortech/pk-du-mobile/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.


* Try:
Run with 
--stacktrace
 option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
(node:4233) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: /home/dre/workspace/nortech/pk-du-mobile/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Script '/home/dre/workspace/nortech/pk-du-mobile/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.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s

please could someone help me figure out why this command can’t find the build tools?

1 Like

Maybe these posts on stackoverflow could help?

thanks, but I have already looked at both of those… to be fair, I do research things before I ask questions. (: however, I just realised my error… and now I’m kicking myself for being so silly.

I extracted the “command line only” version of the SDK to /home/dre/android-sdk/tools, then I set my ANDROID_HOME variable to look at that folder specifically.

checking the contents of the /home/dre/android-sdk folder, I see the built-tools folder is in there. so I just changed my ANDROID_HOME variable to look at /home/dre/android-sdk instead, and now my project is running.

Congrats for finding your solution!

For the record, I didn’t meant at all that I thought that you didn’t did any research before posting your issue, it’s just sometimes you know when we face an error we read a thousand posts and sometimes we just miss the one, that’s all

Again congrats and enjoy your Sunday then :wink:

1 Like

that is too true, guess that’s just one down side of having so much information available; there’s also so much to have to sift through when you’re looking for one specific thing.

thanks for taking the time to reply anyway, I do appreciate it. :vulcan_salute:

1 Like