Closed bananaCaptain closed 7 years ago
@bananaCaptain This example works correctly I just checked, Did you try to rebuild the project? You have to go Build -> Rebuild project. Remember that these classes are generated at compile-time.
@erikcaffrey I am just trying to move the CategoryActivityComponent to another package which does not with the CateoryActivity. And then this error come out . I think you should change this line https://github.com/erikcaffrey/Dagger2-MVP-Sample/blob/master/app/build.gradle#L38 to "apt 'com.google.dagger:dagger-compiler:2.0'" to suport while those two file doesn't in same package
@IdioticMadman the library would not have to be a problem maybe you can try rebuild project, you don't need to create or move another component is just a simple example also there are no many dependencies that must be separated and remember maintain the things simples.
Yeah, That's OK.Thanks
@erikcaffrey , thanks rebuild is solution.
@dilip90 @IdioticMadman @bananaCaptain https://erikcaffrey.github.io/ANDROID-kata-dagger2/
Hello, clean and rebuild is not a solution for me, and the error stays there.
This is my error log:
Error:(8, 47) error: cannot find symbol variable DaggerAppComponent Error:Execution failed for task ':app:compileDebugJavaWithJavac'. Compilation failed; see the compiler error output for details.
Can anyone suggest me an alternative or a workaround for this?
@aneeshATgithub
The class DaggerAppComponent
is a generated class on compile time. Try invalidate caches an restart, and rebuild. if it doesn't works maybe your problem is about version of sdk btw I updated the project to the last version of support library and is working https://github.com/erikcaffrey/Dagger2-MVP-Sample/pull/6
I also have another sample to learn Dagger 2 -> https://github.com/erikcaffrey/Kata-Dagger2-MarioKart
I had tried invalidate caches an restart, also clean and rebuild. Finally I updated buildToolsVersion to "26.0.2". But the error not gone.
Ctrl+F9
I had to clean the project and after that I get this error from Studio, even though the files are present. Tried to Invalidate / Restart, Clean, Rebuild.. still get the error from studio.
What's error?
On Tue, Feb 20, 2018 at 6:58 AM, marconealberto notifications@github.com wrote:
I had to clean the project and after that I get this error from Studio, even though the files are present. Tried to Invalidate / Restart, Clean, Rebuild.. still get the error from studio.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/erikcaffrey/Dagger2-MVP-Sample/issues/1#issuecomment-367003739, or mute the thread https://github.com/notifications/unsubscribe-auth/AbZG7u3O8QysBxH46mWuA6oH4nwAnAxVks5tWt15gaJpZM4IBtEs .
error: cannot find symbol
import com.mypackage.DaggerAppComponent;
I went through most of the answer on stackoverflow but it looks I broke it.
compile 'com.google.dagger:dagger:2.8' annotationProcessor 'com.google.dagger:dagger-compiler:2.8'
i will already used this gradle but DaggerAppComponent not support. please help thanks in advance
Where is your project address at Github? Let me try.
Homan Huang
On Wed, May 9, 2018 at 4:36 AM, sandeep287 notifications@github.com wrote:
compile "com.google.dagger🗡$daggerversion" annotationProcessor "com.google.dagger:dagger-compiler:$daggerversion"
i will already used this gradle but DaggerAppComponent not support. please help thanks in advance
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/erikcaffrey/Dagger2-MVP-Sample/issues/1#issuecomment-387710519, or mute the thread https://github.com/notifications/unsubscribe-auth/AbZG7s3R5RW2F4yxaFivPeGrnHCh_xf2ks5twtTNgaJpZM4IBtEs .
@sandeep287 Hey man!
First of all thanks for visit this repository, I hope you found it useful.
I Upgrated the project some minutes ago and it's working 😃.
!
Remember the class DaggerAppComponent is a generated class on compile time so you should do:
I hope it solves your problem.
Invalidate and Restart
invalidate & cache restart is not valid solution I have started new project setup dagger same problem raise daggerComponent not find the symbols.
Make Project and Rebuild Project So DaggerAppComponent will be generated .
1.Clean the project 2.Rebuild 3.File-->Invalidate and Restart
If you are in test folder, you don't need to rebuild it again; ignore the red line; run it. For example,
fun daggerInjection(app: Application) : TestRetrofitComponent { return DaggerTestRetrofitComponent.builder() .application( app ) .testAppModule(TestAppModule()) // for test purpose: 2 second timeout .apiModule(ApiModule(testUrl, 2, 2)) .build() }
my test component:
`
@Singleton
@Component(modules = [
AndroidSupportInjectionModule::class,
ApiModule::class,
TestAppModule::class
])
interface TestRetrofitComponent : AppointmentAppComponent {
@Component.Builder
interface Builder {
@BindsInstance
fun application(application: Application): Builder
fun apiModule(apiModule: ApiModule): Builder
fun testAppModule(testAppModule: TestAppModule): Builder
fun build(): TestRetrofitComponent // Type
}
// Dagger injector
fun inject(test: MainActivityRetrofitTest)
}
@Module
class TestAppModule {
@Singleton
@Provides
fun giveMockWebServer(): HomanMockWebServer = HomanMockWebServer()
}
Inject to the test class:
@Before
fun setUp() {
context = InstrumentationRegistry.getInstrumentation().targetContext
val testApp = context.applicationContext as DebugAppointmentApplication?
// Dagger component
val component = daggerInjection(testApp!!)
testApp.setTestComponent(component)
// Dagger shot: init all variables
component.inject(this)
`