androidbuild.gradlejavafxports

Changing minSdkVersion in JavaFXPorts doesn't work


I have a weird problem regarding the aplied minimum sdk for Android. For some reason the changes inside the build.gradle won't affect the compilation of the project

I get the following warnings for a lot of methods:

defining a default interface method requires --min-sdk-version >= 24 (currently 13)

As a result I get the following Error:

Too many classes in --main-dex-list, main dex capacity exceeded

Which is really annoying, because I already changed the minimum requirements.

build.gradle:

buildscript {
    repositories {
        jcenter()
        google()
        maven {
            url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
        }
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:2.0.8'
    }
}

apply plugin: 'scala'
apply plugin: 'org.javafxports.jfxmobile'

configurations {
    scalaCompiler
}
configurations.scalaCompiler.transitive = false

compileScala.targetCompatibility = "1.8"

mainClassName = 'sfxml.Main'

repositories {
    mavenCentral()
    jcenter()
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
}

dependencies {
    compile('org.scala-lang:scala-library:2.12.6'){transitive = false}
    compile(group: 'org.scalafx', name: 'scalafx_2.12', version: '8.0.144-R12'){transitive = false}
    compile group: 'org.scalafx', name: 'scalafxml-core-sfx8_2.12', version: '0.4'

    scalaCompiler "org.scalamacros:paradise_2.12.6:2.1.1"

//    testCompile group: 'junit', name: 'junit', version: '4.12'
}

String scalaCompilerOptions="-Xplugin:$configurations.scalaCompiler.singleFile.path"
compileScala.scalaCompileOptions.additionalParameters = [scalaCompilerOptions]
compileTestScala.scalaCompileOptions.additionalParameters = [scalaCompilerOptions]



jfxmobile {
    android {
        manifest = 'src/android/AndroidManifest.xml'
        minSdkVersion '28'
        compileSdkVersion '28'
        buildToolsVersion '28.0.0'
        dexOptions {
            javaMaxHeapSize '3g'
        }
    }
}

Manifest.xml:

<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="sfxml" android:versionCode="1" android:versionName="1.0">
        <supports-screens android:xlargeScreens="true"/>
        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
        <uses-sdk android:minSdkVersion="28" android:targetSdkVersion="28"/>
        <application android:label="Test2" android:name="android.support.multidex.MultiDexApplication">
                <activity android:name="javafxports.android.FXActivity" android:label="Test2" android:configChanges="orientation|screenSize">
                        <meta-data android:name="main.class" android:value="sfxml.Main"/>
                        <meta-data android:name="debug.port" android:value="0"/>
                        <intent-filter>
                                <action android:name="android.intent.action.MAIN"/>
                                <category android:name="android.intent.category.LAUNCHER"/>
                        </intent-filter>
                </activity>
        </application>
</manifest>

Everything works out fine, when I am just compiling for desktop. What am I missing here? Why does Gradle or JavaFXPorts not recognize these changes?

If you need a little bit more context as to what I am trying to achieve, you can read this.

Also: I am using Intellij on the newest release (if that makes a difference)

Also Also: I configured the project settings to use JDK 9 and Android-SDK 28


Solution

  • I found the Answer here.

    You need to use the dex options like so:

    android {
            manifest = <path/to/manifest>
            dexOptions {
                additionalParameters "--min-sdk-version=24"
            }
    }