Skip to content
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

Android App Bundle support #610

Closed
shanlin2dltk opened this issue Jan 2, 2019 · 51 comments
Closed

Android App Bundle support #610

shanlin2dltk opened this issue Jan 2, 2019 · 51 comments

Comments

@shanlin2dltk
Copy link

What is the plan to support Android App Bundle .aab in a cordova build?

@shanlin2dltk
Copy link
Author

added one reference article to show android is moving to this direction:
https://medium.com/googleplaydev/what-a-new-publishing-format-means-for-the-future-of-android-2e34981793a

@dpogue
Copy link
Member

dpogue commented Jan 2, 2019

I've been investigating this (along with some other gradle updates for stuff like Kotlin and Google Services). It's clear that we should support this going forward, but I don't think it will actually provide any benefits to Cordova apps in terms of APK size.

Unfortunately, it doesn't look like I'm going to have any time to work on Cordova stuff for the next month or two, so unless someone else picks it up it won't be until sometime later in the year.

@shanlin2dltk
Copy link
Author

Thanks @dpogue for giving a timeline.

@mesqueeb
Copy link

mesqueeb commented Jan 5, 2019

So Cordova currently only supports APK right?

@dpogue
Copy link
Member

dpogue commented Jan 5, 2019

So Cordova currently only supports APK right?

At this time, that is correct.

@fortunella
Copy link

Any updates on this?
Currently, the Google Play Console shows a warning each time you upload an APK.

@janpio
Copy link
Member

janpio commented May 8, 2019

