It doesn't look like this question was ever answered, so in case anyone else is searching for it, here you go:
The new recommended way to produce an Instant App is via Instant Enabled App Bundles. (See Google Developer Documents for details)
Basically, you need to first build an app "bundle". To do so, there are a number of steps, but basically you need to get your application within the recommended size limitations (10 MB) and ensure that you are not using any unsupported permissions. If you are working with a larger application, the best way to do this is to modularize your features and only include those features that you want to be "instant". This "instant" version of your application will be a separate Flavor, and from there, you can add in the following to the Manifest that corresponds to the Instant app version of your application.
<manifest ... xmlns:dist="http://schemas.android.com/apk/distribution">
<dist:module dist:instant="true" />
...
</manifest>
When you've done that, if you want to build using CLI/Terminal, you will need to build using the new bundle
version of your application. You can run ./gradlew tasks
to see what options you have available, or just run ./gradlew bundle
which will run them all.
Next, to test to ensure that your app bundle was done correctly, you will need a couple more tools. The bundletool (provided by Google here), and the ia
tool, located in your $ANDROID_HOME/extras/google/instantapps/
directory. (Just slap that on your path or have an alias point to it).
With both of these tools in hand, you will need access to a signing key for the instant app. I haven't tried it, but you could probably use the debug
signing key for testing purposes. Just to quickly demonstrate how to build a key using CLI
, here you go:
apksigner sign --ks my-instant-app-key.jks --out my-app-release.apk my-app-unsigned-aligned.apk
Note: Don't use this for production, this is just demonstration.
Now, we can build the APK's for our app bundle and sign them.
$ java -jar bundletool-all-*.jar build-apks \
//1
--bundle=app.aab \
//2
--output=app.apks \
//3
--connected-device \
//4
--ks=your-keystore-path \
//5
--ks-pass=pass:your-keystore-password \
//6
--ks-key-alias=your-key-alias \
//7
--key-pass=pass:your-key-password
Note: The above was taken from the following tutorial.
Next, check to see if your instant app was done correctly by running the following:
ia check instant-app.apks
The s
at the end of apks
is not a typo. If all checks out, you can run the app using:
ia run instant-app.apks
Hope this helps!