-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Unable to load class 'com.android.build.gradle.AppExtension'.
#12
Comments
So, using |
Hi @davwheat - I see, your gradle setup seems to be the newest one which might not be too popular yet in android projects, which is why I didn't include it for now in the docs. I think the way you've set it up is right, but the only thing that seems a bit off for me is that you seem to be applying the plugin "placeholder-resolver" into your
Please let me know if that helps you. |
I've tried both of those, but they each result in the same error (attached below). For now, I'm commenting out the plugin application in my app module Suuuper long error trace
|
Hi @davwheat - sorry to hear it. I was taking a look at it myself right now and it looks like this plugin does work with the latest, unstable android build plugin version Anyway this is how I managed to make it work based on your example: settings.gradle pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
plugins {
id 'org.jetbrains.kotlin.android' version '1.5.30'
}
}
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.1.0-alpha11"
classpath "com.likethesalad.android:string-reference:1.2.2"
}
} And the build.gradle file for the app module remains the same, no changes needed there. In the settings.gradle file I just moved the android build plugin declaration over to the buildscript.dependencies block and that's it. Tbh I think it's better to have it there, as you wouldn't have to explicitly define its sub-plugins (com.android.application and com.android.library) separated, plus having to repeat the versions too. Thanks for letting me know about this issue though, I'll be taking a deeper look for the next release in order to understand why this very subtle change makes so much difference in the way Gradle resolves its plugins. It kinda seems like a bug, but I'll investigate more. Cheers! |
I think I've configured it how you suggested. I am new to Android development and using the newest syntax where there is little documentation for it online wasn't the smartest idea! 😅 I'm getting no errors, but the string replacement isn't actually happening. Just to check, is this how you meant? settings.gradle pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
plugins {
id('com.android.application') version('7.1.0-alpha11')
id('com.android.library') version('7.1.0-alpha11')
id('org.jetbrains.kotlin.android') version('1.5.30')
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30"
classpath "com.android.tools.build:gradle:7.1.0-alpha11"
classpath "com.likethesalad.android:string-reference:1.2.2"
}
} build.gradle (app) plugins {
id('com.android.application')
id('org.jetbrains.kotlin.android')
id('kotlin-parcelize')
id('placeholder-resolver')
}
// ... build.gradle (project) // Basically empty
task clean(type: Delete) {
delete rootProject.buildDir
} |
Hi @davwheat - I see, no worries. In terms of your gradle files, I think it's all right 👍 so I don't think the issue is caused by any gradle script - The only thing I'd change, just for cleaning up purposes, would be that I'd delete these 2 lines from the id('com.android.application') version('7.1.0-alpha11')
id('com.android.library') version('7.1.0-alpha11') Because they are no longer needed since you are adding the android build plugin classpath below inside the "buildscript.dependencies" block. There's no harm in keeping them tho, it's just that since they are no longer needed, it might be better for code visibility to remove them. Aside from that, I need to check a couple of things:
So please keep in mind that, the string generation happens when you build your app, and also your templates names' must start with "template_". |
Ahh, I had removed the Thank you so much for your troubleshooting work, and for this fantastic plugin! :) I just noticed that if my template is wrapped in quotes, the build process fails, but that's a separate issue which can be worked around by just using escape sequences. |
Hi @davwheat - I'm glad to know it's working now! In regards to the quotes, I remember adding some validations around double quotes, are those the ones you're using? |
Yes, it was double quotes. It was a bit like this:
I've closed this issue as it's solved now, but if you have any suggestions about the quoted strings, that'd be amazing! |
Oh! I see, yeah it seems like a case that could have issues, thanks for your feedback, I'll address this in the next release 👍 In the meantime, just to have a reference when I'm working on the patch, please can you provide me the exact example of how do you have your strings set up? - It doesn't have to be the actual strings but at least to have the same quotes in the same places for reference. For example, is this the way you have them set up? <string name="dummy_text">"Some text"</string>
<string name="template_other_dummy_text">"I can't say ${dummy_text}"</string> Or is it like: <string name="dummy_text">\"Some text\"</string>
<string name="template_other_dummy_text">"I can't say ${dummy_text}"</string> |
Hey, I'm trying to use the plugin with Kotlin's Gradle.
The setup instructions seem to be aimed at Java Gradle instead, so I've tried my best:
settings.gradle
build.gradle (app module)
The text was updated successfully, but these errors were encountered: