I've create a module at Android Studio. In module code, I want to show a dialog which uses a layout defined in the module. When I reference layout like net.gwtr.module.R.layout.my_dialog_layout, I get this exception;
java.lang.ClassNotFoundException: Didn't find class "net.gwtr.module.R$layout" on path: DexPathList[[zip file "/data/app/net.gwtr.moduletest-1.apk"],nativeLibraryDirectories=[/data/app-lib/net.gwtr.moduletest-1, /vendor/lib, /system/lib]] I think the reason is that resources are merged when you add a module to project. It did not create different resource ids for the module package name. So i cannot reach to resources from module package.
How can I reference resources of module in module code?
Edit1: I reference resource like this;
Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.my_dialog_layout); dialog.show(); Edit2: I found a way but i don't want to use this every time when I reference resource.
I can reach resources when I get resource id with this;
context.getResources().getIdentifier("my_dialog_layout", "layout", context.getPackageName())