-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Configure the need of kotlin-android-extensions
plugin to support Kotlin 1.9
#1642
Comments
According to https://android-developers.googleblog.com/2022/02/discontinuing-kotlin-synthetics-for-views.html this Gradle plugin is no longer required, and will actually prevent using newer Kotlin versions to build Android applications. This is also reflected in apache#1642, so staying one step ahead, this plugin has been effectively removed. References https://outsystemsrd.atlassian.net/browse/RNMT-6192
Do you know if I'd rather not add in a new preference and instead just remove Edit: Found the relevant blog post: https://android-developers.googleblog.com/2020/11/the-future-of-kotlin-android-extensions.html It does appear to be obsolete moving forward. |
The first time Google released the intention to remove the Starting from Kotlin 1.7 the build process was generating a warning that this plugin is deprecated. And in the version Kotlin 1.9 the issue got stricter and now the build process fails with an error. I believe it would be safe to remove the plugin from the template of the upcoming major version of Cordova. |
If anyone else runs into this when moving to Kotlin 1.9+; Add a cordova hook of Regardless, I am now able to run with kotlin 1.9.22 just fine. |
Following @bkohler616's suggestion, for anyone interested, here's an rough draft script to remove #!/usr/bin/env node
'use strict';
const fs = require('fs');
const path = require('path');
const plugins = ['kotlin-android-extensions'];
module.exports = function () {
const file = path.join('platforms', 'android', 'app', 'build.gradle');
if (fs.existsSync(file)) {
let newFile = fs.readFileSync(file).toString();
console.log('Removing lines from build.gradle... ');
newFile = removeRegExp(newFile, plugins, applyPluginRegExp);
fs.writeFileSync(file, newFile);
} else {
throw `Couldn't find file: ${file}`;
}
};
function removeRegExp(file, items, regExp) {
const lines = [];
for (const item of items) {
lines.push(...Array.from(file.matchAll(regExp(item))));
}
if (lines.length > 0) {
lines.sort((a, b) => b.index - a.index);
for (const line of lines) {
console.log(`Removing line from build.gradle: ${line[0].trim()}`);
file = file.slice(0, line.index) + file.slice(line.index + line[0].length);
}
}
return file;
}
function applyPluginRegExp(plugin) {
return new RegExp("\\s*?apply plugin: '" + plugin + "'.*?", 'gm');
} You can add it as a |
When updating to the latest Firebase SDK versions, these require you to use Kotlin 1.9. After I added the
It seems that adding |
According to https://android-developers.googleblog.com/2022/02/discontinuing-kotlin-synthetics-for-views.html this Gradle plugin is no longer required, and will actually prevent using newer Kotlin versions to build Android applications. This is also reflected in apache#1642, so staying one step ahead, this plugin has been effectively removed. References https://outsystemsrd.atlassian.net/browse/RNMT-6192
Feature Request
Kotlin 1.9 does not make use of
kotlin-android-extesions
plugin which is still being generated by the latest cordova-android 12.0.0 version and thus android app build fails.It would be nice to add another preference apart of
{ xmlKey: 'GradlePluginKotlinEnabled', gradleKey: 'IS_GRADLE_PLUGIN_KOTLIN_ENABLED', type: Boolean }
to be able to configure the need ofkotlin-android-extensions
plugin for the android appMotivation Behind Feature
Kotlin 1.9 does not work out of the box with the latest Cordova 12.0.0 framework. It requires manual interference to remove the line
apply plugin 'kotlin-android-extensions'
from the /platforms/android/app/build.gradle file.Feature Description
Add new xml key and preference { xmlKey: 'GradlePluginKotlinExtEnabled', gradleKey: 'IS_GRADLE_PLUGIN_KOTLIN_EXT_ENABLED', type: Boolean } and apply the
kotlin-android-extesions
plugin only in case the property is set to true.The text was updated successfully, but these errors were encountered: