美文网首页
Cannot cast object ‘com.android.

Cannot cast object ‘com.android.

作者: 程序员大耳 | 来源:发表于2021-04-13 16:10 被阅读0次

问题

Project的Build.gradle

buildscript {

    repositories {

        google()

        jcenter()

    }

    dependencies {

        classpath "com.android.tools.build:gradle:4.0.0"

        classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.8'

        // NOTE: Do not place your application dependencies here; they belong

        // in the individual module build.gradle files

    }

}

Module:app的Build.gradle

dependencies {

..........

    apply plugin: 'com.hujiang.android-aspectjx'

    implementation 'org.aspectj:aspectjrt:1.8.+'

}

然后运行时提示报错

Cannot cast object ‘com.android.build.gradle.internal.pipeline.TransformTask$2$1@f074159’ with class ‘com.android.build.gradle.internal.pipeline.TransformTask$2$1’ to class ‘com.android.build.gradle.internal.pipeline.TransformTask’

解决办法

Project的build.gradle中,将build:gradle降级到3.5.2即可。

dependencies {

        classpath "com.android.tools.build:gradle:3.5.2"

        classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.8'

        // NOTE: Do not place your application dependencies here; they belong

        // in the individual module build.gradle files

    }

原因

https://github.com/HujiangTechnology/AspectJX-Demo/blob/master/build.gradle

hujiang对AspectJ的二次封装,暂时最高只支持gradle3.6.1而已。(当然3.6.1我也试了很久也是不行)

相关文章

网友评论

      本文标题:Cannot cast object ‘com.android.

      本文链接:https://www.haomeiwen.com/subject/qwrclltx.html