android - 无法从您的 Ionic 应用生成 Android App Bundle(没有 Android Studio)

标签 android cordova ionic3 build.gradle gradlew

这主要是 build fail for android 的重复项但是还没有答案,而且我的情况略有不同,所以再放一次。

就我而言,我能够正确构建 apk,并且我想在命令成功后创建一个应用程序包
ionic cordova build android --prod --release通过运行这个 cmd,我可以生成 apk。

之后我要去/platform/android并运行 ./gradlew bundle在这里我收到了这个错误

The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.


FAILURE: Build failed with an exception.

* What went wrong:
Task 'bundle' is ambiguous in root project 'android'. Candidates are: 'bundleAppClassesDebug', 'bundleAppClassesDebugAndroidTest', 'bundleAppClassesDebugUnitTest', 'bundleAppClassesRelease', 'bundleAppClassesReleaseUnitTest', 'bundleDebug', 'bundleRelease'

如何解决?

最佳答案

对于那些最终来到这里并发现 --packageType=bundle flag 似乎不起作用,密切注意注释 here :

Note: You should use double -- to indicate that these are platform-specific arguments, for example:

cordova run android --release -- --keystore=../my-release-key.keystore --storePassword=password --alias=alias_name --password=password --packageType=bundle.


注意空的 ----release 之后.以下假设您已经在 build.json 中配置了 keystore 和密码。 :
cordova build android --packageType=bundle // flag is silently ignored, generates apk
cordova build android -- --packageType=bundle // flag works, generates aab

关于android - 无法从您的 Ionic 应用生成 Android App Bundle(没有 Android Studio),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61364268/

相关文章:

安卓NFC无法读取Oberthur ID ONE(PIV类型A大D)

javascript - Mobile Safari - 显示控制台?

带有 wkwebview 插件的 Cordova ios - window.open(url, "_system") 不起作用

angular - 为什么 ngClass 无限期地调用函数?

cordova - ionic cordova build ios --模拟器不显示失败或成功构建

angular - 如何将 url 参数(查询字符串)传递给 ionic 3 上的 HTTP POST 请求

android - 从我的 android 应用程序向 chrome 发送/接收消息

android - 同步帐户未在“设置”>“帐户”下创建

android - 总是在顶部布局不起作用

javascript - Cordova 3.5 的 InAppbrowser window.open 插件无法正常工作