This article explains the basics of getting your NativePHP application to the Google Play Store.
Before you begin, you will need to register for a Play Console developer account. It has a one time fee of $25 (at the time of writing). It may take a few days to get approved on Google's side.
Once you have been approved and your NativePHP application is ready to be uploaded, you need to do the following things.
- Generate a keystore file
- Configure NativePHP to use the keystore file
- Publish your application
Generate your keystore file
You keystore file is a Java thing which is essentially a bag that can hold a bunch of things. In our case, we want it to hold our signing keys for our application (but it could hold many things).
In a terminal, run the following command (this assumes you already have a JDK installed which comes with the keytool cli).
keytool -genkey -v -keystore my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my-key-alias
-
my-release-key.jkswill be the filename -
my-key-aliasis an identifier for your key
For simplicity, I would recommend you just call both the name of your application.
Follow the prompts:
- Enter keystore password: Create and confirm a strong password. This is your password to the keystore file and we'll need to use this later.
- What is your first and last name?
- What is the name of your organisational unit?
- What is the name of your organisation?
- What is the name of your city or locality?
- What is the name of your state or province?
- What is the two letter country code for this unit?
- Type
yeswhen prompted to confirm - Enter key password for
<my-key-alias>: You can press Enter to use the same password as the keystore password or you can create a separate, unique password. This is your Key Password
You'll get an output similar to this:
Generating 2,048 bit RSA key pair and self-signed certificate (SHA384withRSA) with a validity of 10,000 days
for: CN=Norman Osborn, OU=Research & Development, O=Oscorp, L=New York, ST=New York, C=US
[Storing goblin.jks]
IMPORTANT: Store this file somewhere safe! It is used to sign every version of your app. If it is lost, you will not be able to update your app. If you have multiple apps, you should generate a new keystore file for each application.
Configure NativePHP
Now that you've got a keystore file (with your signing key inside it), we need to configure NativePHP to use it whenever you build a bundle version of your app.
There are several ways you can configure NativePHP to use this. If you're just building on your local machine the easiest is to place the following keys in your .env file.
ANDROID_KEYSTORE_FILE=/Users/normanosborn/dev/goblin-app/goblin.jks
ANDROID_KEYSTORE_PASSWORD=your-keystore-password-from-earlier
ANDROID_KEY_ALIAS=your-key-alias-from-earlier
ANDROID_KEY_PASSWORD=your-key-password-from-earlier
# Then build your application
npm run build && php artisan native:package android --build-type=bundle
If you're using some sort of automation (CI/CD perhaps), you can pass the same values as parameters to the native:package command.
php artisan native:package android \
--build-type=bundle \
--keystore=/Users/normanosborn/dev/goblin-app/goblin.jks \
--keystore-password=your-keystore-password-from-earlier \
--key-alias=your-key-alias-from-earlier \
--key-password=your-key-password-from-earlier \
--output=./artifacts \
--no-tty
or as environment variables
export ANDROID_KEYSTORE_FILE="Users/normanosborn/dev/goblin-app/goblin.jks"
export ANDROID_KEYSTORE_PASSWORD="your-keystore-password-from-earlier"
export ANDROID_KEY_ALIAS="your-key-alias-from-earlier"
export ANDROID_KEY_PASSWORD="your-key-password-from-earlier"
php artisan native:package android --build-type=bundle --output=./artifacts --no-tty
Please check out the NativePHP docs for the latest info on this.
Publish App
Once you've run the native:package command, a window will pop up to the folder where your .aab file is stored. This is your bundled and signed Android application which you can upload to the Google Play Console.
Conclusion
Once you know, it's pretty straight-forward to build and publish your application but I'm just new to this and there may be some things that I've missed. So I will update this article as I learn more.
Top comments (0)