java无法在Android Studio中构建项目
我正试图在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项目,所有项目都有相同的位置
这是stacktrace:
* 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.安卓.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
FaceRecognition Gradle
apply plugin: 'com.安卓.application'
安卓 {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "eu.upcom.recred.facerec"
minSdkVersion 9
targetSdkVersion 9
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-安卓.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile files('libs/javacpp.jar')
compile files('libs/javacv.jar')
compile project(':openCVLibrary2410')
}
openCV2410 gradle
apply plugin: 'com.安卓.library'
安卓 {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 8
targetSdkVersion 8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-安卓.txt'), 'proguard-rules.txt'
}
}
}
# 1 楼答案
当我在这里发布gradle文件时,我的眼睛看到了一些东西。我将构建工具版本从
'com.android.tools.build:gradle:1.1.0'
更改为'com.android.tools.build:gradle:2.2.2'
,现在它正在按它应该的方式构建# 2 楼答案
我也有同样的问题,这里是Java路径上的问题。您可以检查是否在系统变量中设置了java或JDK的路径,或者是否单击Environment variable
还要检查Java JDK版本
此外,此链接还提供了有关如何设置路径的所有详细信息。 我建议你可以使用这个解决方案。这将有助于解决你的问题