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

The strings placeholder resolver can only be applied to projects of type 'com.android.application' #99

Open
StephenChow-beep opened this issue Jul 9, 2024 · 3 comments

Comments

@StephenChow-beep
Copy link

1
I have added it to the app module, and this error appears after clicking sync.

@StephenChow-beep StephenChow-beep changed the title Failed to add plugin The strings placeholder resolver can only be applied to projects of type 'com.android.application' Jul 9, 2024
@LikeTheSalad
Copy link
Owner

Hi @StephenChow-beep

Thank you for your feedback. I've just tried it out but couldn't reproduce the issue. I'm usind AGP version: 8.5.1. The only reasons I could think of that might cause this issue would be:

  • There might be an apply plugin: somewhere to add Stem using the "legacy" apply method mechanism.
  • There might be a specific AGP version that causes this issue.

So as a follow-up I'd like to confirm if the "legacy" apply method is not happening in your project, and also I'd like to check what's the AGP version that you're using.

@5peak2me
Copy link
Contributor

5peak2me commented Dec 31, 2024

I think the fault with @StephenChow-beep is that it also uses id("com.likethesalad.stem") version "2.9.0" in the build.gradle file in the root directory. This error is because when we define the plugin in the build.gradle file in the root directory, we don't apply android plugin immediately, like id("com.android.application") version "8.1.0" apply false. At this time, when the plugin is loaded, it will be verified and failed, and the specific code is implemented inBaseTemplatesProcessorPlugin.kt#L36

@5peak2me
Copy link
Contributor

There are two ways to fix this:

  1. Remove the plugin definition from the root directory and add id("com.likethesalad.stem") version "2.9.0" directly under the app module.
// build.gradle(.kts) in root project

plugins {
  ··· emit ···

  id("com.likethesalad.stem") version "2.9.0" // remove this
}
  1. In the traditional way, in the build.gradle directory of the root directory, use apply false, and then remove the version of the plugin under the app module and use it only id("com.likethesalad.stem")
// build.gradle(.kts) in root project

plugins {
  ··· emit ···

  id("com.likethesalad.stem") version "2.9.0" apply false // add `apply false`
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants