我的项目是由 gradle 构建的,结构为 android
, core
, desktop
模块。在哪里 android
是一个 Android 模块,但两者都是 core
和 desktop
模块是java模块。 core
是两个 android
的依赖项和 desktop
.当我写(在 desktop
中):
Queue<P> qeueue= new ArrayDeque<P>();
想法提示:
Cast from ArrayDeque to Queue requires API level 9 (current min is 1)
我怎样才能避免这种提示?禁用对整个项目的检查似乎不对。我也不想转换
desktop
成为一个Android模块。项目的 build.gradle:
buildscript {
repositories {
// repositories
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
allprojects {
apply plugin: "idea"
version = '1.0'
ext {
appName = 'my-app-name'
}
repositories {
// repositories
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
// some dependencies here
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
// some other dependencies here
}
}
project(":core") {
apply plugin: "java"
dependencies {
// some dependencies here
}
}
Core 的 build.gradle:
apply plugin: "java"
sourceCompatibility = 1.6
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = ["src/", "postprocessing/", "gl/", "math/", "experiment/"]
dependencies {
}
桌面的 build.gradle:
apply plugin: "java"
sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = ["src/", "experiment/", "resources/"]
project.ext.mainClassName = "cz.plajt.wallp.hills.desktop.DesktopLauncher"
project.ext.assetsDir = new File("../android/assets");
task run(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
}
task dist(type: Jar) {
from files(sourceSets.main.output.classesDir)
from files(sourceSets.main.output.resourcesDir)
from { configurations.compile.collect { zipTree(it) } }
from files(project.assetsDir);
manifest {
attributes 'Main-Class': project.mainClassName
}
}
dist.dependsOn classes
dependencies {
}
最佳答案
这是 IntelliJ 的一个已知问题,我也面临同样的问题。我什至无法让项目在 IntelliJ 中编译。
https://youtrack.jetbrains.com/issue/IDEA-122904
似乎没有解决方法。
关于android - Intellij Idea 2016.3 提示非 Android 模块中的 Android API 级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41919003/