Dagger 2 components not generated when using Jack

When I turn on the Jack compiler in Android Studio 2.2, Dagger 2 is not generated. Can dagger 2 be used with jack? If so, how do I configure my application?

From my build.gradle application:

 jackOptions { enabled true } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } 
+6
source share
3 answers

I drowned like 2 days to figure this out. Therefore, I return to posting the results here if it saves time:

This is caused by a bug in Jack that prevents the path classes from working properly . This is because Jack runs in-process (in the same JVM as the gradle daemon). Setting android.defaultConfig.jackOptions.jackInProcess to false is beyond the scope of the Prerequisite error, but causes other problems (2 JVMs that support system resources) and errors that break the assembly in other ( worse ) ways.

Currently, the best solution is:

  • Wait for Android gradle version 2.3, which already has a fix for this.
  • Downgrade dagger to version 2.2, meanwhile. This is the highest version that seems to avoid a conflict with Guava and Jack.

EDIT: Update 1/14/2017:
I ran into several OTHER problems with Jack and was so tired of it that I switched to a retrolambda and kicked myself for not doing it before! Right now, Jack just seems to be causing more problems than he is solving. Just add lines with a plus and delete lines with a minus, and you can return to Dagger 2.8, waiting for Jack to act together!

 +plugins { + id "me.tatarka.retrolambda" version "3.4.0" +} apply plugin: 'com.android.application' +apply plugin: 'me.tatarka.retrolambda' - jackOptions { - enabled true - } 

For an even faster retrolambda build, add org.gradle.jvmargs=-Xmx4608M to your gradle.properties file gradle.properties that the dexing process can happen in the process. Now I'm on Dagger 2.8, and my clean builds are just 12 seconds, GOOD RIDDANCE, JACK!

+8
source

The documentation page on the Jack and Jill page contains instructions specific to annotation processors that will be applied at compile time but will not be included in your APK, "advising using the annotationProcessor dependency scope. The example randomly mentions Dagger 2:

 dependencies { compile 'com.google.dagger:dagger:2.0' annotationProcessor 'com.google.dagger:dagger-compiler:2.0' } 
+3
source

Jack is now deprecated, see this post .

You need to upgrade Android Studio to version 3.0 to use Java 8.

If you cannot update it (conflict with another library) or want to wait for the version version, you can try this solution:

  • Add retrolamba lib, follow the instructions here .
0
source

Source: https://habr.com/ru/post/1012771/


All Articles