Unresolved reference BuildConfig when upgrading to 1.5.0
See original GitHub issueHi, I’ve been using this library using AGP 4 and Root Coverage Plugin 1.4.0. But after I update the AGP and kotlin version to this version (see version below) I got an error that said Unresolved reference: BuildConfig
. The unresolved BuildConfig causes an error when I generate jacoco report or assembleDebug the app. Fyi I saved the value of BuildConfigField at shared gradle and apply it to each module, is that affect this issue?. Also, when I downgrade to 1.4.0 the error is gone, generating a report is successful but causes [ant:jacocoReport] Execution data for class 'xxx' does not match
.
This is the version:
AGP: 7.2.0
Kotlin Gradle Plugin: 1.6.21
Jacoco: 0.8.6
This is the stackrace:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':core:compileDebugKotlin'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:145)
at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:143)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:131)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:77)
at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
unresolved reference : BuildConfig in Kotlin - Stack Overflow
Here are some simple steps which resolved this issue: Go to File menu > Build > Clean Project; Now go to File menu...
Read more >error: unresolved reference: BuildConfig · Issue #3272 - GitHub
This is due to the inability to gather the complete compile classpath from the Android Gradle Plugin (upstream ticket) and can safely be...
Read more >Strange "Unresolved reference:" error after upgrading to Kotlin ...
Coding example for the question Strange "Unresolved reference:" error after upgrading to Kotlin 1.0.5-kotlin.
Read more >It is not a problem: [UNRESOLVED_REFERENCE ...
It is not a problem: [UNRESOLVED_REFERENCE] Unresolved reference: BuildConfig · I used jvm-android linter · BuildConfig file is a generated class ...
Read more >New Build System - Android Studio Project Site
Upgrade required Gradle to 2.14.1; Fixes to reduce memory consumption ... Unresolved placeholder failure in manifest merger when building library test ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
After upgrading to
1.5.1
, it works like a charm! Thanks @Rolf-SmitDid some digging, I found that I can no longer reproduce this when I remove this line:
https://github.com/NeoTech-Software/Android-Root-Coverage-Plugin/blob/0b28266b2737d10adaa3804ad9a056caeb1ef992/plugin/src/main/kotlin/org/neotech/plugin/rootcoverage/RootCoveragePlugin.kt#L179
But obviously this line is needed for code coverage to work. So while it fixes the BuildConfig problem, it breaks code coverage.
I suspect the issue is in the
variant.sources.java.all
part. This is a new public but unstable API to get the Java source locations. Release 1.4 of this plugin was using an older (unofficial) method to get the Java sources. For some reason calling this API results in the BuildConfig file to disappear. I updated to AGP version7.3.0-beta01
and by doing so the problem was gone.Conclusion:
variant.sources.java.all
is broken in AGP version 7.2 and causes class files to disappear (not generated?). In AGP7.3.0-beta01
this issue is not present.Solution: There are 2 things possible, the quick and easy is to update to AGP version
7.3.0-beta01
but not everyone might be able to do so. The other (more difficult) solution is to create a hot-fix for this release where I change to code so it uses the old (unofficial) method to get the Java sources. However this is not as easy as one might think, since in release 1.5 I changed the whole plugin setup to use official APIs only.TLDR: This is potentially a bug in AGP 7.2, I’m looking to workaround this.