Build errors in .2419 when adding Android support library gradle references

When adding Android support libraries as Gradle references, I get hundreds of build errors. The debug build log and project zip are below. FWIW, in the project linked below, I referenced the libraries via the old com.android.support namespace, but the newer androidx namespace had the same results.

The errors are all along these lines:

E: Duplicate identifier “GradientColorItem_android_offset” [C:\…\EBuild\Obj\tests.annotations-DCF22A56CCE609933E210FD1F96CD59BA5A017C4\Debug\Cooper-Android\aar\transition-1.1.0\R.java (165)]

N: Previous declaration was here [C:\…\EBuild\Obj\tests.annotations-DCF22A56CCE609933E210FD1F96CD59BA5A017C4\Debug\Cooper-Android\r\androidx\transition\R.java (12169)]

Build Log: libs-out.txt (2.4 MB)
Project: tests.annotations.zip (349.9 KB)

Btw, “annotations” in the project title is a misnomer :slight_smile: I originally created the project to test something else. The project doesn’t use annotations/attributes/aspects anywhere.

Reproduced, will need to investigate tomorrow. Oddly, with Incremental there seem to be far fewer (of there same) errors. weird.

// Auto-generated by EBuild from animated-vector-drawable-28.0.0

package android.support.graphics.drawable;

it seems as if maybe the namespaces don’t match properly here…

Plot thickens:

AReference.Name support-vector-drawable-28.0.0
lManifestFile /Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/tests.annotations-EB700A5E573E5E18F28F20BBAD06EF8E66609DD3/Debug/Cooper-Android/aar/support-vector-drawable-28.0.0/AndroidManifest.xml
lXml.Root.Attribute["package"]:Value android.support.graphics.drawable

it looks like there’s two packages (android-support-graphics-drawable and animated-vector-drawable) with an R.txt file, and both packages specify the same namespace (package name) in their Manifest.xml. (android.support.graphics.drawable). I;'m tempted to say animated-vector-drawable-28.0.0 is simply broken or these two are incompatible and not supposed to be used together — but I’ll investigate more, tomorrow.

I doubt this would affect it, but Google did move all of their support libraries to a new namespace, androidx, because Google. This was probably two years ago? Maybe one. I forget when exactly. Details on the mapping between the two can be found here.

1 Like

Odd. I had 502 errors in either PreDex or Incremental on my Windows machine via Water.

That sounds to me like one should use the adroidx-named gradle reference names, too?

That’s the official recommendation. Google is still maintaining the old namespace, but all updates will be in the androidx namespace:

You can continue to use the support library. Historical artifacts (those versioned 27 and earlier, and packaged as android.support.* ) will remain available on Google Maven. However, all new library development will occur in the AndroidX library.

We recommend using the AndroidX libraries in all new projects. You should also consider migrating existing projects to AndroidX as well.

サポート ライブラリ  |  Android デベロッパー  |  Android Developers

Ok, does it work when you switch to those, or same error?

Same error

K. whats the exact set of references you have now?

In the uploaded project, these are the references:

com.android.support:support-v4:*
com.android.support:appcompat-v7:*
com.android.support:design:*
com.android.support:recyclerview-v7:*

RIght. but now you changed to androidx, what are the references now?

Ah, sorry:

androidx.legacy:legacy-support-v4:*
androidx.appcompat:appcompat:*
androidx.appcompat:appcompat-resources:*
com.google.android.material:material:*
androidx.recyclerview:recyclerview:*

Hmm, this one builds compiles clean for mew, Incremental. attaching my exact project, no other changes made on my side. But it fails with different DEX errors I’ll investigate:

