Gradle构建GroovyAndroid错误

Ellipse 发布于 2015/08/09 00:57
阅读 489
收藏 0
:app:compileDebugGroovy FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugGroovy'.
> Unable to load class android.support.v4.app.Fragment due to missing dependency android/support/v4/view/LayoutInflaterFactory

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 6.063 secs
Unable to load class android.support.v4.app.Fragment due to missing dependency android/support/v4/view/LayoutInflaterFactory


配置文件(root)

// 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.2.3'
        classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.6'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}
app

apply plugin: 'com.android.application'
apply plugin: 'groovyx.grooid.groovy-android'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.misty.xxx.app"
        minSdkVersion 19
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }

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

    lintOptions {
        abortOnError false
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'org.codehaus.groovy:groovy:2.4.4:grooid'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:support-v4:22.2.1'
}



其实后来已经找到解决办法,就是再运行一次build即可。只要clean后build就会报错,再build就正常。可能是GroovyAndroid插件的bug。

加载中
0
jeffsui
jeffsui
超时?你用代理了吗
E
Ellipse
不是超时,是编译的时候找不到依赖的类LayoutInflaterFactory
0
掬一捧
掬一捧

发一下build.gradle文件是如何配置的呗~

E
Ellipse
配置已加,谢谢
0
小红书
小红书

玩的好潮…体验如何?

0
Feng_Yu
Feng_Yu

compile fileTree(dir: 'libs', include: ['*.jar'])

这一行不建议,尽可能走maven,不要把这些jar包扔到项目目录下

E
Ellipse
回复 @Feng_Yu : 我经常在不同电脑上开发,直接把jar连同项目推到git上,方便。你说的这种也用,不过是直接发布到local-repo里,没有搭私服
Feng_Yu
Feng_Yu
回复 @Ellipse : 还可以搭建maven的私服(比如用nexus或者artifactory,都容易实现),把自己的jar包作为工程build结果上传到maven私服中解决。maven写清楚依赖,构建就容易的多,不用自己一个个下载jar包了,也不用在build.gradle写每一个jar包的依赖了
E
Ellipse
了解,这行主要是把自己写的jar放到项目里。其他都走maven的
返回顶部
顶部