(A good solution would probably be to open a Feature Request issue, so this can be tracked and doesn't get lost in a closed issue @fortunella)

@pabloleone
Copy link

Google is not allowing me to roll-out an APK and it's suggesting me to use the Bundle build, but as far as I understand we can't use that build format yet which makes impossible to publish new apps using cordova-android if I'm right.

I think this should be a top-urgent feature to cover to keep using cordova.

Screenshot 2019-06-04 at 17 42 20

@janpio
Copy link
Member

janpio commented Jun 4, 2019

You better create a new issue for this, so it doesn't get buried here.

Please also include specific information about your app, like the APK size etc.

@breautek
Copy link
Contributor

breautek commented Jun 4, 2019

@pabloleone You should be still able to publish apps that contains warnings. In my experience, Google only ever prevents publishing if the contains "errors". But I do agree, this is an important enhancement and something I can definitely can foresee Google enforcing in the future.

@malvarez-troop
Copy link

malvarez-troop commented Jun 5, 2019

Hi, @pabloleone
We have generated the bundle with Android Studio.

The steps are:

  1. Launch Android Studio
  2. Go To Import Project (Eclipse ADT, Gradle, etc).
  3. Select Android platform directory in your project (/platforms/android).
  4. Wait for finish the Sync
  5. Go to Build > Generate Sign Bundle
  6. Complete sign data
  7. Upload de .aab file generated (in path /platforms/android/outputs/

Note: if you have problems with minSDK version, fix this and make a resync

@zarabz
Copy link

zarabz commented Jun 5, 2019

Worked for me! thank you so much
In case anyone else have problems with updating their Android Studio and Gradle versions, remove minSdkVersion from config.xml and add these to your manifest (your version may vary)
android{
...
defaultConfig {
minSdkVersion 19
targetSdkVersion 27
}
}

@theunreal
Copy link

Hi, @pabloleone
We have generated the bundle with Android Studio.

The steps are:

  1. Launch Android Studio
  2. Go To Import Project (Eclipse ADT, Gradle, etc).
  3. Select Android platform directory in your project (/platforms/android).
  4. Wait for finish the Sync
  5. Go to Build > Generate Sign Bundle
  6. Complete sign data
  7. Upload de .aab file generated (in path /platforms/android/outputs/

Note: if you have problems with minSDK version, fix this and make a resync

Android studio is not asking you to upgrade the gradle plugin version every time you build the app?

@etcho
Copy link

etcho commented Jun 9, 2019

Hi, @pabloleone
We have generated the bundle with Android Studio.

The steps are:

  1. Launch Android Studio
  2. Go To Import Project (Eclipse ADT, Gradle, etc).
  3. Select Android platform directory in your project (/platforms/android).
  4. Wait for finish the Sync
  5. Go to Build > Generate Sign Bundle
  6. Complete sign data
  7. Upload de .aab file generated (in path /platforms/android/outputs/

Note: if you have problems with minSDK version, fix this and make a resync

My project don't have an Android plataform folder, only browser. And when I try to import it, Android Studio says that my project contains non-ASCII characters... Don't know what to do.

@malvarez-troop
Copy link

Hi, @pabloleone
We have generated the bundle with Android Studio.
The steps are:

  1. Launch Android Studio
  2. Go To Import Project (Eclipse ADT, Gradle, etc).
  3. Select Android platform directory in your project (/platforms/android).
  4. Wait for finish the Sync
  5. Go to Build > Generate Sign Bundle
  6. Complete sign data
  7. Upload de .aab file generated (in path /platforms/android/outputs/

Note: if you have problems with minSDK version, fix this and make a resync

Android studio is not asking you to upgrade the gradle plugin version every time you build the app?

I did not have the problem. But a developer in my company has to update Gradle. Tomorrow I'm going to ask her about that

@malvarez-troop
Copy link

Hi, @pabloleone
We have generated the bundle with Android Studio.
The steps are:

  1. Launch Android Studio
  2. Go To Import Project (Eclipse ADT, Gradle, etc).
  3. Select Android platform directory in your project (/platforms/android).
  4. Wait for finish the Sync
  5. Go to Build > Generate Sign Bundle
  6. Complete sign data
  7. Upload de .aab file generated (in path /platforms/android/outputs/

Note: if you have problems with minSDK version, fix this and make a resync

My project don't have an Android plataform folder, only browser. And when I try to import it, Android Studio says that my project contains non-ASCII characters... Don't know what to do.

You have to add android platform first to build a Android project

@xale76
Copy link

xale76 commented Jun 15, 2019

Hello I don't understand. What's step 3? where I can find /platforms/android? I build with PhoneGap and I don't have this folder. Please help me

@Lukaskaras
Copy link

Hi, @pabloleone
We have generated the bundle with Android Studio.
The steps are:

  1. Launch Android Studio
  2. Go To Import Project (Eclipse ADT, Gradle, etc).
  3. Select Android platform directory in your project (/platforms/android).
  4. Wait for finish the Sync
  5. Go to Build > Generate Sign Bundle
  6. Complete sign data
  7. Upload de .aab file generated (in path /platforms/android/outputs/

Note: if you have problems with minSDK version, fix this and make a resync

Android studio is not asking you to upgrade the gradle plugin version every time you build the app?

I have exactly this problem. Can't get past it. Was changing the Android Gradle Plugin version manually through File -> Project Structure, but didn't help. Anybody knows how to solve it?

@xale76
Copy link

xale76 commented Jun 15, 2019

facing the same issue, I build my app by phonegap, even there nobody gives solutions. since 1st August, google will no longer accept Apk, I'm scared! any solution for phonegap??

@breautek
Copy link
Contributor

facing the same issue, I build my app by phonegap, even there nobody gives solutions. since 1st August, google will no longer accept Apk, I'm scared! any solution for phonegap??

I could not find anything that said Google won't be accepting APKs after August 1st. Are you sure you're not confusing that with the incoming 64-bit enforcement?

@xale76
Copy link

xale76 commented Jun 15, 2019

maybe anyway how to enforce to 64bit with Phonegap?

@breautek
Copy link
Contributor

maybe anyway how to enforce to 64bit with Phonegap?

Not sure... It's important to note that you only need to provide 64bit APK if you use native libraries with your application. Cordova does not use native libraries in any of its plugins that Cordova manages. If you do use a plugin that includes a native library, cordova already supports building multiple APKs by 32/64bit variant which satisfies Google's 64bit enforcement. But whether you need to use that build method is entirely dependent on your app.

@janpio
Copy link
Member

janpio commented Jun 15, 2019

@xale76 You should ask the Phonegap people, not Apache Cordova. And even if you want to ask this here, do so in a new issues instead of asking off topic question in an issue about Android App Bundle support.

@xale76
Copy link

xale76 commented Jun 15, 2019

@breautek so I don't understand why Google warnes me: I only build PG with standard Cordova plugins or NPM. please how can I check if I need to take any action or noT? Is there any tool I can use?

@breautek
Copy link
Contributor

@breautek so I don't understand why Google warnes me: I only build PG with standard Cordova plugins or NPM. please how can I check if I need to take any action or noT? Is there any tool I can use?

Regarding App Bundles, google is warning everyone who is still publishing the old way. They are just recommending developers to make the switch. At the time of writing, they have announced no plans forcing people to use app bundles.

@goynov
Copy link

goynov commented Jun 21, 2019

Once you've opened, synced and built using the Android Studio (3.2+), you can use this command line from the ./platforms/android/ directory:
./gradlew app:bundleRelease

@jfoclpf
Copy link

jfoclpf commented Jun 23, 2019

@malvarez-troop
Is there any way to do the same with the command line adb ?

@breautek
Copy link
Contributor

breautek commented Jun 23, 2019

@malvarez-troop
Is there any way to do the same with the command line adb ?

I don't believe so. adb is for communicating with your android device. You can't deploy .aab files to your android device directly. They meant exclusively for deploying your app to the Google Play store. As @goynov said, you can use ./platforms/android/gradlew app:bundleRelease from within ./platforms/android/ directory, run `./gradlew app:bundleRelease to generate the aab bundle for now.

@jfoclpf
Copy link

jfoclpf commented Jun 23, 2019

I found it! Here on Google they have instructions on how to build the bundle file with the command line.

you can use ./platforms/android/gradlew app:bundleRelease to generate the aab bundle for now.

Thanks a lot @BBosman

@jfoclpf
Copy link

jfoclpf commented Jun 23, 2019

@BBosman apologies but I'm not that versed in gradle but what shall I put in app? The project id? CordovaLib?

@goynov
Copy link

goynov commented Jun 24, 2019

You should run ./gradlew app:bundleRelease from this directory: ./platforms/android/

./platforms/android/gradlew app:bundleRelease will not do the job.

And it will work only when you upgrade Android Studio to 3.2+ and then open your project using the studio, sync it, resolve possible issues and then build.

@jfoclpf
Copy link

jfoclpf commented Jun 24, 2019

@goynov thanks for the tip, I will try it. But according to google instructions

The easiest way to build an app bundle is by using Android Studio. However, if you need to build an app bundle from the command line, you can do so by using either Gradle or bundletool, as described in the sections below.

It gives some how the impression that we can avoid Android Studio. But maybe it's like you say, we use the command line but we need to have Android Studio installed and synced. They talk about bundletool and AAPT2 but I had not the time to read all of that documentation thoroughly.

@hugoblanc
Copy link

Google is not allowing me to roll-out an APK and it's suggesting me to use the Bundle build, but as far as I understand we can't use that build format yet which makes impossible to publish new apps using cordova-android if I'm right.

I think this should be a top-urgent feature to cover to keep using cordova.

Screenshot 2019-06-04 at 17 42 20

In my case I thought I was not able to publish because of this, but in fact, that was due to others play store sections which was not completly filled

@ewwwgiddings
Copy link

If anyone experiences errors with leftShift() not found as I did. See this SO post:
https://stackoverflow.com/questions/55793095/could-not-find-method-leftshift-for-arguments-after-updating-studio-3-4

@martinjuhasz
Copy link

Google is not allowing me to roll-out an APK and it's suggesting me to use the Bundle build, but as far as I understand we can't use that build format yet which makes impossible to publish new apps using cordova-android if I'm right.
I think this should be a top-urgent feature to cover to keep using cordova.
Screenshot 2019-06-04 at 17 42 20

In my case I thought I was not able to publish because of this, but in fact, that was due to others play store sections which was not completly filled

This is a very valid response. i also thought i cannot publish (for internal testing) because of this warning (button was greyed out) but it was in fact because of the not fulfilled informations for a new app.

Make sure all checkmarks on the left navigation panels are green, then this should not be an issue for releasing

@patrickbussmann
Copy link

I'm having the same issue and I fixed it via this command.

cd platforms/android && ./gradlew bundle

Found it here: #729 (comment)

But when cordova-android will fix it? 🥳

@breautek
Copy link
Contributor

But when cordova-android will fix it? 🥳

Most likely in cordova-android version 9. You can keep track of the PR progress at #764.

@pookdeveloper
Copy link

IMPORTANT resolve the grey check points to publish and ignore the alert

@tomriddle1234

This comment has been minimized.

@samazgor
Copy link

ionic cordova build android --prod --release -- -- --versionCode=2
cd platforms/android && ./gradlew bundle

.aab file can be found at the following folder

platforms/android/app/build/outputs/bundle/release

Finally sign the .aab file before upload.

@desmeit
Copy link

desmeit commented Oct 24, 2019

@samazgor

How is the exact way to sign the aab file?

I see there 3 options:

  • Upload a key exported from Android Studio

  • Exporting and Uploading a Key from a Java Keystore

  • Exporting and Uploading a Key (Not from a Java Keystore)

@breautek
Copy link
Contributor

@samazgor

How is the exact way to sign the aab file?

I see there 3 options:

  • Upload a key exported from Android Studio
  • Exporting and Uploading a Key from a Java Keystore
  • Exporting and Uploading a Key (Not from a Java Keystore)

The easiest way is to include a build.json file in your project, see the documentation for details on how to create the build.json to supply your keystore and passwords. This will allow the build process to sign the APK or AAB file during the build.

If you don't want to have your password in the text file, you can leave them empty and the password should be prompted during the build.

If you don't want to use the build.json, then you need to use the jarsigner according to the android documentation however I've never done this, and they don't go into detail on how to use jarsigner with an aab file.

@desmeit
Copy link

desmeit commented Oct 24, 2019

Thanks. Two questions:

  1. Should I add the signing files (keystore, debug-signing.properties and release-signing.properties) in addition to the android folder like i did before before i worked with the build.json file?

  2. I get the following error, although it found the keystore file during the build process:

* What went wrong:
Failed to create component for 'dialog' reason: java.awt.HeadlessException
> java.awt.HeadlessException (no error message)

Thats my file:

"ios": {
    "debug": {
        "codeSignIdentity": "iPhone Developer",
        "developmentTeam":"XXX",
        "provisioningProfile": "XXX",
        "packageType": "development",
		"buildFlag": [
		  "-UseModernBuildSystem=0"
		]
    },
    "release": {
        "codeSignIdentity": "iPhone Distribution",
        "developmentTeam":"XXX",
        "provisioningProfile": "XXX",
        "packageType": "app-store",
		"buildFlag": [
		  "-UseModernBuildSystem=0"
		]
    }
},
	"android": {
        "debug": {
            "keystore": "androidsigning/XXX.keystore",
            "storePassword": "",
            "alias": "XXX",
            "password" : "",
            "keystoreType": ""
        },
        "release": {
            "keystore": "androidsigning/XXX.keystore",
            "storePassword": "",
            "alias": "XXX",
            "password" : "",
            "keystoreType": ""
        }
    }
}

I tried with and without password.

@breautek
Copy link
Contributor

Thanks. Two questions:

  1. Should I add the signing files (keystore, debug-signing.properties and release-signing.properties) in addition to the android folder like i did before before i worked with the build.json file?
  2. I get the following error, although it found the keystore file during the build process:
* What went wrong:
Failed to create component for 'dialog' reason: java.awt.HeadlessException
> java.awt.HeadlessException (no error message)

Thats my file:

"ios": {
    "debug": {
        "codeSignIdentity": "iPhone Developer",
        "developmentTeam":"XXX",
        "provisioningProfile": "XXX",
        "packageType": "development",
		"buildFlag": [
		  "-UseModernBuildSystem=0"
		]
    },
    "release": {
        "codeSignIdentity": "iPhone Distribution",
        "developmentTeam":"XXX",
        "provisioningProfile": "XXX",
        "packageType": "app-store",
		"buildFlag": [
		  "-UseModernBuildSystem=0"
		]
    }
},
	"android": {
        "debug": {
            "keystore": "androidsigning/XXX.keystore",
            "storePassword": "",
            "alias": "XXX",
            "password" : "",
            "keystoreType": ""
        },
        "release": {
            "keystore": "androidsigning/XXX.keystore",
            "storePassword": "",
            "alias": "XXX",
            "password" : "",
            "keystoreType": ""
        }
    }
}

I tried with and without password.

I'd advise creating a new issue describing the problem so that can be tracked. This appears to be related to the prompt feature that suppose to ask you for your password.

@samazgor
Copy link

samazgor commented Oct 24, 2019

@desmeit
here is a demo code i used so far

cd ~/Android/Sdk/build-tools/28.0.3/
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore /home/USER/KEYSTORE_FILE_PATH/MY_RELEASE_KEY.keystore /home/USER/YOUR_APP/platforms/android/app/build/outputs/bundle/release/app.aab ALIAS_NAME -storepass STORE_PASS

Dont forget to replace

  • Path of .keystore
  • Path of app.aab
  • ALIAS_NAME
  • STORE_PASS

Follow this https://ionicframework.com/docs/publishing/play-store just replace .apk with .aab

@desmeit
Copy link

desmeit commented Oct 24, 2019

Thanks @samazgor

Just one question.

i still have to register for the app signature at google play. he asks me the following:

Upload a key exported from Android Studio

Exporting and Uploading a Key from a Java Keystore

Exporting and Uploading a Key (Not from a Java Keystore)

if i want to work with my existing keystore, should i choose option 3 and upload my old keytore file?

@breautek
Copy link
Contributor

Google doesn't require you to upload your keystore to the play store, or at least I haven't forced to yet and I've published app updates earlier this week. They will however push you to do so. And once you do, you cannot sign apps yourself, you must let google sign your apps or bundles.

@samazgor
Copy link

@desmeit
are you updating an existing app or unpublished app?
Please check this docs - https://support.google.com/googleplay/android-developer/answer/7384423

@desmeit
Copy link

desmeit commented Oct 25, 2019

Bildschirmfoto 2019-10-25 um 09 01 13

I get this info:

If you want to upload an Android App Bundle, you must be signed in to the Google Play App Signature.

But to sign for signature, I have to upload a keystore file.🤔
I try to update an existing app.

@desmeit
Copy link

desmeit commented Oct 25, 2019

OK solved.
I have to choose option 2: Exporting and Uploading a Key from a Java Keystore

  1. Download PEPK File
  2. Navigate to folder with keystore in the terminal
  3. copy into this folder the PEPK file
  4. take encryptionkey from google and type in terminal:
    java -jar pepk.jar --keystore=XXX.keystore --alias=XXX --output=private_key.pem --encryptionkey=XXX
  5. Upload pem file to Google
  6. now you are registered for Google App Signature
  7. You can now sign your aab as @breautek described with the build.json file. but for me the password had to be included

on this website (at the bottom) is a very good explanation:
https://iphonedevlog.wordpress.com/2019/09/17/making-an-android-app-bundle-aab-file-from-a-cordova-project/

Thanks for your help.

@robertramirezg
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests