0
votes

I've been building an app for months on PhoneGap Build using cli-5.2.0, now due to plugins and Android M permissions I was forced to move to cli-6.1.0 and gradle build.

Suddenly it's not respecting android-minSdkVersion anymore, I usually build 2 APKs, one for sdk 15-19 and another for 21+, but now it ignores the config-file preference and any APK is built for SDK 15+

I think it could be related with gradle build but couldn't find out how to configure the min sdk version for gradle to read, and where to put the gradle config file, I'm using just a text editor and grunt to run the build on phonegap build.

2

2 Answers

3
votes

You could use cordova hooks to copy custom gradle file into the platform.

I set up a pre-build hook script to copy my build-extra.gradle into my android platform.

In my config.xml I added

<platform name="android">
  <hook type="before_build" src="hooks/build-extras-gradle.sh"/>
</platform>

Which is a bash script:

#!/usr/bin/env bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

cd "$DIR/.."

echo '=== Copy Gradle build extras to android'
cp -Rf build-extras.gradle platforms/android

My build-extras.gradle file:

ext.cdvMinSdkVersion = 21
android.lintOptions.abortOnError = false
android.lintOptions.checkReleaseBuilds = false
0
votes

I've just found out that the latest versions of phonegap-plugin-barcodescanner are enforcing sdk version 15+ through its gradle build script.

Rolling back to 4.x versions solved the issue (besides bringing other issues like camera upside down on newer phones, etc, etc).