When typing to start an Activity
within a dynamic feature module trough an Android Studio run-configuration, I get the following warning: The activity 'SomeActivity' is not declared in AndroidManifest.xml
.
(because it is being declared in the AndroidManifest.xml
of the dynamic feature module). For reference, this is the library being used:
// https://developer.android.com/guide/app-bundle/playcore
api "com.google.android.play:core:1.6.4"
The run configuration shows & deploys both modules, but it only recognizes the activities from the base module AndroidManifest.xml
. How to start an Activity in a dynamic features module?
Side Note: When trying to install the deployed feature module, it doesn't seem to install:
I/PlayCore: SplitInstallListenerRegistry : registerListener
I/PlayCore: SplitInstallInfoProvider : No metadata found in AndroidManifest.
I/PlayCore: SplitInstallService : startInstall([feature_module],[])
I/PlayCore: SplitInstallService : Initiate binding to the service.
I/PlayCore: SplitInstallService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.splitinstallservice.SplitInstallService})
I/PlayCore: SplitInstallService : linkToDeath
I/PlayCore: SplitInstallService : onError(-5)
I/PlayCore: SplitInstallService : Unbind from service.
Where -5
means SplitInstallErrorCode.API_NOT_AVAILABLE
(likely because it's a debug build); nevertheless getInstalledModules()
should find the deployed feature module ...which it doesn't. SplitInstallInfoProvider : No metadata found in AndroidManifest
seems to be this issue - when depoying "Default APK" instead of "APK from app bundle", the feature module gets installed.
Since one cannot reference feature module activities in the base module's
AndroidManifest.xml
, I've wrote aSplitInstallActivity
, which resides in thedebug
source-set of the base module, where it is also available to tests. It can be called with a run-configuration, which passes launch flags:It either installs the feature module by
moduleName
and/or starts theActivity
byclassName
.This at least works while deploying the "Default APK" instead of "APK from app bundle".
ArgumentKeys.java
SplitInstallActivity.java
The launch of a specific
Activity
can be automated with anActivityTestRule<?>
:For testing one has to provide these dependencies in the feature module's
build.gradle
:Else it cannot link the resources of the test application and fails with:
For testing, there's also: