关于Android的最低SDK,我有一个奇怪的问题。 由于某种原因,build.gradle内部的更改不会影响项目的编译
我收到许多方法的以下警告:
defining a default interface method requires --min-sdk-version >= 24 (currently 13)
结果是出现以下错误:
Too many classes in --main-dex-list, main dex capacity exceeded
这真的很烦,因为我已经更改了最低要求。
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>
当我只是为台式机编译时,一切正常。我在这里想念什么?为什么Gradle或JavaFXPorts无法识别这些更改?
如果您需要更多有关我要实现的目标的上下文,可以阅读this。
另外:我正在最新版本上使用Intellij(如果有所作为)
还:我将项目设置配置为使用JDK 9和Android-SDK 28
答案 0 :(得分:0)
我找到了答案here。
您需要像这样使用dex选项:
android {
manifest = <path/to/manifest>
dexOptions {
additionalParameters "--min-sdk-version=24"
}
}