java - 无法在 Android Studio 中构建项目

标签 java android eclipse 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 项目并且所有项目都具有相同的位置

这是堆栈跟踪:

* 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/

相关文章:

java - 关于KVM(JVM)的问题

java - 在为 HashMap 分配值时使用(对象)

java - 使用 Maven 构建 Soap web 项目

android - 如何让这个三角形指示器在 android jetpack compose 中旋转和移动?

java - 主分片未激活或未分配是已知节点?

Android:上传视频时出现 OutOfMemoryError - 如何最好地分块?

Android键盘弹出字符问题

eclipse - 多模块项目的sonar-eclipse插件分析

java - 如何在运行 java 时修复 "Failed to write core dump. Core dumps have been disabled"错误

eclipse - 当我仅使用Gradle时发生Eclipse Maven错误