moko-resources
moko-resources copied to clipboard
Android fails to compile with AGP 7.3.0-beta03
Hi! I tried updating Android Gradle Plugin to 7.3.0-beta03 and Moko Resource to 0.20.1 and I can't compile Android anymore.
Steps:
- Install Android Studio Dolphin Beta 3
- Update Android Gradle Plugin in this project to
7.3.0-beta03as in this fork - Run
sample.android-mpp-app
Gradle fails with:
Task :sample:android-mpp-app:compileDebugKotlinAndroid FAILED
e: ..\moko-resources\sample\android-mpp-app\build\generated\moko\androidMain\src\com\icerockdev\library\MR.kt: (16, 77): Unresolved reference: common_name
I investigated this and it looks like AGP 7.3.0 is ignoring resources in the generated folder. It might be a bug in AGP but I don't know enough to create a ticket there.
hi @headsvk as i see android gradle plugin read resources dirs before our generation dir was added. why - i not find yet. i think we should wait release version of AGP before own changes. for now you can add this to build.gradle:
android {
sourceSets.getByName("main").res.srcDir(File(buildDir, "generated/moko/androidMain/res"))
}
I had a somehow similar issue. For me, assets were missing in builds; at first I blamed R8 aggressive mode, but it turned out to be this issue. I think it's safer to use this in general, until there's an update:
android {
sourceSets["main"].apply {
assets.srcDir(File(buildDir, "generated/moko/androidMain/assets"))
res.srcDir(File(buildDir, "generated/moko/androidMain/res"))
}
}
Hey @Alex009, is your suggested fix still the way to go or could you investigate the problem further? AGP 7.3.0 is stable now.
It seems like AGP 8.0.0-alpha02 works without this workaround. Perhaps this is just a bug in AGP 7.3/7.4.
@sproctor For me the problem persists with AGP 8.0.0-alpha08.
It may be significant that in my case Moko is applied to an intermediate (hierarchical) source-set.
However the workaround is still effective 👍
will be released in 0.21.0