apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

Android App Bundle support #610

Closed shanlin2dltk closed 5 years ago

shanlin2dltk commented 5 years ago

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

shanlin2dltk commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

Thanks @dpogue for giving a timeline.

mesqueeb commented 5 years ago

So Cordova currently only supports APK right?

dpogue commented 5 years ago

So Cordova currently only supports APK right?

At this time, that is correct.

fortunella commented 5 years ago

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

janpio commented 5 years ago

(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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

maybe anyway how to enforce to 64bit with Phonegap?

breautek commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

@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 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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

breautek commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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

goynov commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

cd platforms/android && ./gradlew bundle

Found it here: https://github.com/apache/cordova-android/issues/729#issuecomment-511405278

But when cordova-android will fix it? 🥳

breautek commented 4 years ago

But when cordova-android will fix it? 🥳

Most likely in cordova-android version 9. You can keep track of the PR progress at https://github.com/apache/cordova-android/pull/764.

pookdeveloper commented 4 years ago

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

tomriddle1234 commented 4 years ago

this is not alert or warning anymore, but an error. there's no solution yet, although above method could generate aab file, but it doesn't contain 64bit code.

samazgor commented 4 years ago
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 commented 4 years ago

@samazgor

How is the exact way to sign the aab file?

I see there 3 options:

breautek commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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

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

desmeit commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

desmeit commented 4 years ago

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 commented 4 years ago

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.