You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ionic Cordova构建Android 14(API Level 34)失败(Gradle错误)求助

Ionic Cordova 构建Android 14(API Level 34)应用失败,报错Gradle退出码1,求技术支持

Ionic环境信息

Ionic:

   Ionic CLI                     : 7.2.0 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.0.7
   @angular-devkit/build-angular : 0.803.29
   @angular-devkit/schematics    : 8.3.29
   @angular/cli                  : 8.3.29
   @ionic/angular-toolkit        : 2.2.0

Cordova:

   Cordova CLI       : 10.0.0
   Cordova Platforms : android 13.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 17 other plugins)

Utility:

   cordova-res (update available: 0.15.4) : 0.15.3
   native-run (update available: 2.0.1)   : 1.4.0

System:

   Android SDK Tools : 26.1.1 (/home/user/Android/Sdk)
   NodeJS            : v16.20.2 (/usr/local/bin/node)
   npm               : 8.19.4
   OS                : Linux 5.15

构建失败错误日志

Date: 2024-12-19T12:00:44.992Z - Hash: 893516b2e63dea55a99d - Time: 14179ms
> cordova build android
The "<splash>" tags were detected and are no longer supported. Please migrate to the "preference" tag "AndroidWindowSplashScreenAnimatedIcon".
cordova-plugin-androidx-adapter: Processed 75 source files in 1067ms
Checking Java JDK and Android SDK versions
ANDROID_HOME=/home/user/Android/Sdk (recommended setting)
ANDROID_SDK_ROOT=/home/user/Android/Sdk (DEPRECATED)
Using Android SDK: /home/user/Android/Sdk
Starting a Gradle Daemon, 2 incompatible Daemons could not be reused, use --status for details

FAILURE: Build failed with an exception.

* What went wrong:
Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
> Could not create service of type PluginResolutionStrategyInternal using BuildScopeServices.createPluginResolutionStrategy().

* 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 1s
Command failed with exit code 1: gradle -p /home/user/Documents/beauty_salon_app_0817/platforms/android/tools wrapper --gradle-version 8.7
[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.

已执行的升级操作

  • 修改config.xml中的android-targetSdkVersion值为34
  • 通过Android Studio安装Android 14.0("UpsideDownCake"),API Level 34
  • 通过Android Studio安装Android SDK Build-Tools 34.0.0
  • 更新Node.js:sudo n 16
  • 更新Ionic CLI:
    sudo npm install -g @ionic/cli
    npm install
    
  • 更新JAVA:
    sudo apt-get update
    sudo apt-get upgrade
    sudo add-apt-repository ppa:openjdk-r/ppa    
    sudo apt install openjdk-22-jdk                   # java 22 适配 gradle 8.7.0
    java -version                             # 检查java版本
    sudo update-alternatives --config java        # 运行此命令选择版本
    echo $JAVA_HOME                   # 检查JAVA_HOME路径
    export JAVA_HOME=/usr/lib/jvm/java-22-openjdk-amd64 # 设置JAVA_HOME 
    
  • 更新Cordova Android平台:
    cordova platform rm android
    cordova platform add android@13.0.0
    
  • 执行构建命令:ionic cordova build android -info

内容的提问来源于stack exchange,提问作者HongKong Simfusion

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 13:32:45