Skip to content

error: class drawable is already defined in class R #5686

@LeoJHarris

Description

@LeoJHarris

For some reason there are duplicate class definitions for drawable and string in the R.java. When I build the Binding Library project it builds fine but when I add it as a reference to my consuming Xamarin.Android project I get build failed as per below.... both projects can build fine when there is no reference from the consuming project to the library. To my knowledge I have not changed or altered the .aar file and simply downloaded it from from the public URL of the native android SDK location. I am not sure if this is a bug on my end or Xamarin.Android but I don't know why duplicates exist in the R,java file but please advise.

Steps to Reproduce

  1. Create an android binding library
  2. Add the specified .aar file to the jar folder and change build libraryprojectzip
  3. Build the binding library
  4. Add binding library as reference to consuming android application project
  5. Try to build solution - fails

Sample repo
TestBinding.zip

Attached screen of the build failed and there are duplicate class for drawable in R.java but why??

Capture

The aar to be used is already in the jars folder called "card-entry-1.5.0_old.aar" but can also be downloaded from here: https://sdk.squareup.com/public/android/com/squareup/sdk/in-app-payments/card-entry/1.5.0/

Expected Behavior

The project to build

Actual Behavior

Project build fails

Version Information

Microsoft Visual Studio Community 2019
Version 16.9.0
VisualStudio.16.Release/16.9.0+31025.194
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Community

ASP.NET and Web Tools 2019 16.9.687.37626
ASP.NET and Web Tools 2019

ASP.NET Core Razor Language Services 16.1.0.2107702+c4adaa061f13292143de82a96c71341e50bc4032
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2019 16.9.687.37626
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 16.9.687.37626
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools 16.9.687.37626
Azure Functions and Web Jobs Tools

C# Tools 3.9.0-6.21124.20+db94f4cc8c78a7cd8cf9cfdae091158d2ba9d974
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

CleanBinAndObjCommand Extension 1.1.1
CleanBinAndObjCommand Visual Studio Extension Detailed Info

Clear MEF Component Cache 1.4
Clears the Visual Studio MEF component cache to fix issues with cache corruption.

Code alignment 14.1.107.0
Code alignment helps you present your code beautifully, enhancing clarity and readability.

CodeMaid 11.2.231
CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, R, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

ConfigureAwaitEnforcerOptions Extension 1.0
ConfigureAwaitEnforcerOptions Visual Studio Extension Detailed Info

Conveyor by Keyoti 1.0
Allows you to access your web applications from other machines, even if hosted on the development web server.

CreateUnitTestBoilerplateCommand Extension 1.0
CreateUnitTestBoilerplateCommand Visual Studio Extension Detailed Info

Extensibility Message Bus 1.2.6 (master@34d6af2)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

File Icons 2.7
Adds icons for files that are not recognized by Solution Explorer

GitHub.VisualStudio 2.11.106.19330
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

Infragistics Toolbox 2.0.7
A toolbox for the Infragistics controls referenced from NuGet packages.

IntelliCode Extension 1.0
IntelliCode Visual Studio Extension Detailed Info

IntelliSenseExtenderPackage Extension 1.0
IntelliSenseExtenderPackage Visual Studio Extension Detailed Info

Markdown Editor 1.12.253
A full featured Markdown editor with live preview and syntax highlighting. Supports GitHub flavored Markdown.

Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.40218.1

Microsoft Continuous Delivery Tools for Visual Studio 0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager 2.1.113+g422d40002e.RR
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Mono Debugging for Visual Studio 16.9.7 (df23ba6)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 5.9.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

Sharpen 0.10.1
Sharpen is a Visual Studio extension that intelligently introduces new C# language features into your existing code base. It makes your code smaller, simpler, faster, more expressive and more readable, in one word - sharper.

SQL Server Data Tools 16.0.62102.01130
Microsoft SQL Server Data Tools

StylerPackage Extension 1.0
StylerPackage Visual Stuido Extension Detailed Info

TypeScript Tools 16.0.30201.2001
TypeScript Tools for Microsoft Visual Studio

Viasfora 4.3.195
Add color to your Visual Studio editor!

