任务执行失败 :app:compileDebugJavaWithJavac

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34640804/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 15:52:12  来源:igfitidea点击:

Execution failed for task :app:compileDebugJavaWithJavac

javaandroidgradleandroid-gradle-plugin

提问by dequec64

I picked up someone else's project and when I asked AS to run the project on my AVD, it pops me an error:

我拿起了别人的项目,当我要求 AS 在我的 AVD 上运行该项目时,它弹出一个错误:

Error:Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

错误:任务 ':app:compileDebugJavaWithJavac' 的执行失败。

编译失败;有关详细信息,请参阅编译器错误输出。

Here is my build.gradle

这是我的 build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    defaultConfig {
        applicationId 'ca.gggolf.aminutegolf'
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
}

I don't know what to do.. Everything else works fine and the app was working a couple of years ago when it was first made.

我不知道该怎么办.. 其他一切都很好,应用程序在几年前第一次制作时就可以运行了。

回答by dequec64

I'm back at this question simply because it got many views.

我回到这个问题只是因为它有很多观点。

First, thanks all for the help. I managed to run the app by creating a new project on Android Studio and importing classes one at a time while making sure the code was still fine. Maybe creating a new project added some parameters that were not present in the older version of the project.

首先感谢大家的帮助。我设法通过在 Android Studio 上创建一个新项目并一次导入一个类来运行该应用程序,同时确保代码仍然正常。也许创建一个新项目添加了一些旧版本项目中不存在的参数。

If someone has a better explanation, feel free to answer!

如果有人有更好的解释,请随时回答!

回答by Sanjeet

Enable multidex for your project. Add below line to gradle defaultConfig:

为您的项目启用 multidex。将以下行添加到 gradle defaultConfig:

multiDexEnabled true

Also add multidex dependency to gradle's dependencies :

还要向 gradle 的依赖项添加 multidex 依赖项:

compile 'com.android.support:multidex:1.0.1'

回答by RMK

Check your lib versions. In my case it was old Realm plugin that was an issue.

检查您的 lib 版本。就我而言,这是一个旧的 Realm 插件。

回答by Hessam Rastegari

Check your location address of exist project. if you use special character like :

检查现有项目的位置地址。如果您使用特殊字符,如:

( / | \ + = * ... )

In folder and sub-folders name, you should change it and check it out.

在文件夹和子文件夹名称中,您应该更改它并检查它。

I changed my folder name from "UI/UX"to "UiUx"and its done :)

我将文件夹名称从 更改"UI/UX""UiUx"并完成:)

回答by user25

Sometimes this error happens to me. I don't have any java compiler errors.

有时这个错误发生在我身上。我没有任何 Java 编译器错误。

And seems this issue related to the build cache of a project.

这个问题似乎与项目的构建缓存有关。

So it can be solved like this

所以可以这样解决

  1. Build/Clean Project
  2. Build/Make Project or Build APK
  1. 构建/清理项目
  2. 构建/制作项目或构建 APK

回答by rajesh jonnagaddala

Build with below command, this command will point the exact point in source code where the compilation error is getting generated.

使用以下命令构建,此命令将指向源代码中生成编译错误的确切点。

gradlew assembleDebug --stacktrace