我正在尝试在 Android Studio 中导入一个项目。这段代码应该有效,但我似乎无法构建该项目。这是我尝试构建时产生的错误:
Error:Execution failed for task ':openCVLibrary2410:compileReleaseJava'.
Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory.
我已经搜索了一个解决方案,但我找到的是指的是 eclipse 或更改 jdk 的位置
File > other Settings > Default Project Structure
这对我来说不是一个有效的解决方案,因为我检查了我以前的 Android Studio 项目并且所有项目都具有相同的位置
这是堆栈跟踪:
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':openCVLibrary2410:compileReleaseJava'.
mainProject Gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
FaceRecognition Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "eu.upcom.recred.facerec"
minSdkVersion 9
targetSdkVersion 9
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile files('libs/javacpp.jar')
compile files('libs/javacv.jar')
compile project(':openCVLibrary2410')
}
openCV2410 gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 8
targetSdkVersion 8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
最佳答案
当我在这里发布 gradle 文件时,我注意到了一些东西。我将构建工具版本从 'com.android.tools.build:gradle:1.1.0'
更改为 'com.android.tools.build:gradle:2.2.2'
现在它正在按预期构建
关于java - 无法在 Android Studio 中构建项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40861525/