0
我试图导入匕首2成在Android Studio中的一个全新的项目,使用较新的匕首2.11 API并具有看看各种指南和文件,我无法使用DaggerAppComponent
无法在Android的
我的摇篮设置如下:
构建(项目)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// 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'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.raywenderlich.todolist"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
//Dagger 2
compile 'com.google.dagger:dagger:2.11'
compile 'com.google.dagger:dagger-android:2.11'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.11'
annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
}
的在我0类:我有这样的:
@Override
public void onCreate() {
super.onCreate();
DaggerAppComponent
.builder()
.application(this)
.build()
.inject(this);
}
但是Android Studio中显示以下错误:
Error:(21, 5) error: cannot find symbol variable DaggerAppComponent
我试图重建项目和导入各种dagger
文件,但似乎没有任何工作。
感谢之前先创建。它解决了我的一些问题,DaggerAppComponent现在正在工作,但是,编译器没有找到该代码的'.application(this)'部分。另一个)错误:无法找到符号方法应用程序(ToDoListApplication) - 我觉得我在这里错过了一些小东西。 – Tander
好的,没关系。我发现了错误。这是我的AppComponent类中缺少的方法。谢谢您的帮助! – Tander
@Tander您应该将此方法添加到您的'ApplicationComponent'中。你是否复制了一些教程的代码? – DeKaNszn