0

when i try to test my application on more android device, i get this error:

java.lang.NoClassDefFoundError: com.myapp.androidapp.Dagger.Modules.NetworkModule_LoggingInterceptorFactory

i search more problems about Dagger, but i can't find whats this error and how can i resolve that,

my application work fine on Sony and Lenovo tables , but it doesn't work on Samsung

Application class:

component = DaggerGithubApplicationComponent.builder()
        .contextModule(new ContextModule(this))
        .jobManagerModule(new JobManagerModule())
        .networkServiceModule(new NetworkServiceModule("https://api.github.com/"))
        .build();

githubService = component.getGithubService();
picasso = component.getPicasso();
jobManager = component.getJobManager();
handler = component.getHandler();

my NetworkModule class:

@Module(includes = ContextModule.class)
public class NetworkModule {

    @Provides
    @AlachiqApplicationScope
    public HttpLoggingInterceptor loggingInterceptor() {
        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
            @Override
            public void log(String message) {
                Timber.e(message);
            }
        });
        interceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
        return interceptor;
    }

    @Provides
    @AlachiqApplicationScope
    public RxJavaCallAdapterFactory rxAdapter() {
        return RxJavaCallAdapterFactory.createWithScheduler(Schedulers.io());
    }


    @Provides
    @AlachiqApplicationScope
    public Cache cache(File cacheFile) {
        return new Cache(cacheFile, 10 * 1000 * 1000); //10MB Cahe
    }

    @Provides
    @AlachiqApplicationScope
    public File cacheFile(@ApplicationContext Context context) {
        return new File(context.getCacheDir(), "okhttp_cache");
    }

    @Provides
    @AlachiqApplicationScope
    public OkHttpClient okHttpClient(HttpLoggingInterceptor loggingInterceptor, Cache cache) {
        return new OkHttpClient.Builder()
                .addInterceptor(loggingInterceptor)
                .cache(cache)
                .build();
    }
}

GithubApplicationComponent:

@MyAppApplicationScope
@Component(
        modules = {
                UserInformationModule.class,
                NetworkServiceModule.class,
                PicassoModule.class,
                JobManagerModule.class,
                SocketModule.class,
                HandlerModule.class,
                ActivityModule.class
        }
)
public interface GithubApplicationComponent {
    GithubService getGithubService();

    JobManager getJobManager();

    Picasso getPicasso();

    Socket getSocket();

    Handler getHandler();
}

My full LogCat:

java.lang.NoClassDefFoundError: com.myapp.androidapp.Dagger.Modules.NetworkModule_LoggingInterceptorFactory
at com.myapp.androidapp.Dagger.Components.DaggerGithubApplicationComponent.initialize(DaggerGithubApplicationComponent.java:87)
at com.myapp.androidapp.Dagger.Components.DaggerGithubApplicationComponent.<init>(DaggerGithubApplicationComponent.java:76)
at com.myapp.androidapp.Dagger.Components.DaggerGithubApplicationComponent.<init>(DaggerGithubApplicationComponent.java:0)
at com.myapp.androidapp.Dagger.Components.DaggerGithubApplicationComponent$Builder.build(DaggerGithubApplicationComponent.java:210)
at com.myapp.androidapp.Alachiq.onCreate(Alachiq.java:124)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1017)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4717)
at android.app.ActivityThread.access$1600(ActivityThread.java:163)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1419)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5536)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1397)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1192)
tux-world
  • 2,680
  • 6
  • 24
  • 55
  • It is possible to end up with an old version of the generated Dagger components if you, say, checkout a branch and deploy without performing a `clean` first. Is that what is happening here? Or are the errors from versions of your app downloaded from the Google Play store? – David Rawson Jun 06 '17 at 01:03
  • @DavidRawson i'm using latest version of dagger, clean project and invalidate cache don't resolve my problem, application is developed by me and don't stored on google play – tux-world Jun 06 '17 at 05:12
  • I think the best thing then is to try and make a [mcve] that replicates the problem – David Rawson Jun 06 '17 at 06:14

0 Answers0