Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android fails to compile with AGP 7.3.0-beta03 #353

Closed
headsvk opened this issue Jun 20, 2022 · 7 comments · Fixed by #439
Closed

Android fails to compile with AGP 7.3.0-beta03 #353

headsvk opened this issue Jun 20, 2022 · 7 comments · Fixed by #439
Assignees
Labels
bug Something isn't working
Milestone

Comments

@headsvk
Copy link

headsvk commented Jun 20, 2022

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:

  1. Install Android Studio Dolphin Beta 3
  2. Update Android Gradle Plugin in this project to 7.3.0-beta03 as in this fork
  3. 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
@Alex009 Alex009 added the bug Something isn't working label Jun 23, 2022
@headsvk
Copy link
Author

headsvk commented Jun 23, 2022

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.

@Alex009
Copy link
Member

Alex009 commented Jul 10, 2022

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"))
}

@YektaDev
Copy link

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"))
    }
}

@ln-12
Copy link

ln-12 commented Sep 26, 2022

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.

@sproctor
Copy link

sproctor commented Oct 6, 2022

It seems like AGP 8.0.0-alpha02 works without this workaround. Perhaps this is just a bug in AGP 7.3/7.4.

@chris-hatton
Copy link

chris-hatton commented Nov 21, 2022

@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 👍

@Alex009 Alex009 added this to the 0.20.2 milestone Dec 8, 2022
Alex009 added a commit that referenced this issue Dec 8, 2022
Alex009 added a commit that referenced this issue Dec 8, 2022
@Alex009 Alex009 modified the milestones: 0.21.0, 0.21.1 Mar 3, 2023
@Alex009 Alex009 modified the milestones: 0.21.1, 0.21.0 Mar 12, 2023
@Alex009
Copy link
Member

Alex009 commented Mar 24, 2023

will be released in 0.21.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
6 participants