androidgradleproguardandroid-module

Reflection fails in signed build Android


I'm modularising our ongoing project.

Let's say there is an app module.

And 'n' number of other modules. These modules implement app module (i.e implementation project(':app_module'))

From app module I need to launch Module 1..n

I've used reflection to get the activity reference in app_module.

val intent = Intent()
intent.setClass(context, Class.forName("com.application.myapp.HelpActivity"))
context.startActivity(intent) 

So when I run the application it works fine.

But when I generated a Signed debug build and I installed it, I got ClassNotFoundException

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.application.myapp.HelpActivity" on path: DexPathList

Any idea what's causing reflection to fail in Signed debug build ?

Note: Its not a pro-guard issue. I've disabled it and I've checked. Same issue is there.

Thank you.


Solution

  • Update: The issue was because the module was treated as a dynamic module.

    Cause for the issue was dist:onDemand="true" in module's manifest.

    I set it to false and generated app bundle and installed it through bundletool. It's working fine now.