无法在Android Studio中构建项目

时间:2021-03-15 08:57:08

I am trying to import a project in Android Studio. This code supposedly works but I cannot seem to be able to build the project. This is the error that is produced when I am trying to build:

我正在Android Studio中导入一个项目。这段代码可能有效,但我似乎无法构建这个项目。这是我在尝试构建时产生的错误:

Error:Execution failed for task ':openCVLibrary2410:compileReleaseJava'.

错误:任务':openCVLibrary2410: compiler ereleasejava '执行失败。

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.

无法找到系统Java编译器。确保您安装了JDK(而不仅仅是JRE)并将JAVA_HOME系统变量配置为指向相应目录。

I have searched for a solution, but what I found was was either referring to eclipse or changing the jdk position for

我搜索了一个解决方案,但是我发现要么是指eclipse,要么是改变jdk的位置

File > other Settings > Default Project Structure

Which is not a valid solution for me because I checked my previous Android Studio Projects and all have the same position

哪个方案对我来说不是一个有效的解决方案,因为我检查了之前的Android Studio项目,结果都是一样的

This is the stacktrace:

这是加亮:

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task     ':openCVLibrary2410:compileReleaseJava'.

mainProject Gradle:

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

认脸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

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'
        }
    }
}

2 个解决方案

#1


1  

While I was posting here the gradle files my eye caught something. I changed the build tools version from 'com.android.tools.build:gradle:1.1.0' to 'com.android.tools.build:gradle:2.2.2'and now it is building as it should

当我在这里发布等级文件时,我的眼睛发现了一些东西。我将构建工具的版本从“com.android.tools.build:gradle:1.1.0”改为“com.android.tools.build:gradle:2.2.2”,现在它正在按照它的需要构建。

#2


0  

I had same problem, Here is problem on Java path. You can check you have set path of your java or JDK in system variable or not click Environment variable

我有同样的问题,这是Java路径上的问题。您可以在系统变量中检查您的java或JDK的设置路径,或者不单击环境变量。

Also check your Java JDK version.

还要检查Java JDK版本。

Also this link have all details of How to set path. I suggest to you can use this solution. It will be help to resolve your problem..

这个链接还包含了如何设置路径的所有细节。我建议你可以用这个办法。解决你的问题是有帮助的。

#1


1  

While I was posting here the gradle files my eye caught something. I changed the build tools version from 'com.android.tools.build:gradle:1.1.0' to 'com.android.tools.build:gradle:2.2.2'and now it is building as it should

当我在这里发布等级文件时,我的眼睛发现了一些东西。我将构建工具的版本从“com.android.tools.build:gradle:1.1.0”改为“com.android.tools.build:gradle:2.2.2”,现在它正在按照它的需要构建。

#2


0  

I had same problem, Here is problem on Java path. You can check you have set path of your java or JDK in system variable or not click Environment variable

我有同样的问题,这是Java路径上的问题。您可以在系统变量中检查您的java或JDK的设置路径,或者不单击环境变量。

Also check your Java JDK version.

还要检查Java JDK版本。

Also this link have all details of How to set path. I suggest to you can use this solution. It will be help to resolve your problem..

这个链接还包含了如何设置路径的所有细节。我建议你可以用这个办法。解决你的问题是有帮助的。