任务执行失败:app:compileDebugJavaWithJavac

时间:2016-01-06 19:07:29

标签: java android gradle android-gradle

我选择了其他人的项目,当我要求AS在我的AVD上运行项目时,它给我一个错误:

  

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

     

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

这是我的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'
}

我不知道该怎么做......其他一切都运行正常,应用程序在几年前首次制作时正在运作。

6 个答案:

答案 0 :(得分:2)

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

multiDexEnabled true

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

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

答案 1 :(得分:1)

检查现有项目的位置地址。如果你使用像:

这样的特殊字符
save

在文件夹和子文件夹名称中,您应该更改它并将其签出。

我将文件夹名称从( / | \ + = * ... ) 更改为"UI/UX"并完成了:)

答案 2 :(得分:0)

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

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

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

答案 3 :(得分:0)

检查您的lib版本。在我的情况下,它是旧的Realm插件,这是一个问题。

答案 4 :(得分:0)

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

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

所以可以这样解决

  1. 构建/清理项目
  2. 构建/制作项目或Build APK

答案 5 :(得分:0)

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

gradlew assembleDebug --stacktrace
相关问题