开发者社区> 问答> 正文

Gradle构建GroovyAndroid错误?报错

: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'
}
<p>
	<br>
</p>
<p>
	<br>
</p>

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

展开
收起
爱吃鱼的程序员 2020-06-12 15:15:30 725 0
2 条回答
写回答
取消 提交回答
  • 精于基础,广于工具,熟于业务。

    恭喜你已经找到解决办法。

    2020-06-12 17:08:32
    赞同 展开评论 打赏
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    超时?你用代理了吗不是超时,是编译的时候找不到依赖的类LayoutInflaterFactory

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

    配置已加,谢谢

    玩的好潮…体验如何?

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

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

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

    2020-06-15 11:11:13
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载