E:                   dex: java.lang.IllegalArgumentException: already added: Landroidx/appcompat/content/res/AppCompatResources;
E:                   dex: java.lang.IllegalArgumentException: already added: Landroidx/appcompat/content/res/AppCompatResources$ColorStateListCacheEntry;
E:                   dex: java.lang.IllegalArgumentException: already added: Landroidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat;
E:                   dex: java.lang.IllegalArgumentException: already added: Landroidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat$1;
E:                   dex: java.lang.IllegalArgumentException: already added: Landroidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat$AnimatableTransition;
E:                   dex: java.lang.IllegalArgumentException: already added: Landroidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat$AnimatedStateListState;
E:                   dex: java.lang.IllegalArgumentException: already added: Landroidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat$AnimatedVectorDrawableTransition;
E:                   dex: java.lang.IllegalArgumentException: already added: Landroidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat$AnimationDrawableTransition;
E:                   dex: java.lang.IllegalArgumentException: already added: Landroidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat$FrameInterpolator;
E:                   dex: UNEXPECTED TOP-LEVEL EXCEPTION:

tests.annotations.elements (3.3 KB)

PreDex still has the 500+ errors, im assuming thats an unrelatedly issue to the wring namespace we discussed yesterday, and I’ll start investigating that one, as well.

Curious. for PreDex, apt generates R.java source files, so we end up with dupe copies. for non-przdex it doesn’t, so we end up just with the ones EBuild generates. If I drop mine, PreDex too compiles clean. Now to find out why this is inconsistent…

Same error in final dev, in both modes. “good”.

1 Like

Got it; processing AAPT ran a bit too early, for non-predex.

1 Like

Fixed cleanly now.

As for the dupe classes, it seems that these two packages contain the same classes. I’m guessing they aren’t meant top be used together:

                     dex> processing archive /Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/tests.annotations-EB700A5E573E5E18F28F20BBAD06EF8E66609DD3/Debug/Cooper-Android/aar/appcompat-resources-1.1.0-rc01/classes.jar...
                     dex> ignored resource META-INF/androidx.appcompat_appcompat-resources.version
                     dex> processing androidx/appcompat/content/res/AppCompatResources.class...
                     dex> processing androidx/appcompat/content/res/AppCompatResources$ColorStateListCacheEntry.class...
                     dex> processing androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat.class...
                     dex> processing androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat$1.class...
                     dex> processing androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat$AnimatableTransition.class...
                     dex> processing androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat$AnimatedStateListState.class...
                     dex> processing androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat$AnimatedVectorDrawableTransition.class...
                     dex> processing androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat$AnimationDrawableTransition.class...
                     dex> processing androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat$FrameInterpolator.class...
                     dex> processing androidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat$Transition.class...

                     dex> processing archive /Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/Gradle/androidx/lifecycle/lifecycle-common/2.0.0/lifecycle-common-2.0.0.jar...
...
E:                   dex: java.lang.IllegalArgumentException: already added: Landroidx/appcompat/content/res/AppCompatResources;
E:                   dex: java.lang.IllegalArgumentException: already added: Landroidx/appcompat/content/res/AppCompatResources$ColorStateListCacheEntry;
E:                   dex: java.lang.IllegalArgumentException: already added: Landroidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat;
E:                   dex: java.lang.IllegalArgumentException: already added: Landroidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat$1;
E:                   dex: java.lang.IllegalArgumentException: already added: Landroidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat$AnimatableTransition;
E:                   dex: java.lang.IllegalArgumentException: already added: Landroidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat$AnimatedStateListState;
E:                   dex: java.lang.IllegalArgumentException: already added: Landroidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat$AnimatedVectorDrawableTransition;
E:                   dex: java.lang.IllegalArgumentException: already added: Landroidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat$AnimationDrawableTransition;
E:                   dex: java.lang.IllegalArgumentException: already added: Landroidx/appcompat/graphics/drawable/AnimatedStateListDrawableCompat$FrameInterpolator;
E:                   dex: UNEXPECTED TOP-LEVEL EXCEPTION:
1 Like

Looks like you’re right. I added it to the test project assuming that Google had split the old appcompat-v7 into 2 parts, but the migration mapping only lists appcompat and not appcompat-resources.

1 Like

Cool. I’ll send you a new build once done, with the R.java fix. Do you use Water or VS, i forgot.

1 Like