科尔多瓦为“ ANDROID_HOME”使用了错误的路径

时间:2020-05-14 13:30:16

标签: android bash cordova

我已经构建了一个角度应用程序,并希望使用cordova将其转换为本地android应用程序。

我以前使用android-sdk文件夹中添加的apt-get安装了/usr/lib。我还单独安装了Android Studio,其SDK工具位于~/Android/Sdk

以前,我的$ANDROID_HOME变量包含路径/usr/lib,但是在安装Android Studio之后,我将其更改为<myhomedirectory>/Android/Sdk

以前,安装的android-sdk工具的版本为23,该版本与较新版本的gradle不兼容,并且在我的项目中运行cordova run android(使用sudo)时出现以下错误:

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.

出现以下错误:

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

我安装的Android Studio上同时安装了针对API 28和API 29的工具,但我不知道为什么它仍然给我这个错误,直到我注意到此错误的最后一行,即我的Android SDK是从/usr/lib(旧目录)中获取。我尝试再次检查环境变量,获取~/.bashrc,并注销,但没有任何效果。

我决定删除先前安装的android-sdk并使用apt清除文件,但即使如此,也没有任何反应。

我什至删除了mobile文件夹(我创建的cordova的项目文件夹),甚至从头开始重新启动,但是它仍然给我同样的错误。

我不确定为什么它仍然从环境变量中选择错误的路径,我什至echo编辑了该变量,而该路径是我最近设置的路径,但是科尔多瓦出于某种原因似乎不同意。

1 个答案:

答案 0 :(得分:0)

cordova项目中的权限存在问题。必须sudo chown -R <myproject>。当我尝试使用sudo cordova requirements而不是cordova requirements时(我说我已经安装了所有要求),我首先注意到了。我注意到这些安装不是在用户级别,而是在用户级别,这就是为什么在sudo上它给我一个错误。 chown输入后,只需运行cordova run android。您将不再有问题。