Ionic构建失败:出现异常错误。

3

我正在我的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\,但是我仍然遇到了相同的错误。

我也查看了其他Stack Overflow线程,但没有获得所需的结果。

我还尝试删除与版本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

我该怎么办?

请帮帮我。

3个回答

1

在您的应用程序中,打开platform/android/build.gradle文件,找到defaultBuildToolsVersion

例如:defaultBuildToolsVersion="29.0.2"

现在,在Android Studio中打开SDK管理器,并下载与build.gradle中defaultBuildToolsVersion匹配的“Android SDK Build-Tools”版本

这对我有用。


谢谢您的回复,我按照您说的做了,但这次出现了不同的错误:“执行任务':app:lintVitalRelease'失败。
无法解析配置文件':app:lintClassPath'中的所有文件。
- Sadaf Shafi
我有相同的错误,而且该行已经设置为29.0.2。 - Flecibel

0

我通过不使用最新的构建工具来解决了这个问题,而是选择了29.0.3和30.0.3版本。


0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接