Unable to build a bundle

Dear all,

I am building a cht-android flavor as described in the documentation

I have successfully build the apks for Webview and for lower Android version. When building the bundle with the command

make org=new_brand flavor=New_brand bundle

I get the error message

bundleNew_flavorRelease not found in root project ‘cht-android’

Such a file is indeed not there, but when was it supposed to be created?

Can you double-check that you have added your New_brand config to the build.gradle in the android/productFlavors section (as described in step 2.2)?

If this is missing or does not match the flavor you are using in the bundle command, it could cause the error you are seeing.

Dear @jkuester,

yes I have the entry:

new_flavor {
dimension = ‘brand’
applicationID = ‘org.medicmobile.webapp.mobile.new_flavor’
}

Okay, so we must have something weirder going on… Another thing to double-check is if you have the ANDROID_HOME environment variable properly set as described here: https://docs.communityhealthtoolkit.org/contribute/code/android/development-setup/.

If that is setup properly and it still does not work, you could try forcing gradle to rebuild its cache for the project (just in case something has been corrupted in there). From within your cht-android directory, run mv .gradle backup.gradle

If none of that works, it would be helpful if you could post the complete output for your make org=new_brand flavor=New_brand bundle command.

@jkuester
before digging deeper, could you please clarify that the path of the generated apks is correct?
According to the documentation, the files should have been created in

build/outputs/apk/new_brand/release/

In my case the files are in :

build/outputs/apk/new_brand/release/new_brandWebview/release

and

build/outputs/apk/new_brand/release/new_brandXwalk/release

I assume that the bundle command is accessing the apks to make the bundle, so that path probably matters.

Dear @jkuester your suggested solutions did not help, unfortunately.
Yes, ANDROID_HOME is properly set. I have moved .gradle

Please find the output of the bundle command (revealing the encryption)

ANDROID_KEYSTORE_PATH=msfecare.keystore ANDROID_KEY_ALIAS=medicmobile
ANDROID_KEYSTORE_PASSWORD=4cdc7f5096ac71e5 ANDROID_KEY_PASSWORD=4cdc7f5096ac71e5
./gradlew --daemon --parallel bundleMsfecareRelease

Configure project :
WARNING:Using flatDir should be avoided because it doesn’t support any meta-data formats.

FAILURE: Build failed with an exception.

  • What went wrong:
    Task ‘bundleMsfecareRelease’ not found in root project ‘cht-android’.

  • Try:

Run gradlew tasks to get a list of available tasks.
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See Command-Line Interface

BUILD FAILED in 2s
make: *** [Makefile:54: bundle] Error 1

Okay, wait, I think I know what is going on here. Is the branch for you new branded based on a previous tag of cht-android (such as v0.11.1)? If so, you will also need to include the the version (Webview/Xwalk) as part of your flavor that you provide to make ... bundle.

E.g.: make flavor=New_brandWebview bundle

The source of my confusion was that in the upcoming v1.0.0 of cht-android we are removing the separate versions and so if you happen to be testing things while on the master branch (like I was) then make flavor=New_brand bundle should work without the extra version notation…

Note that it is correct to base the branch for your new bundle off of the last released version (as mentioned in the documentation) and not off master. Just realize that with the new major version of cht-android, this bundle command will be changing. @Jennifer_Quesada feel free to jump in here and correct me if I am wrong or add anything I missed!

Hi @jkuester
I’m running into this same problem.
I was base to base my branch to v1.0.4 however I’m getting the following error.
FAILURE: Build failed with an exception.

  • What went wrong:
    Task ‘assemblesearch_cht’ not found in root project ‘cht-android’.

  • Try:

Run gradlew tasks to get a list of available tasks.
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See Command-Line Interface

BUILD FAILED in 3s
make: *** [Makefile:42: assemble] Error 1

Kindly note that I added my new flavor into into build.gradle,
Any insights on what I might be missing out.
Thank you.
Erick

If you run ./gradlew tasks do you see assemblesearch_cht in the list of “Build tasks”?

Can you share the exact make command you are running when you get this error?

Hi the the command
make flavor=search_cht assemble
I’ve executed /gradlew tasks and I can’t see assemblesearch_cht in the list of “Build tasks”.
Thank you.
Erick

I’ve seen the error I was making, and I’m now able to see assemblesearch_cht on the list of task.
Thank you.

Erick

2 Likes

Hi,
My app bundles very well and generates the required APK.
However when I install the apk on my android phone or the android emulator. The app is not displaying any page.
Kindly let me if I might have missed anything in this configuration

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">Search Cht</string>
    <string name="app_host">URL of the host server</string>
</resources>

Is the configuration of “app_host” ok?
Thank you.
Erick

Sorry for the delayed response! That strings.xml should be fine as long as URL of the host server is actually a real URL for your server! For example:

<?xml version="1.0" encoding="utf-8"?>
<resources>
	<string name="app_name">Medic (gamma)</string>
	<string name="app_host">gamma.dev.medicmobile.org</string>
</resources>

The app is not displaying any page.

Do you mean that you cannot see the app at all on the device, or that nothing is displayed when openning the app?