Status Update
Comments
je...@google.com <je...@google.com>
bi...@google.com <bi...@google.com>
je...@google.com <je...@google.com> #2
this seems to be pointing to an issue with dex transforms, I can see there is only 1 .class file in lib/a but 2 dex files.
./lib/build/intermediates/runtime_library_classes_dir/debug/com/example/lib/a/BuildConfig.class ./lib/build/intermediates/javac/debug/classes/com/example/lib/a/BuildConfig.class ./lib/build/generated/source/buildConfig/debug/com/example/lib/a/BuildConfig.java ./lib/build/.transforms/adfcd297971eeda5a95b2b2e7fff7506/transformed/debug/com/example/lib/BuildConfig.dex ./lib/build/.transforms/adfcd297971eeda5a95b2b2e7fff7506/transformed/debug/com/example/lib/a/BuildConfig.dex ./app/build/intermediates/project_dex_archive/debug/out/com/example/app/BuildConfig.dex ./app/build/intermediates/javac/debug/classes/com/example/app/BuildConfig.class ./app/build/generated/source/buildConfig/debug/com/example/app/BuildConfig.java
je...@google.com <je...@google.com> #3
ok root of the issue is the SerializedChange is incorrect : SerializableChange(file=/usr/local/google/home/jedo/bugs/223365583/DuplicateClassBug/lib/build/intermediates/runtime_library_classes_dir/debug/com/example/lib/BuildConfig.class, fileStatus=REMOVED, normalizedPath=BuildConfig.class)
normalizedPath seems like it needs to contain the package name + class name to function properly.
hu...@google.com <hu...@google.com> #4
Yes this is a regression in AGP 7.1+ introduced by
In DexingTranform.kt
, we have this code (edited to show key ideas) to remove stale dex files in the transform outputs:
inputChanges.removedFiles.forEach { removedClassFile: org.gradle.work.FileChange ->
val staleDexFileRelativePath = removedClassFile.normalizedPath + ".dex"
FileUtils.deleteRecursivelyIfExists(dexOutputDir.resolve(staleDexFileRelativePath))
}
Note that the call to removedClassFile.normalizedPath
is meant to get a relative path, which means the dexing transform's input needs to be annotated with PathSensitivity.RELATIVE
or @Classpath
.
Previously, the input was annotated as @Classpath
, but in AGP 7.1+ it was changed to PathSensitivity.NAME_ONLY
(the commit above) to fix
I guess we will need to find another way to get the relative path (or find a different way to fix the other bug?)
je...@google.com <je...@google.com> #5
yes, I have made a change that uses RELATIVE path sensitivity
Change-Id: If04c848a174fb2a981f402a855c5132433f6a0fd
bi...@google.com <bi...@google.com>
mc...@ebay.com <mc...@ebay.com> #6
Any chance we could get this back-ported to the 7.1 series? This is incredibly painful for us.
je...@google.com <je...@google.com> #7
yes, I am planning to have this backported to 7.1.3, I will confirm
mc...@ebay.com <mc...@ebay.com> #8
Excellent. Being able to convey this to our folks should help appease them a bit in the mean time. Thanks.
th...@gmail.com <th...@gmail.com> #10
ky...@icloud.com <ky...@icloud.com> #12
Excellent. Being able to convey this to our folks should help appease them a bit in the mean time. Thanks.
je...@google.com <je...@google.com> #9Mar 14, 2022 10:56PM
Marked as fixed.
Fixed, will be available in 7.1.3 and up.
th...@gmail.com <th...@gmail.com> #10Apr 4, 2022 07:30AM
Do we have an ETA for when 7.1.3 will be published?
ch...@instacart.com <ch...@instacart.com> #11Apr 7, 2022 12:55PM
It was published today
Add comment
kk...@gmail.com <kk...@gmail.com> #13
How can I download the soure code for AGP plugin 7.1.3 ? I don't konw the branch
hu...@google.com <hu...@google.com> #14
How can I download the soure code for AGP plugin 7.1.3 ?
It's here:
If you wanted to see the fix at
fa...@publicisgroupe.net <fa...@publicisgroupe.net> #15
When we downgrade to 7.2.2 it's OK
ga...@google.com <ga...@google.com> #16
Re #15: You are almost certainly hitting
Description
DESCRIBE THE ISSUE IN DETAIL:
We're seeing some issues where developers are not able to build the project after moving classes around. Although there are multiple cases where this seems to happen the easiest repro we found was starting off with a project that defines two library projects with the same
packageName
, then building, then changing the package name and then trying to build again. In this case theBuildConfig
class of the original package name as well as the new package exist in the final apk located inapp/build/intermediates/apk/debug/app-debug.apk
Software/Hardware
Android Studio Bumblebee 2021.1.1 Android Gradle Plugin 7.1.1 Gradle 7.4 OS: Mac OS 10.15.7
STEPS TO REPRODUCE:
app/build/intermediates/apk/debug/app-debug.apk
to see that it contains just 4 classescom.example.app.BuildConfig
,com.example.app.R
,com.example.lib.BuildConfig
andcom.example.lib.R
lib/src/main/AndroidManifest.xml
tocom.example.lib.a
.app/build/intermediates/apk/debug/app-debug.apk
again it now contain 6 class files, aBuildConfig
in each of the packagescom.example.app
,com.example.lib
andcom.example.lib.a
You'll also see that a
dex
file exists for bothBuildConfig
classes inlib/build/.transforms
as in the attached screenshotStudio Build: 2021.1.1 Version of Gradle Plugin: 7.1.1 Version of Gradle: 7.4 Version of Java: 11 OS: MacOS 10.15.7