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

[ksp] InjectProcessingStep was unable to process a class which extends Binder Stub because 'error.NonExistentClass' could not be resolved. #4158

Closed
Goooler opened this issue Nov 24, 2023 · 8 comments

Comments

@Goooler
Copy link

Goooler commented Nov 24, 2023

There is a class which extends Binder Stub like

class RemoteUnfoldTransitionReceiver
@Inject
constructor(
    useReceivingFilter: Boolean,
    private val executor: Executor
) : UnfoldTransitionProgressProvider, IUnfoldTransitionListener.Stub() {
}

(IUnfoldTransitionListener.Stub is generated from IUnfoldTransitionListener.aidl), provide RemoteUnfoldTransitionReceiver as

@Module
@DisableInstallInCheck
class UnfoldRemoteModule {
    @Provides
    @Singleton
    fun provideTransitionProvider(
        config: UnfoldTransitionConfig,
        traceListener: ATraceLoggerTransitionProgressListener,
        remoteReceiverProvider: Provider<RemoteUnfoldTransitionReceiver>,
    ): Optional<RemoteUnfoldTransitionReceiver> {
        if (!config.isEnabled) {
            return Optional.empty()
        }
        val remoteReceiver = remoteReceiverProvider.get()
        remoteReceiver.addCallback(traceListener)
        return Optional.of(remoteReceiver)
    }
}

This could be compiled by Hilt Kapt compiler but Hilt KSP compiler, with the error below:

e: [ksp] InjectProcessingStep was unable to process 'RemoteUnfoldTransitionReceiver(boolean,java.util.concurrent.Executor)' because 'error.NonExistentClass' could not be resolved.

Dependency trace:
    => element (CLASS): com.android.systemui.unfold.progress.RemoteUnfoldTransitionReceiver
    => type (ERROR superclass): error.NonExistentClass

If type 'error.NonExistentClass' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type 'error.NonExistentClass' is on your classpath.
e: [ksp] InjectProcessingStep was unable to process 'UnfoldTransitionProgressForwarder()' because 'error.NonExistentClass' could not be resolved.

Dependency trace:
    => element (CLASS): com.android.systemui.unfold.progress.UnfoldTransitionProgressForwarder
    => type (ERROR superclass): error.NonExistentClass

If type 'error.NonExistentClass' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type 'error.NonExistentClass' is on your classpath.
e: [ksp] ComponentProcessingStep was unable to process 'com.android.systemui.unfold.RemoteUnfoldSharedComponent' because 'error.NonExistentClass' could not be resolved.

Dependency trace:
    => element (CLASS): com.android.systemui.unfold.progress.RemoteUnfoldTransitionReceiver
    => type (ERROR superclass): error.NonExistentClass

If type 'error.NonExistentClass' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type 'error.NonExistentClass' is on your classpath.
e: Error occurred in KSP, check log for detail

You can repro this issue at LawnchairLauncher/lawnchair#3761 with following steps:

  1. git clone --recursive https://github.com/LawnchairLauncher/lawnchair.git
  2. git checkout repro-hilt-ksp-compiler-issue
  3. ./gradlew assembleLawnWithQuickstepDebug
@Goooler Goooler changed the title [ksp] InjectProcessingStep was unable to process a class extends Binder Stub because 'error.NonExistentClass' could not be resolved. [ksp] InjectProcessingStep was unable to process a class which extends Binder Stub because 'error.NonExistentClass' could not be resolved. Nov 24, 2023
@Goooler
Copy link
Author

Goooler commented Nov 24, 2023

Links #4049.

@Goooler
Copy link
Author

Goooler commented Nov 24, 2023

Workaround:

// Workaround for https://github.com/google/dagger/issues/4158
androidComponents {
    onVariants(selector().all(), { variant ->
        afterEvaluate {
            def capName = variant.name.capitalize()
            tasks.getByName("ksp${capName}Kotlin") {
                setSource(tasks.getByName("compile${capName}Aidl").outputs)
            }
        }
    })
}

@VincentMasselis
Copy link

VincentMasselis commented Nov 24, 2023

I'm facing the exact same issue with SQLDelight. In my case, I was able to make it work by updating build.gradle.kts like this:

// This is written for Gradle KTS 
androidComponents {
    onVariants(selector().all()) { variant ->
        afterEvaluate {
            val capName = variant.name.capitalize()
            tasks.getByName<KotlinCompile>("ksp${capName}Kotlin") {
                setSource(tasks.getByName("generate${capName}DatabaseInterface").outputs)
            }
        }
    }
}

@danysantiago
Copy link
Member

Filled https://issuetracker.google.com/313669430 for the AGP team as they own the AIDL stub generation.

@wbervoets
Copy link

wbervoets commented May 2, 2024

https://issuetracker.google.com/313669430 has been fixed, but this issue still gives me the same error when using ksp 1.9.23-1.0.20. Are there any other things I could try?

@aftabahmadTW
Copy link

@danysantiago any chance you could follow up with the AGP team about this as it still exists for generated code such as for sqldelight.

@Chang-Eric
Copy link
Member

@aftabahmadTW This issue was just for AIDL generated code. Even though the error looks similar, I think it could need to be fixed for each code generator depending on where the generated code is outputted. So you should file a separate issue for SQLDelight.

@aftabahmadTW
Copy link

@Chang-Eric Thanks, I'll create a small reproducer and file a new issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants