square / anvil

A Kotlin compiler plugin to make dependency injection with Dagger 2 easier.
Apache License 2.0
1.31k stars 81 forks source link

Generated files contain errors #842

Closed lippfi closed 8 months ago

lippfi commented 9 months ago

I have been unable to locate an appropriate forum (such as a Matrix chat or Discord channel) to address my query, therefore, I am presenting it here. My apologies if this is not the correct platform for such questions. I am experiencing an issue with a failing build, as indicated by the following logs:

C:\Users\Administrator\Downloads\android\app\build\generated\source\kapt\internalDebug\anvil\module\com\duckduckgo\app\di\AppComponentAnvilModule_Companion_ProvidePixelParamRemovalPluginMulti0Factory.java:36: error: package AppComponentAnvilModule does not exist
    return Preconditions.checkNotNullFromProvides(AppComponentAnvilModule.Companion.providePixelParamRemovalPluginMulti0());
                                                                         ^
C:\Users\Administrator\Downloads\android\app\build\generated\source\kapt\internalDebug\anvil\module\com\duckduckgo\app\di\AppComponentAnvilModule_Companion_ProvidePixelParamRemovalPluginMulti1Factory.java:36: error: package AppComponentAnvilModule does not exist
    return Preconditions.checkNotNullFromProvides(AppComponentAnvilModule.Companion.providePixelParamRemovalPluginMulti1());

This appears to be the only error in my build. Could this possibly be a bug, or is there an error in my approach? How can I identify and address the cause of this problem?

Also attaching the generated file:

package anvil.module.com.duckduckgo.app.di;

import com.duckduckgo.common.utils.plugins.pixel.PixelParamRemovalPlugin;
import dagger.internal.DaggerGenerated;
import dagger.internal.Factory;
import dagger.internal.Preconditions;
import dagger.internal.QualifierMetadata;
import dagger.internal.ScopeMetadata;
import javax.annotation.processing.Generated;

@ScopeMetadata
@QualifierMetadata
@DaggerGenerated
@Generated(
    value = "dagger.internal.codegen.ComponentProcessor",
    comments = "https://dagger.dev"
)
@SuppressWarnings({
    "unchecked",
    "rawtypes",
    "KotlinInternal",
    "KotlinInternalInJava"
})
public final class AppComponentAnvilModule_Companion_ProvidePixelParamRemovalPluginMulti0Factory implements Factory<PixelParamRemovalPlugin> {
  @Override
  public PixelParamRemovalPlugin get() {
    return providePixelParamRemovalPluginMulti0();
  }

  public static AppComponentAnvilModule_Companion_ProvidePixelParamRemovalPluginMulti0Factory create(
      ) {
    return InstanceHolder.INSTANCE;
  }

  public static PixelParamRemovalPlugin providePixelParamRemovalPluginMulti0() {
    return Preconditions.checkNotNullFromProvides(AppComponentAnvilModule.Companion.providePixelParamRemovalPluginMulti0());
  }

  private static final class InstanceHolder {
    private static final AppComponentAnvilModule_Companion_ProvidePixelParamRemovalPluginMulti0Factory INSTANCE = new AppComponentAnvilModule_Companion_ProvidePixelParamRemovalPluginMulti0Factory();
  }
}
JoelWilcox commented 8 months ago

At first glance this looks like it could be related to the incremental compilation issues we're working on fixing. Can you confirm if rebuilding with the --rerun-tasks flag causes the error to go away for you?

lippfi commented 8 months ago

I've just updated Anvil to 2.4.9 and can't reproduce the issue anymore Thank you for your response!