How to access android Resources following removal of package name from Manifest in AGP 8.0+?

55 Views Asked by At

Newer versions of Android Gradle Plugin do not allow for package variable to be declared in the Android Manifest file.

I have therefore removed package from Manifest and instead added namespace variable to my modules build.gradle.kts file. I then realised that i still need access to Resources via the R import but this no longer works because i have removed package from Manifest.

So how can i access my Resources without declaring package variable in manifest?

Manifest

<!-- NOTE package variable below has been removed-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.mymoduleame">

Build.Gradle.kts

android {
    namespace = "com.example.mymoduleame"
    ....
}
import com.example.mymoduleame.R // Error: Unresolved reference R
0

There are 0 best solutions below