-
-
Notifications
You must be signed in to change notification settings - Fork 48
(feature-request): Capacitor Build Steps #20
Comments
Hi @danbunkr 😊 The Problem here is that Cordova Plugins in Capacitor are mapped under the capacitor-cordova-android-plugins module and this has no kotlin support yet (i created PR ionic-team/capacitor#4536 to add this support). In this PR you can see the changes that are needed in the module's So i created another PR (that you linked) that adds hook support for Capacitor CLI, so i can make the required changes via a script. I did this and my Appflow Builds now works perfect. Add a script in
the script file: const fs = require("fs");
if (process.env.CAPACITOR_PLATFORM_NAME === 'android') {
let file = fs.readFileSync('./android/capacitor-cordova-android-plugins/build.gradle', 'utf8');
file = file.replace(/apply plugin: 'com.android.library'\n\s*\n/, `apply plugin: 'com.android.library'\r\nif(project.hasProperty('kotlin_version')) {\r\n apply plugin: 'kotlin-android'\r\n}\r\n\r\n`);
file = file.replace(/implementation "org.apache.cordova:framework:\$cordovaAndroidVersion"\n[ ]{4}\/\/ SUB-PROJECT DEPENDENCIES START/,
`implementation "org.apache.cordova:framework:$cordovaAndroidVersion"\r\n if(project.hasProperty('kotlin_version')) {\r\n implementation "androidx.core:core-ktx:+"\r\n implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"\r\n }\r\n // SUB-PROJECT DEPENDENCIES START`);
fs.writeFileSync('./android/capacitor-cordova-android-plugins/build.gradle', file);
} |
@EinfachHans thanks for the reply! I will look into implementing this in our pipeline. We ended up solving it by doing something similar where we have the android build.gradle file that was working locally stored in the project and then after the build pipline runs |
Hey man first just wanted to say thanks for the plugin. After evaluating over 5 different ones this one was the only one that had all the features required for our app. I was able to set it up and get it working but when running through our build pipeline the
npx cap sync
seems to overwrite the Android stuff. I did some digging and found your issues on Capacitor:ionic-team/capacitor#4426
ionic-team/capacitor#4739
I was wondering if you could clarify the steps you added to get this plugin to run in a CI pipeline. Thanks!
The text was updated successfully, but these errors were encountered: