Ionic 离子失效:生成失败,出现异常

r7s23pms  于 2023-04-27  发布在  Ionic
关注(0)|答案(3)|浏览(138)

我在我的ionic项目中运行这个命令

ionic cordova build android --prod --release

但我得到以下错误:

k\build-tools\31.0.0-rc5\dx.bat
Build-tool 31.0.0 rc5 is missing DX at C:\Users\daees\AppData\Local\Android\Sdk\build-tools\31.0.0-rc5\dx.bat

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileReleaseJavaWithJavac'.
> Installed Build Tools revision 31.0.0-rc5 is corrupted. Remove and install again using the SDK Manager.

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

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

BUILD FAILED in 3s
Command failed with exit code 1: C:\Users\daees\Desktop\Ionic project\cam\platforms\android\gradlew cdvBuildRelease -b C:\Users\daees\Desktop\Ionic project\cam\platforms\android\build.gradle
[ERROR] An error occurred while running subprocess cordova.

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

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

我确实在我的android SDK中删除并添加了31.0.0-rc5\,但我得到了相同的错误
我还跟踪了stackoverflow的其他线程,但无法获得所需的结果。
我还尝试删除31.0.0-rc5\版本旁边的工具,如29.xx等,但也没有帮助。
我运行了gradle -v得到了这个

------------------------------------------------------------
Gradle 7.1.1
------------------------------------------------------------

Build time:   2021-07-02 12:16:43 UTC
Revision:     774525a055494e0ece39f522ac7ad17498ce032c

Kotlin:       1.4.31
Groovy:       3.0.7
Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM:          1.8.0_291 (Oracle Corporation 25.291-b10)
OS:           Windows 10 10.0 amd64

我该怎么办?
请帮帮忙

pn9klfpd

pn9klfpd1#

在您的应用中,转到platform/android/build.gradle并找到defaultBuildToolsVersion
例如:defaultBuildToolsVersion=“29.0.2”
现在在android studio中,转到SDK管理器,下载与build.gradle中的defaultBuildToolsVersion匹配的“AndroidSDKBuild-Tools”版本
这对我很有效。

6ss1mwsb

6ss1mwsb2#

我没有使用最新的构建工具解决了这个问题,而是选择了29.0.3和30.0.3。

pokxtpni

pokxtpni3#

因为Android Build Tools 31.0.0缺少dx文件。您可以检查此链接以获得解决方案
Android Build Error "Build-tool 31.0.0 is missing DX at /usr/local/lib/android/sdk/build-tools/31.0.0/dx"

相关问题