-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Using enableAggregatingTask does not generate classes #2695
Comments
Can you provide more information? Do you have tests failing? is your APK failing to compile? What sort of error are you seeing? With |
The apk compiling is running fine but when I start the app, the app crashes with "Class not found exception". When having a look at the build folder, the crash is valid because expected classes are not available (like Hilt_MyApplication). |
The |
Do you have a repro project you can share? Some more questions to try and help us figure this out:
|
Nothing I can share at this moment.
Present in every build and product flavor that exists in the project.
Kotlin code only.
I have no custom annotation processor flags present in the project.
That folder does not exist for me. When using enableExperimentalClasspathAggregation the files are created as part of \build\generated\source\kapt\devMockDebug\com\demo\app. This folder includes all expected files. When using enableAggregatingTask, this folder only contains the injector generated classes but nothing else. |
This might be hard to repro without a sample app... I got more questions though:
|
I can create a sample app but that might take until next month (or longer) until I get the needed time to spend on that.
I can see the issue when building from Android Studio and command line.
4.2.1
Both tasks are executed, but hiltJavaCompile is stated as |
Seems my same issue. I didn't see this and I opened another issue.. sorry :( |
Thanks for sharing the example project, @aeroxr1. @danysantiago is that enough for you and your team to reproduce and potentially fix the issue? |
Thanks for the sample app @aeroxr1, I'll take a look and report back. |
@aeroxr1 do you have any specific repro steps? I was able to clone and run the sample app successfully. Building and installing I can see the right files being generated:
Inspecting the APK and dex files also show the generated application being correctly included: |
I run the app branch feature/hilt from Android Studio 4.2.1 on Samsung tab s6. The app starts, but it immediately crash with this stacktrace:
Moreover i don't see ../app/build/intermediates/hilt directory |
I'm having trouble with a similar problem. After setting
When I checked the component_classes directory, I verify that AGP: 7.0.0-beta03 PS: I don't use Hilt in my tests or androidTests. Hence I haven't included any testImplementation related to dagger / hilt. Edit: Task fails both from the terminal using |
@safaorhan I believe what you are seeing is a different issue related to AGP, see: https://issuetracker.google.com/190438045. You should be able to workaround by adding an empty source file into the @aeroxr1 I want to know more about your environment setup:
Thanks again for providing all the info. |
@danysantiago Indeed it is! Thank you so much! |
@danysantiago I applied the workaround described in the issue tracker link (https://issuetracker.google.com/190438045) but the problem still continues. (It fixed some of other errors I was getting for the modules that I haven't any test source files) This is what I get if I run
And if I switch to the experimental flag:
build succeeds. I can create a separate issue and can provide more info if you need. Best, Safa |
I'm using Windows. And I have the same issue also on the emulator |
Thanks - I was finally able to repro in a dev environment with Windows. Don't have a fix yet but will keep you posted. |
Thanks ! :) |
Using file APIs allows for platform-agnostic path comparisons where as File#parent() returns a String which will contain path separators that are OS specific and will fail to match with the known aggregated packages path that use UNIX-based file separator '/'. Specifically this fixes an issue for Windows users whose file separators are '\'. Note that JarEntry path matching is String based but well formatted Jar files (which are Zip files) regardless of the host OS use forward slashes as path separator. Fixes #2695 RELNOTES=Fix an issue where `enableAggregatingTask` would not correctly generate Hilt classes when compiling in a dev environment with Windows OS. PiperOrigin-RevId: 381877388
Using file APIs allows for platform-agnostic path comparisons where as File#parent() returns a String which will contain path separators that are OS specific and will fail to match with the known aggregated packages path that use UNIX-based file separator '/'. Specifically this fixes an issue for Windows users whose file separators are '\'. Note that JarEntry path matching is String based but well formatted Jar files (which are Zip files) regardless of the host OS use forward slashes as path separator. Fixes #2695 RELNOTES=Fix an issue where `enableAggregatingTask` would not correctly generate Hilt classes when compiling in a dev environment with Windows OS. PiperOrigin-RevId: 381877388
@danysantiago Why closed this issue? |
@andrewhunter0 we typically close issues with the commit that fixes them rather than with the release. You can still verify the fix using the // Project-level build.gradle
buildscript {
ext.daggerVersion = "HEAD-SNAPSHOT"
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
allprojects {
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
} Because Gradle sometimes gets confused on versions that are not numerical you may also need to add: configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.google.dagger') {
details.useVersion 'HEAD-SNAPSHOT'
details.because 'HEAD-SNAPSHOT should act as latest version.'
}
}
} |
Ok, thank you, i will try and reply. |
@bcorso
What went wrong:
Because we should use proxy of
|
@andrewhunter0 we plan to do a release this week. However, besides the version name there's no difference between the current The artifact is contained in the // Project-level build.gradle
allprojects {
repositories {
google(),
}
} |
@bcorso I still got the same error:
And the generated files list as below: If i use |
@andrewhunter0 can you verify that you're also using |
@bcorso |
When using the dagger 2.37 with the enableAggregatingTask flag set to true, several required classes are not generated anymore. For example the Hilt_MyApplication does not exist anymore, but also several class dependencies. It seems that only the injector related classes are created. When using enableExperimentalClasspathAggregation (without enableAggregatingTask), everything is working fine.
The text was updated successfully, but these errors were encountered: