这主要是 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/