0

I have a an app that has 2 modules base and restaurant. I have a module output that is used for normal app release and another one for instant app. When I run the build using android studio it is working fine but when I run ./gradlew assembleRelease only the output module seems to be built. Is it possible to create the instant app apk from terminal? My instant app gradle file is only like:

apply plugin: 'com.android.instantapp'

dependencies {
    implementation project(':base')
    implementation project(':restaurant')
}

without any signing configs inside.

Rgfvfk Iff
  • 1,549
  • 2
  • 23
  • 47

3 Answers3

1

Gradle build only one module gives you a clue.

You can point gradle to the com.android.instantapp module. The instant app module basically instructs which modules to assemble, those defined by implementation project(), and zip them up for the instant app.

This base cmd worked for me:

./gradlew instantapp:assemble

Then the ia zip files will be contained in the instantapp /build/output/apk/ directory.

But even if you run ./gradlew assemble, you should still find your instant app apks.zip in that same directory.

TWL
  • 6,228
  • 29
  • 65
0

You should open the Gradle window.

View -> Tool Windows -> Gradle.

You can synchronise and run any task you want to execute (independently). if you need absolutely to do in the terminal or in a script. I m sure that after seen the name of the task. You ll be able to write your command line.

Fred
  • 24
  • 3
0

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!

DustNSummers
  • 181
  • 1
  • 1
  • 10