簡體   English   中英

ANDROID_SDK_ROOT=undefined(推薦設置)同時使用 Cordova 為 Android 設備構建離子應用程序

[英]ANDROID_SDK_ROOT=undefined (recommended setting) while building ionic app using Cordova for Android device

我正在嘗試使用來自 VSCode 的以下命令為 Android 設備和 Cordova 構建離子應用程序。

ionic cordova build android --prod --release

但是出現錯誤

Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\tanmay\AppData\Local\Android\sdk (DEPRECATED)
Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio
[ERROR] An error occurred while running subprocess cordova.

        cordova.cmd build android --release exited with exit code 1.

我已經安裝了JDK,Android Studio。 我還使用正確的 SDK 路徑設置了環境變量ANDROID_SDK_ROOT 但仍然沒有運氣。

我在 ZAEA23489CE3AA9B630Z06EBBA4 上使用 Android Studio 3.6.1、Gradle 6.3、Cordova 8.1。

我想我在某個地方缺少設置ANDROID_SDK_ROOT但不確定在哪里。

您的幫助將不勝感激。 謝謝。

您可以在構建應用程序之前檢查 Java JDK、Android SDK、Z7B5CC4FB56E11DC7520F716EC7 是否正確安裝。 為此,您可以運行以下命令:

cordova 要求 android --verbose

它將顯示缺少的內容,然后,如果您尚未安裝它,您可以安裝它,或者您可以檢查環境變量中的正確路徑。

我有同樣的錯誤。 我通過使用 Gradle 5.6.3 而不是較新的版本解決了這個問題。

For anyone as dumb as I was that also thought you could setup and run a cordova project on android without having java, gradle or android studio installed: Once you installed all those things , delete your cordova project's node_modules , platforms , plugins and www folders and set them up again (ie npm i , cordova platform add android , npm run build , etc) before trying to run the cordova project again. 就我而言,我正在嘗試運行cordova run android ,這導致了與 OP 相同的錯誤。

注意:我對 cordova 的經驗為零。 我必須在本地啟動並運行一個非常具體的 cordova/webpack 模板,我在這個答案中給出的建議對我有用。 YMMV。

If you have an android studio installed, you need not to worry about this error on terminal, as until this error cordova will update your android package in platforms directory.

  1. 打開您的 Android 工作室。
  2. Select 打開現有項目並瀏覽到 select 您在項目目錄中的 /platforms/android 文件夾。
  3. 它將在 android 中打開並將構建成功

改用電容器,這可能會對您有所幫助

https://youtu.be/LpwyaPrpcA4

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM