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

java.lang.IllegalArgumentException: Invalid relative name: META-INF\proguard\com_example_ui_backupBackupViewModel_HiltModules_BindsModule_LazyClassKeys.pro #4533

Closed
HyakYegoryaln opened this issue Dec 9, 2024 · 12 comments · Fixed by #4542

Comments

@HyakYegoryaln
Copy link

I am encountering an issue when building my project on Windows devices. The build process fails due to problems related to META-INF files, specifically during KAPT or while processing dependencies like com.google.dagger:hilt-compiler.

This issue only occurs on Windows systems, and the project builds without issues on macOS and Linux.

Caused by: java.lang.IllegalArgumentException: Invalid relative name: META-INF\proguard\[com_example_ui_backupBackupViewModel_HiltModules_BindsModule_LazyClassKeys.pro](http://com_example_ui_backupbackupviewmodel_hiltmodules_bindsmodule_lazyclasskeys.pro/)
    at jdk.compiler/com.sun.tools.javac.file.JavacFileManager.getFileForOutput(Unknown Source)
    at org.jetbrains.kotlin.kapt3.base.javac.KaptJavaFileManager.getFileForOutput(KaptJavaFileManager.kt:82)
    at jdk.compiler/com.sun.tools.javac.processing.JavacFiler.createResource(Unknown Source)
    at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalFiler.createResource(incrementalProcessors.kt:121)
    at dagger.spi.internal.shaded.androidx.room.compiler.processing.javac.JavacFiler.writeResource(JavacFiler.kt:94)
    at dagger.internal.codegen.processingstep.LazyClassKeyProcessingStep.writeProguardFile(LazyClassKeyProcessingStep.java:112)
    at dagger.internal.codegen.processingstep.LazyClassKeyProcessingStep.processOver(LazyClassKeyProcessingStep.java:106)
    at dagger.spi.internal.shaded.androidx.room.compiler.processing.XProcessingStep.process(XProcessingStep.kt:54)
    at dagger.spi.internal.shaded.androidx.room.compiler.processing.CommonProcessorDelegate.processLastRound(XBasicAnnotationProcessor.kt:168)
    at dagger.spi.internal.shaded.androidx.room.compiler.processing.javac.JavacBasicAnnotationProcessor.process(JavacBasicAnnotationProcessor.kt:65)
    at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt:90)
    at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:216)

I use:
implementation "com.google.dagger:hilt-android:2.53"
kapt "com.google.dagger:hilt-compiler:2.53"

id 'com.android.application' version '8.7.2' apply false
id 'org.jetbrains.kotlin.android' version '2.0.21' apply false
gradle-8.9

@cemtufekci
Copy link

cemtufekci commented Dec 9, 2024

happens on my project too. I am also developing on a Windows PC.

kotlin: 2.0.21
agp: 8.7.3
dagger: 2.53

@cemtufekci
Copy link

This error also happens in 2.53.1

@HyakYegoryaln
Copy link
Author

I tried using KSP instead of KAPT, and the problem was resolved. I used KSP version "2.0.21-1.0.28"

@cemtufekci
Copy link

I can't remove kapt because I'm using databinding.

@infisdeveloper
Copy link

infisdeveloper commented Dec 10, 2024

i am too

I rollback to
kotlin = 2.0.21
agp: 8.7.2
hilt: 2.52

and the problem was resolved

@bcorso
Copy link

bcorso commented Dec 11, 2024

I took a brief look at this and my guess this is due to Java's Path.of() automatically converting the path separators in the original string to OS-specifc path separators. In particular, we use / to create the file here but the path in the error message uses \ (i.e. META-INF\proguard\...).

Typically, choosing the OS-specific path separators would be the behavior we would want; however, in this case the resource file is being stored in a JAR file, and the defined path separator in a JAR is /. Thus, I think we'll need to make an API change in XProcessing, since XFiler#createResource() only takes in a Path.

I've filed https://issuetracker.google.com/383578358.

copybara-service bot pushed a commit to androidx/androidx that referenced this issue Dec 11, 2024
Since resources are placed on the Jar the specification requires the use of forward-slash file path separator, while the Path API converts the given path to string using file-system dependant separator.

KspFiler is not affected since the resources is placed in the file system and later packaged into the output jar and paths can use file-system dependant separator.

See google/dagger#4533.

Bug: 383578358
Test: Existing
Change-Id: I823f7a5ce2feb3afafda2129770a17a2d16b0baf
@cemtufekci
Copy link

Should we wait for a new release ?

@bcorso
Copy link

bcorso commented Dec 17, 2024

Yes, however I'm still waiting on the XProcessing fix (https://issuetracker.google.com/383578358) to be available to Dagger. I should be able to do a release in the next day or two.

copybara-service bot pushed a commit that referenced this issue Dec 19, 2024
The update pulls in a fix for #4533, which fixes the path separator for Windows when creating LazyClassKey proguard file.

Fixes #4533

RELNOTES=Fixes #4533: Fixes path separator for Windows when creating LazyClassKey proguard file.
PiperOrigin-RevId: 707914983
copybara-service bot pushed a commit that referenced this issue Dec 19, 2024
The update pulls in a fix for #4533, which fixes the path separator for Windows when creating LazyClassKey proguard file.

Fixes #4533

RELNOTES=Fixes #4533: Fixes path separator for Windows when creating LazyClassKey proguard file.
PiperOrigin-RevId: 707914983
copybara-service bot pushed a commit that referenced this issue Dec 19, 2024
The update pulls in a fix for #4533, which fixes the path separator for Windows when creating LazyClassKey proguard file.

Fixes #4533

RELNOTES=Fixes #4533: Fixes path separator for Windows when creating LazyClassKey proguard file.
PiperOrigin-RevId: 707914983
@bcorso
Copy link

bcorso commented Dec 20, 2024

I'll plan on doing a release tomorrow, but if anyone wants to try it out and verify the fix beforehand you can use Dagger's HEAD-SNAPSHOT artifact.

While we're pretty confident the XProcessing change should fix this issue, we also don't have any test coverage on Windows so we'll be relying on your feedback to verify the fix.

@cemtufekci
Copy link

Sure thing, I'm gonna test as soon as possible when it's live.

@cemtufekci
Copy link

It's working now. Thank you so much !

@JimVanG
Copy link

JimVanG commented Jan 7, 2025

I can't remove kapt because I'm using databinding.

That's fine because you don't need to remove the kapt. What you would've done is only replace the kapt with the newer ksp annotation-processor for only the Hilt/Dagger dependency.

Replacing the kapt with the ksp in Hilt/ Dagger fixed the issue that was being faced on windows machines with the META-INF errors.

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

Successfully merging a pull request may close this issue.

5 participants