-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Build app bundles (.aab files) #764
Conversation
This comment has been minimized.
This comment has been minimized.
corrected tests bundle flag added bundle specific output reverted jasmine-spec-reporter change revert jasmine config change
Thanks for the pull request!! I haven't looked at this in any detail yet, but in my recent musing about how we might add support for this feature I had imagined we might reuse the |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Codecov Report
@@ Coverage Diff @@
## master #764 +/- ##
==========================================
- Coverage 66.57% 66.02% -0.56%
==========================================
Files 18 19 +1
Lines 1822 1860 +38
==========================================
+ Hits 1213 1228 +15
- Misses 609 632 +23
Continue to review full report at Codecov.
|
I'm open to suggestions and will gladly modify this PR. I opened this PR with exactly that in mind actually. I do have one question about using a setting from Bundles won't be replacing APKs. Developers actively developing their app will still build APKs and deploy to their devices/emulators for testing. But one might opt to build a bundle instead of an APK to release to the app store. So I think the general use case is most of the time, developers will be building APKs, just like they have always done traditionally. Then they'll build a bundle when they are ready to make a release. If the setting to decide whether to build an APK is in a json file, I think most people will end up requiring to edit the file constantly based on what they want to build. This is why I opted to add a Interested to hear your thoughts on this. |
This is probably not about either/or, but about "additionally". I generate the |
Ok that makes sense to me. Later tonight I can make an edit where I can grab the setting from build.json |
I think what we do on iOS with |
Is the bumping of the devDependencies |
|
I would really favor keeping the |
Thanks for your explanation, I'm a little new to this. :) Didn't think of potential conflicts that could occur later. The changeset was more or less and artefact of me messing around with jasmine when I having troubles with Node12, that I forgot to revert before I made the PR. I've added a TODO item for myself to revert these devDependency changes later tonight. |
Ugh, that's true - you should create an issue that cordova-android currently doesn't build nightlies :/ Then your best bet is to install from |
Thanks for the info. Created #810 |
@tomriddle1234 it should work using
like explained in doc about flags :
|
Just leaving a note here for Crosswalk users (like myself, since I haven't migrated away from it yet...) If you are using the crosswalk webview plugin, building bundles will not give you a bundle that contains the 64bit crosswalk library. This is because the crosswalk plugin downloads a single prebuilt library and it will only download 32bit architecture; unless the As a result, using bundles will not work properly with the crosswalk webview. Even if you use the This is a problem with the crosswalk webview plugin itself, it will need to be updated so it packages all prebuilt libraries for each architecture when you build a bundle. Note that Intel has stopped maintaining the crosswalk project a couple years ago so you won't see a fix on the official crosswalk repository. |
Does this work with cordova platform add [email protected] ? |
No, this feature was only merged in and released under
Those two commands looks right. |
I'm trying to convert to use app bundles, but when I use: ionic cordova build android --release -- --packageType=bundle cordova still creates an apk in build/outputs/apk. I'm using [email protected] and [email protected] How can I get cordova to create an aab in build/outputs/bundle? |
See ionic-team/ionic-cli#4187 (comment) for how to pass |
@breautek, yes I saw that post in my trawl through the forums. In fact, that's the one I got the format of the command from that I used above. Unfortunately, it doesn't appear to work, as it keeps creating an apk, instead of a bundle. Hence my question of how I can get it to create a bundle. Is there something more I have to do than just adding the extra parameter to the command? |
For ionic it's: You have: Note the double |
I couldn't get cordova 8.1.0 to build anything other than an apk, so I resorted to using the following step between the ionic build and jarsigner steps: cd ./platforms/android ; ./gradlew app:bundleRelease ; cd ../.. ; which worked first time and the resulting signed bundle was accepted by the Play Store. I hope that helps anyone with the same problem. |
Hello @breautek Regards |
If phonegap supports the If it doesn't work... You'll have to ask the phonegap team. Cordova supports it as of cordova-android 8.1.0. |
I've now tried using build.json to create an aab and it works! My build.json is (located in the project root folder):
and the build command is:
I hope that helps. |
the problem is that i use phonegap build to build the apps, so i don't know which solution or method can i used to make this codes in phonegap build |
May be best to ask the phonegap team. It's possible that they require some updates on their end to support the latest |
You are right, but unfortunately i put an issue in phoengap build github page about .aab file that not support in current phonegap cli (android 8.0.0), I think they should update the version of android to the latest one, but until now no anyone investigate about the issue |
…n parse This allows corber to perform bundle/aap builds for android apache/cordova-android#764
Had a similar problem: I was getting .apk instead of .aab with all the above mentioned commands. What worked for me eventually was running: c:\Cordova\app_name\platforms\android>gradlew.bat bundle Might also worth mentioning here is that gradle is still looking for ANDROID_HOME environment variable, although it's officially deprecated. |
Thanks very much for this feature. But I have a question. Is it somehow possible to build an apk and an abb file at the same time? Or do I have to choose between these two? I would like to have both types built. |
You can't do it at the same time, but you can run the build twice, one with the https://cordova.apache.org/docs/en/dev/guide/platforms/android/index.html#using-flags |
Thanks for the fast answer. Works Great. |
Platforms affected
Motivation and Context
This PR adds support to build android bundle (aab) files.
Fixes: #729
Description
Adds an--bundle
flag to thecordova build
command. If present, cordova will do the necessary steps to run thegradlew bundleDebug
command (orgradlew bundleRelease
if--release
flag is present)Accepts
packageType
property frombuild.json
, or optionally the--packageType=apk|bundle
command line argument. ThepackageType
property was chosen to keep consistency with the iOS platform.This PR does not change the current build commands. Building APKs is still necessary for deploying apps to test devices, or of course to upload to the Google Play store using the traditional way. Bundle files are exclusively for deploying to Google Play Store.
You can however use the google provided
bundletool
program to build APKs from a bundle file so this PR still provides the ability to build bundles in both debug and release variants.If
build.json
is present in the cordova project, just like building APKs, bundles will automatically be signed using the key and password as defined inbuild.json
.This PR does alter a previous constraint where if a signing property is present, but is missing the required properties for signing a warning would be displayed. This was altered to only show the warning if a property for signing is present is missing the required properties for signing. In other words, if
packageType
is the only property defined in thebuild.json
file, then a warning about missing required properties for signing won't be emitted.The
cordova run android
command has been modified to produce an error ifpackageType
is set tobundle
. This is because you cannot execute/deploy a bundle directly to the phone. I believe it is possible to replace all usages of theadb
tool and instead use Google'sbundletool
, which provides tools to deploy bundle files to devices and thus support thecordova run
command using bundles, but that would be another PR for another day.Testing
I have done the following:
--packageType
flagnpm test
and ensure all tests passed (Running Node 10.x & cordova@9)cordova-android
platform to a test app viacordova platform add https://github.com/breautek/cordova-android.git#app-bundle
and manually ran build commands and all combinations of--debug
,--release
, and--bundle
cordova build android --bundle --release
.Checklist
(platform)
if this change only applies to one platform (e.g.(android)
)TODO
packageType
to decide whether to build an APK or bundle. Overridable by --packageType (Removing the --bundle flag)withContext
, the other doesn't)nyc
andjasmine
Crosswalk Users
See #764 (comment)