Visual Basic Tools 3.9.0-6.21124.20+db94f4cc8c78a7cd8cf9cfdae091158d2ba9d974
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 16.9.0-beta.21102.9+7ce7132f1459095e635194d09d6f73265352029a
Microsoft Visual F# Tools

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Container Tools Extensions 1.0
View, manage, and diagnose containers within Visual Studio.

Visual Studio File Histories 2.4.2
Maintains the history of all files saved in Visual Studio

Visual Studio Spell Check Everywhere VSSpellCheckEverywhere
An extension that enables spell checking within any Visual Studio file editor or tool window that uses WPF text boxes.
https://GitHub.com/EWSoftware/VSSpellChecker

Visual Studio Spell Checker VSSpellChecker
An editor extension that checks the spelling of comments, strings, and plain text as you type or interactively with tool windows.
https://GitHub.com/EWSoftware/VSSpellChecker

Visual Studio Tools for Containers 1.0
Visual Studio Tools for Containers

VisualStudio.DeviceLog 1.0
Information about my package

VisualStudio.Mac 1.0
Mac Extension for Visual Studio

VSColorOutput 2.73
Color output for build and debug windows - https://mike-ward.net/vscoloroutput

Xamarin 16.9.000.271 (d16-9@863670b)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 16.9.0.316 (remotes/origin/d16-9@fdbf64026)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 16.9.68 (8e9b569)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 11.2.0.21 (d16-9/93eab59)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: 5e9cb6d
Java.Interop: xamarin/java.interop/d16-9@d6d86b2
ProGuard: Guardsquare/proguard@912d149
SQLite: xamarin/sqlite@daff8f4
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-9@9d8924d

Xamarin.iOS and Xamarin.Mac SDK 14.14.2.5 (3836759d4)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

XamlFormatter 1.0
Formats Xaml the way I want it formatted. Focusing entirely on spacing and leaving the decision of what belongs on what line up to you.

Error log below

Build started...
1>------ Build started: Project: Test, Configuration: Debug Any CPU ------
1>  Test -> C:\Users\SquareBindingsPOC\TestBinding\Test\bin\Debug\Test.dll
1>  obj\Debug\100\android\src\sqip\cardentry\R.java:102: error: class drawable is already defined in class R
1>  	public static final class drawable {
1>  	                    ^
1>  obj\Debug\100\android\src\sqip\cardentry\R.java:164: error: class string is already defined in class R
1>  	public static final class string {
1>  	                    ^
1>  Note: Some input files use or override a deprecated API.
1>  Note: Recompile with -Xlint:deprecation for details.
1>  Note: Some input files use unchecked or unsafe operations.
1>  Note: Recompile with -Xlint:unchecked for details.
1>  2 errors
1>C:\Users\SquareBindingsPOC\TestBinding\Test\obj\Debug\100\android\src\sqip\cardentry\R.java(102,22): javac.exe error JAVAC0000:  error: class drawable is already defined in class R
1>C:\Users\SquareBindingsPOC\TestBinding\Test\obj\Debug\100\android\src\sqip\cardentry\R.java(102,22): javac.exe error JAVAC0000: 	public static final class drawable {
1>C:\Users\SquareBindingsPOC\TestBinding\Test\obj\Debug\100\android\src\sqip\cardentry\R.java(102,22): javac.exe error JAVAC0000: 
1>C:\Users\SquareBindingsPOC\TestBinding\Test\obj\Debug\100\android\src\sqip\cardentry\R.java(164,22): javac.exe error JAVAC0000:  error: class string is already defined in class R
1>C:\Users\SquareBindingsPOC\TestBinding\Test\obj\Debug\100\android\src\sqip\cardentry\R.java(164,22): javac.exe error JAVAC0000: 	public static final class string {
1>C:\Users\SquareBindingsPOC\TestBinding\Test\obj\Debug\100\android\src\sqip\cardentry\R.java(164,22): javac.exe error JAVAC0000: 
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++                 Please consider donating to VSColorOutput                    +++
+++                       https://mike-ward.net/donate/                          +++
+++            (this message can be turned off in the settings panel)            +++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
```csharp

Metadata

Metadata

Assignees

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions