Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with v2.40 and enableAggregatingTask #2997

Closed
SteinerOk opened this issue Nov 9, 2021 · 4 comments · Fixed by #3056
Closed

Problem with v2.40 and enableAggregatingTask #2997

SteinerOk opened this issue Nov 9, 2021 · 4 comments · Fixed by #3056

Comments

@SteinerOk
Copy link

First of all: with 2.39.1 project compiles and run fine.
After updating Dagger to 2.40 the project stopped building and gives an error:

* What went wrong:
Execution failed for task ':app:hiltJavaCompileGmsDebug'.
> java.lang.IllegalStateException: no component requirement expression found for ComponentRequirement{kind=BOUND_INSTANCE, wrappedType=MoreTypes.equivalence().wrap(ru.papirus.android.app.di.subcomponent.account.AccountPapirusSubApp), overrideNullPolicy=Optional.empty, key=Optional[ru.papirus.android.app.di.subcomponent.account.AccountPapirusSubApp], variableName=arg0}

I added code for disabling enableAggregatingTask:

hilt {
    enableAggregatingTask = false
}

After that, the build of the project is completed successfully, but at startup I get the application crash with the following error in the logs:

2021-11-09 03:25:30.592 27387-27387/ru.papirus.android.app.debug E/AndroidRuntime: FATAL EXCEPTION: main
    Process: ru.papirus.android.app.debug, PID: 27387
    java.lang.RuntimeException: Unable to instantiate application ru.papirus.android.app.PapirusApp: java.lang.ClassNotFoundException: Didn't find class "ru.papirus.android.app.PapirusApp" on path: DexPathList[[dex file "/data/data/ru.papirus.android.app.debug/code_cache/.overlay/base.apk/classes20.dex", zip file "/data/app/~~pIc67hHzc6AKwbXVC20BQA==/ru.papirus.android.app.debug-Y_hFu0ddHrOoZzjyT5Ug-Q==/base.apk"],nativeLibraryDirectories=[/data/app/~~pIc67hHzc6AKwbXVC20BQA==/ru.papirus.android.app.debug-Y_hFu0ddHrOoZzjyT5Ug-Q==/lib/arm64, /data/app/~~pIc67hHzc6AKwbXVC20BQA==/ru.papirus.android.app.debug-Y_hFu0ddHrOoZzjyT5Ug-Q==/base.apk!/lib/arm64-v8a, /system/lib64, /system/system_ext/lib64, /system/product/lib64]]
        at android.app.LoadedApk.makeApplication(LoadedApk.java:1268)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6690)
        at android.app.ActivityThread.access$1300(ActivityThread.java:237)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7664)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "ru.papirus.android.app.PapirusApp" on path: DexPathList[[dex file "/data/data/ru.papirus.android.app.debug/code_cache/.overlay/base.apk/classes20.dex", zip file "/data/app/~~pIc67hHzc6AKwbXVC20BQA==/ru.papirus.android.app.debug-Y_hFu0ddHrOoZzjyT5Ug-Q==/base.apk"],nativeLibraryDirectories=[/data/app/~~pIc67hHzc6AKwbXVC20BQA==/ru.papirus.android.app.debug-Y_hFu0ddHrOoZzjyT5Ug-Q==/lib/arm64, /data/app/~~pIc67hHzc6AKwbXVC20BQA==/ru.papirus.android.app.debug-Y_hFu0ddHrOoZzjyT5Ug-Q==/base.apk!/lib/arm64-v8a, /system/lib64, /system/system_ext/lib64, /system/product/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
        at androidx.core.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:52)
        at android.app.Instrumentation.newApplication(Instrumentation.java:1160)
        at android.app.LoadedApk.makeApplication(LoadedApk.java:1260)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6690) 
        at android.app.ActivityThread.access$1300(ActivityThread.java:237) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:223) 
        at android.app.ActivityThread.main(ActivityThread.java:7664) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
    	Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Lru/papirus/android/app/Hilt_PapirusApp;
        at java.lang.VMClassLoader.findLoadedClass(Native Method)
        at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
        		... 14 more
     Caused by: java.lang.ClassNotFoundException: Didn't find class "ru.papirus.android.app.Hilt_PapirusApp" on path: DexPathList[[dex file "/data/data/ru.papirus.android.app.debug/code_cache/.overlay/base.apk/classes20.dex", zip file "/data/app/~~pIc67hHzc6AKwbXVC20BQA==/ru.papirus.android.app.debug-Y_hFu0ddHrOoZzjyT5Ug-Q==/base.apk"],nativeLibraryDirectories=[/data/app/~~pIc67hHzc6AKwbXVC20BQA==/ru.papirus.android.app.debug-Y_hFu0ddHrOoZzjyT5Ug-Q==/lib/arm64, /data/app/~~pIc67hHzc6AKwbXVC20BQA==/ru.papirus.android.app.debug-Y_hFu0ddHrOoZzjyT5Ug-Q==/base.apk!/lib/arm64-v8a, /system/lib64, /system/system_ext/lib64, /system/product/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        		... 17 more
    	[CIRCULAR REFERENCE:java.lang.NoClassDefFoundError: Failed resolution of: Lru/papirus/android/app/Hilt_PapirusApp;]
