Set Minium SDK/Target Android Versions

Another Mobile Feature Request!

The ability within the Project to set:

    minSdkVersion **
    targetSdkVersion **

Within the Mobile Project Settings, and commit to the build.gradle files for Cordova (there are multiple). I ask because if these are not set correctly, and there is a mistake in the current build.gradle:

What it should look like (after setting in Android Studio):

Exists by default (can’t set in Android Studio due to the incorrect formatting):

The above are two different Projects! First image is working and is edited in Android Studio for its configuration (builds in Wappler and Android Studio), the second is the default Wappler configuration (although it builds in Wappler it throws errors in Android Studio).

Then being able to set these in Wappler would resolve the issue, then opening within Android Studio would be a breeze, right now you have to hunt down the incorrect lines and replace them manually, not sure if this is Wappler (maybe its just a Linux thing as can’t remember having this issue on Windows) or something else which produces this problem, but having the ability to set them in the Wappler Project itself would be very useful, then only a simple configuration for Android Studio would be required…

I’m working my way through figuring out why things are duplicated left, right, and center in Mobile Projects, there are multiple versions of build.gradle and manifests created, and figuring out which actually have an impact on builds is taking me some time, but shall document it soon as have figured it out.

For now it would be great to be able to set the Android versions within the Project settings.

Thank you for the considerations. When I know what is going on with the file differences, and errors, and locate them all, will submit a Bug Report.

Please vote!

:slight_smile:

We don’t really control the gradle files - it is all Cordova generating and managing them. Is it not something you can control with Cordova?

Or is maybe Capacitor better in handling this? https://capacitorjs.com/

They are already in version 3 which looks really good as much better alternative to Cordova.

Yes, in the config.xml

<platform name="android">
    <preference name="android-targetSdkVersion" value="30"/>  
    <preference name="android-minSdkVersion" value="24"/>  
</platform>
1 Like

Thanks for the rapid response @George

I’m not familiar with Capacitor although have looked at it briefly, but to be honest could be opening a whole new can of worms with regards to new problems and configuration issues, and shifting the issue? Currently there is little purpose in having the Open in Android Studio button as you can’t do anything such as Build, for example, using Android Studio for signing purposes and submission, etc. Somewhere in the mix some mis-configuration takes place which denies this ability.

Will look in to Capacitor and maybe give it a go.

An error will still be thrown at build.gradle within Android Studio, although thanks for the input Ken, have already tried that though!

Strange, I faced the exact issue, and this solved it. Perhaps I did something elsewhere, but I don’t believe so.

There is definitely something strange happening, as I said maybe its just the Linux side…? What OS are you using Ken? I remember some configurations in Windows having to be made, but either something has changed in recent versions of either Cordova or Wappler, and pinpointing them is quite time consuming.

I now have a base Project which I copy from my Git Repo and base my Mobile Projects on, one that works both in Windows and Linux. Saves me a whole lot of time this way.

As I mentioned building in Wappler is not an issue with a base Project with the standard options for Mobile Projects. We use Android Studio for submissions and certificate management so having it build there is quite important. May I ask have you tried to build in Android Studio?

Mac.

You might try adding that preference, then removing the platform and re-adding (although that presents its own issues!)

If you remove the Platform a whole new configuration is required taking us back to step one with the configuration issues outlined above (whereby can not build in Android Studio). Evil circle.

I build in Wappler while testing, then in Android studio I generate the bundle to load into Google play store.

If you have a few minutes spare create a new Mobile Project, then try to build in A-S… See what happens Mac sides… Would be interesting to know?

Agreed...too often for both iOS and Android the fix reported includes removing the platform, which takes you back to square one in several places.

1 Like

Hence the Git Repo now, saving all that shiznit! :slight_smile:

This should work in Cordova Android 10+ they fixed it some months ago:

Maybe you need to update or remove/add the android platform to activate it, Dave

Done this @George and as mentioned to Ken above you just go back to step one. Thank you for the input though, same for Ken, really appreciated to have a discussion and alternative opinions on the subject.

Both Android versions and Cordova versions are up to date on all our Projects, as a side note. Also not targeting version 30 if you take a look at build.gradle (to avoid the issue you shared).

I must EMPHASISE! Building in Wappler (4.4.3) works perfectly with the defaults! For the benefit of other Users reading, following, this Topic, so don’t let it put you off please! It is an Android Studio/Cordova issue, and am very privileged here within this Community to get offered support (for a problem outside of Wapplers remit) by both Users and Team members!

:wink:

Thanks anyway Gentleman. Will continue to play-around see if I can find a simple work-around that can be explained to other Users (if they wish to use Android Studio for submissions and certificates).

1 Like

If the Cordova xml options for the sdk version work, we can add them in the project options.

1 Like

Unfortunately this is not the solution @George

Created a new Mobile Project and built succesfully within Wappler itself. Opened in Android Studio and received the same error as the original post:

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> compileSdkVersion is not specified. Please add it to build.gradle

Back to the drawing board, worth a shot though!