ionic 4 beta找不到安装的构建工具

时间:2019-01-05 17:43:00

标签: ionic-framework ionic4

我正在尝试编译android apk,但出现错误“找不到安装的构建工具。”

$ ionic cordova build android

错误:

...
Android Studio project detected
Preparing Firebase on Android
ANDROID_HOME=/usr/lib/android-sdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle
studio
Subproject Path: CordovaLib
Subproject Path: app

FAILURE: Build failed with an exception.

* Where:
Script '/home/ubuntu/lapp/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 2s
/home/ubuntu/lapp/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Script '/home/ubuntu/lapp/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 2s
[ERROR] An error occurred while running subprocess cordova.

        cordova build android exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.

环境变量:

export ANDROID_HOME=/home/ubuntu/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

$ echo $ANDROID_HOME
/home/ubuntu/Android/Sdk

$ echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle

$ echo $PATH
...
/usr/lib/jvm/java-8-oracle/bin:
/usr/lib/jvm/java-8-oracle/db/bin:
/usr/lib/jvm/java-8-oracle/jre/bin:
/home/ubuntu/Android/Sdk/platform-tools:
/home/ubuntu/Android/Sdk/tools:
/home/ubuntu/Android/Sdk/build-tools:
/home/ubuntu/Android/Sdk/tools/bin:
/home/ubuntu/Android/Sdk/emulator

$ ionic info

Ionic:

   ionic (Ionic CLI)             : 4.6.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.0.0-rc.0
   @angular-devkit/build-angular : 0.11.4
   @angular-devkit/schematics    : 7.1.4
   @angular/cli                  : 7.1.4
   @ionic/angular-toolkit        : 1.2.2

Cordova:

   cordova (Cordova CLI) : not installed
   Cordova Platforms     : not available
   Cordova Plugins       : not available

System:

   Android SDK Tools : 26.1.1 (/home/ubuntu/Android/Sdk)
   NodeJS            : v10.14.2 (/usr/local/bin/node)
   npm               : 6.4.1
   OS                : Linux 4.15

我尝试:

ionic cordova platform remove android
ionic cordova platform add android

毕竟,我安装了Android 4.3中的所有SDK和19.0.3中的所有Android SDK构建工具,但是即使这样也没有帮助。

Ps:无论我如何尝试将路径设置为ANDROID_HOME(〜/ .bash_profile,〜/ .bashrc),但仍然需要ANDROID_HOME = / usr / lib / android-sdk

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

1)终端为root

$ sudo -s

2)将路径添加到~/.bash_profile~/.bashrc

3)完成!