@jraska
Copy link

jraska commented Nov 18, 2021

Hi, not using Hilt, but getting very similar issue with v2.40.1 after update from v2.39.1

@Subcomponent(modules = [SomeModule::class])
abstract class SomeSubcomponent {

    @Subcomponent.Factory
    interface Factory {
        fun create(@BindsInstance instance: InstanceType): SomeSubcomponent
    }
}

Results in failure:

Caused by: java.lang.IllegalStateException: no component requirement expression found for 
ComponentRequirement{kind=BOUND_INSTANCE, wrappedType=MoreTypes.equivalence().wrap(com.example.InstanceType), 
overrideNullPolicy=Optional.empty, key=Optional[com.example.InstanceType], variableName=arg0}

Changing to

@Subcomponent(modules = [SomeModule::class])
abstract class SomeSubcomponent {

    @Subcomponent.Builder
    interface Builder {
        @BindsInstance 
        fun instance(instance: InstanceType): Builder
        fun build(): SomeSubcomponent
    }
}

Fixes the issue, but fails later on different case of using the @Subcomponent.Factory.

@bcorso
Copy link

bcorso commented Nov 18, 2021

@jraska I wasn't able to repro the failure. Would you be able to create a sample project that repros this case?

@jraska
Copy link

jraska commented Nov 18, 2021

Thanks for the fast reply :)

Will try soon once I get time for it - the snippets were extracted from larger project, though except subcomponents there is nothing too exotic 🤔

@bcorso
Copy link

bcorso commented Nov 22, 2021

@jraska thanks, I had some time to play around with it a bit more and was able to reproduce your error by moving the subcomponent into a separate Gradle module.

I think I found the issue and have a fix that I'll get out this week.

copybara-service bot pushed a commit that referenced this issue Nov 22, 2021
This CL fixes an issue where the parameter name for a ComponentRequirement causes a cache-miss for that requirement. This occurs because one ComponentRequirement uses the name from JavacMethodParameter.getName() which pulls the original parameter name from the KotlinMetadata, and the other uses VariableElement.getSimpleName() which may match the original parameter in some cases but may be "arg0" if the name comes from a precompiled class. This difference in name causes the cache miss.

I'll need to look into if this is something we should fix on the XProcessing side, e.g. have the user explicitly choose if they want to use the name from the kotlin metadata.

Fixes #2997

RELNOTES=N/A
PiperOrigin-RevId: 411454511
copybara-service bot pushed a commit that referenced this issue Nov 22, 2021
This CL fixes an issue where the parameter name for a ComponentRequirement causes a cache-miss for that requirement. This occurs because one ComponentRequirement uses the name from JavacMethodParameter.getName() which pulls the original parameter name from the KotlinMetadata, and the other uses VariableElement.getSimpleName() which may match the original parameter in some cases but may be "arg0" if the name comes from a precompiled class. This difference in name causes the cache miss.

I'll need to look into if this is something we should fix on the XProcessing side, e.g. have the user explicitly choose if they want to use the name from the kotlin metadata.

Fixes #2997

Fixes #3032

RELNOTES=N/A
PiperOrigin-RevId: 411454511
copybara-service bot pushed a commit that referenced this issue Nov 22, 2021
This CL fixes an issue where the parameter name for a ComponentRequirement causes a cache-miss for that requirement. This occurs because one ComponentRequirement uses the name from JavacMethodParameter.getName() which pulls the original parameter name from the KotlinMetadata, and the other uses VariableElement.getSimpleName() which may match the original parameter in some cases but may be "arg0" if the name comes from a precompiled class. This difference in name causes the cache miss.

I'll need to look into if this is something we should fix on the XProcessing side, e.g. have the user explicitly choose if they want to use the name from the kotlin metadata.

Fixes #2997

Fixes #3032

RELNOTES=N/A
PiperOrigin-RevId: 411454511
copybara-service bot pushed a commit that referenced this issue Nov 22, 2021
This CL fixes an issue where the parameter name for a ComponentRequirement causes a cache-miss for that requirement. This occurs because one ComponentRequirement uses the name from JavacMethodParameter.getName() which pulls the original parameter name from the KotlinMetadata, and the other uses VariableElement.getSimpleName() which may match the original parameter in some cases but may be "arg0" if the name comes from a precompiled class. This difference in name causes the cache miss.

I'll need to look into if this is something we should fix on the XProcessing side, e.g. have the user explicitly choose if they want to use the name from the kotlin metadata.

Fixes #2997

Fixes #3032

RELNOTES=N/A
PiperOrigin-RevId: 411454511
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants