Cordova/Android: Change Gradle version to 4.4

Hi guys,

So everytime I am building/running my android app (e.g. meteor run android-device) the following happens:

ERROR:

stderr: '\nFAILURE: Build failed with an exception.\n\n* Where:\nBuild file
   \'/Users/patrick/dev/orderlion/orderlion_mobileapp/.meteor/local/cordova-build/platforms/android/CordovaLib/build.gradle\' line: 41\n\n* What
   went wrong:\nA problem occurred evaluating project \':CordovaLib\'.\n> Failed to apply plugin [id \'com.android.library\']\n   > Minimum
   supported Gradle version is 4.4. Current version is 4.1. If using the gradle wrapper, try editing the distributionUrl in
   /Users/patrick/dev/orderlion/orderlion_mobileapp/.meteor/local/cordova-build/gradle/wrapper/gradle-wrapper.properties to gradle-4.4-all.zip\n\n*

So then I have to go into Android Studio and adjust the following in the “Project Structure”:

Is there any way to avoid this and somehow hardcode the Gradle Version into meteor or my build script? This pretty annoying as I have to do this every single time!

Cheers, Patrick

Unless there is something specifically you need in the later Android SDK, I’d recommend you use an SDK version that corresponds to when Gradle was 4.1 anyway. This is a symptom of trying to mix new, untested stuff with old tested stuff, so it’s not going to be your only problem.

That’s not working unfortunately. I tried that and you can’t even release an Android App with a gradle Version below 4.4. Also, just trying to run meteor run android-device is also not possible because of several errors if you are on gradle 4.1. So I need 4.4 in any case. it also works like a charm, I just would like to avoid the manual step I have to do in Android Studio every single time. :slight_smile:

Man that sucks :slight_smile:

I guess you can fork meteor and fix it hackily, or just search their code base for 4.1 and make that patch yourself. I’m sure the gradle file is being picked up from some old version of Cordova.

I am not sure if this helps you. I am successful in both using android-device and android on my Mac.

On my Mac I have the following:-
Gradle version 4.6
Meteor version 1.8.1
Android Studio - 3.4
SDK - 26,27,28 ( 26 for older version of meteor)

And it works like a charm. The device I am using is Redmi Y1. Here the device can be tricky, sometimes it is not recognised unless one sets developer options correctly.

Thanks for your replies guys!

The gradle version itself isn’t the problem, that problem is that everytime I build my app I have to manually switch back to gradle version 4.4 (or even 4.6 for that matter) because meteor by default sets gradle version 4.1.
I could maybe really fork meteor, replace all the occurences of the gradle version with the newer one and make a PR, we will see.