找不到方法apt()

编程入门 行业动态 更新时间:2024-10-27 22:28:56
本文介绍了找不到方法apt()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用Dagger2,我正在使用Android Studio 2.2.2 但是我在gradle中有一个错误:

I'm trying to work with Dagger2, I am using Android studio 2.2.2 but I have an error with gradle:

Error:(34, 0) Could not find method apt() for arguments [com.google.dagger:dagger-compiler:2.6] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. <a href="openFile:C:\Users\edi.bershatsky\Google Drive\Android\eWave\MyCode\MyDagger2\app\build.gradle">Open File</a>

请帮助我了解我的gradle怎么了

please help me to understand what is wrong with my gradle

这是我的项目gradle:

this is my project gradle:

// 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:2.2.2' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { mavenCentral() maven{ url 'oss.sonatype/content/repositories/snapshots/' } } } task clean(type: Delete) { delete rootProject.buildDir }

这是我的模块gradle:

this is my module gradle:

apply plugin: 'com.android.application' android { compileSdkVersion 25 buildToolsVersion "25.0.2" defaultConfig { applicationId "com.edi.mydagger2" minSdkVersion 15 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } ext { JUNIT_VERSION = '4.12' DAGGER_VERSION ='2.4' } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:25.1.1' compile 'com.google.dagger:dagger:2.6' apt 'com.google.dagger:dagger-compiler:2.6' }

推荐答案

添加

compile 'com.google.dagger:dagger:2.6' annotationProcessor "com.google.dagger:dagger-compiler:2.6"

内部依赖项

注意:

随着android gradle插件2.2.0版本的发布,注释处理不再需要android-apt插件. apt函数包含在最新的android gradle插件中,该插件称为注解处理器.

With android gradle plugin 2.2.0 release, the android-apt plugin is no longer needed for annotation processing. The apt function was included in the latest android gradle plugin which called annotationProcessor.

更多推荐

找不到方法apt()

本文发布于:2023-11-14 05:02:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1586292.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   方法   apt

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!