0

I am currently developing an android application (Min. API-Level 21) with Android Studio 3.4.2. When I tried to sync my gradle (I was adding dagger dependencies) I seem to have lost my internet connection, therefore resulting in an corrupted gradle.

So far I've tried deleting gradle and IDE caches, deleting and redownloading my entire gradle, restarting the IDE, using a local gradle, restarting my PC and reimporting the project...

I virtually tried every single answer on this question: Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

My build.gradle:

...
  implementation 'com.google.dagger:dagger:2.24'
  annotationProcessor 'com.google.dagger:dagger-compiler:2.7'
  implementation 'com.google.dagger:dagger-android:2.15'
  annotationProcessor 'com.google.dagger:dagger-android-processor:2.24'

After following all of the stated instructions for hours I still got the same error message:

Unable to load class 'dagger.Multibindings'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)

The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)

Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

Since I am actually able to add new dependencies when I remove the following line I suspect the issue might actually be caused by dagger since my gradle was interrupted while I was trying to synchronize new dagger dependencies:

annotationProcessor 'com.google.dagger:dagger-android-processor:2.24'

This problem is really confusing and I need your help! Thank you in advance.

Josip Domazet
  • 2,246
  • 2
  • 14
  • 37
  • Try this : implementation 'com.google.dagger:dagger:2.14.1' annotationProcessor com.google.dagger:dagger-compiler:2.14.1' – Kabir Aug 17 '19 at 04:58
  • Did you clean your cache of your Android Studio from File -> Invalidate Cahces / Restart? – No Body Aug 17 '19 at 05:31
  • @Kabir I followed your advice and it worked. After a successful launch I changed my gradle back to my original variant and the exception didn't return. Thank you! – Josip Domazet Aug 17 '19 at 13:43
  • @Kabir btw. how can I mark your comment as correct? – Josip Domazet Aug 17 '19 at 13:44
  • You cannot mark correct comment ,i should put my code to in answer ->then you can ..If you will correct answer then i will put my code in answer. – Kabir Aug 17 '19 at 13:59
  • Well I want to you to get your deserved reputation so put in an answer please. – Josip Domazet Aug 17 '19 at 14:34

1 Answers1

1

// Add Dagger dependencies

dependencies {
  implementation 'com.google.dagger:dagger:2.x'
  annotationProcessor 'com.google.dagger:dagger-compiler:2.x'
}

Example dependencies:

implementation 'com.google.dagger:dagger-android:2.20'
implementation 'com.google.dagger:dagger-android-support:2.20' // if you use the support libraries
annotationProcessor 'com.google.dagger:dagger-android-processor:2.20'
annotationProcessor 'com.google.dagger:dagger-compiler:2.20'
Kabir
  • 852
  • 7
  • 11
  • Ok never mind the problem still persists. I cannot add annotationProcessor 'com.google.dagger:dagger-android-processor:2.24' to my gradle. This problem is haunting me..... – Josip Domazet Aug 18 '19 at 14:55
  • Invalidate cache and restart your porject and rebuild it. – Kabir Aug 18 '19 at 15:18
  • If still error occurs -->if same you different error logcat then plese post here. – Kabir Aug 18 '19 at 15:25
  • Without dagger dependency ,your project run perfectly? – Kabir Aug 18 '19 at 15:41
  • yes exactly without this annotationProcessor 'com.google.dagger:dagger-android-processor:2.24' it works just fine – Josip Domazet Aug 18 '19 at 15:46
  • I updated depenedencie in my answer....Remove other dragle depenedecy and add from my answer.But make sure your internet connection is now slow. – Kabir Aug 18 '19 at 16:15