
每次我尝试构建项目时,都会发生以下错误:
Error:Execution Failed for task ':app:compileDeBUGJavaWithJavac'.> @R_301_4126@.NoSuchMethodError: com.Google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V遵循负责依赖项注入的类:
应用模块
@Modulepublic class ApplicationModule { private static final String APP_ID = "ID"; private static final String APP_SECRET = "secret"; private final Application mApplication; public ApplicationModule(Application application) { mApplication = application; } @ProvIDes Application provIDeApplication() { return mApplication; } @ProvIDes @Singleton ClIEnt provIDeClIEnt(Application application) { return new ClIEnt.Builder(APP_ID, APP_SECRET, application).build(); }}应用组件
@Singleton@Component(modules = ApplicationModule.class)public interface ApplicationComponent { voID inject(MainApplication application); Application getApplication(); ClIEnt getClIEnt();}主要应用
public class MainApplication extends androID.app.Application { private ApplicationComponent component; @Inject ClIEnt clIEnt; @OverrIDe public voID onCreate() { super.onCreate(); ... component = DaggerApplicationComponent.builder() .applicationModule(new ApplicationModule(this)) .build(); component.inject(this); } public ApplicationComponent getComponent() { return component; }}和我的gradle.build(Module:app)
buildscript { repositorIEs { jcenter() maven { url 'http://dl.bintray.com/amulyakhare/maven' } } dependencIEs { classpath 'me.tatarka:gradle-retrolambda:3.2.5' }}apply plugin: 'com.androID.application'apply plugin: 'me.tatarka.retrolambda'androID { compileSdkVersion 25 buildToolsversion "25.0.2" defaultConfig { applicationID "br.mobi.santor.agora" minSdkVersion 15 targetSdkVersion 25 versionCode 1 versionname "1.0" } buildTypes { release { MinifyEnabled false proguardfiles getDefaultProguardfile('proguard-androID.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }}repositorIEs { flatDir { dirs 'libs' }}final SUPPORT_liBRARY_VERSION = '25.1.0'final DAGGER_VERSION = '2.8'dependencIEs { compile filetree(dir: 'libs', include: ['*.jar']) compile(name: 'kinvey-androID-2.10.6', ext: 'aar') // AppCompat dependencIEs compile "com.androID.support:appcompat-v7:$SUPPORT_liBRARY_VERSION" compile "com.androID.support:cardvIEw-v7:$SUPPORT_liBRARY_VERSION" compile "com.androID.support:recyclervIEw-v7:$SUPPORT_liBRARY_VERSION" compile "com.androID.support:design:$SUPPORT_liBRARY_VERSION" // Dagger dependencIEs compile "com.Google.dagger:dagger:$DAGGER_VERSION" annotationProcessor "com.Google.dagger:dagger-compiler:$DAGGER_VERSION" // Network dependencIEs compile 'com.squareup.picasso:picasso:2.5.2' // Utils dependencIEs compile 'uk.co.chrisjenx:calligraphy:2.2.0' compile 'joda-time:joda-time:2.9.7' testCompile 'junit:junit:4.12'}解决方法:
NoSuchMethodError几乎可以肯定意味着您在类路径上具有比用于编译的旧版本的Guava.确保您具有最新版本的Guava(几乎总是可以安全地使用给定的these compatibility guarnatees),并且它应该可以工作.
总结以上是内存溢出为你收集整理的Android-Dagger 2不生成组件全部内容,希望文章能够帮你解决Android-Dagger 2不生成组件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)