dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.94k stars 533 forks source link

R8 : error : Program type already present when using preview builds #4648

Closed PureWeen closed 4 years ago

PureWeen commented 4 years ago

Steps to Reproduce

I'm running these builds on the current public preview

Microsoft (R) Build Engine version 16.6.0-preview-20222-04+b4f75bf75 for .NET Framewor

  1. pull down the following branch of Xamarin.Forms https://github.com/xamarin/Xamarin.Forms/tree/consolidate_build
  2. Download the nuget artifacts from here https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3691948&view=artifacts&type=publishedArtifacts
  3. Place the nugets wherever your msbuild commands will look for local packages or add a nuget.config file to the root folder pointing to that location
  4. Run the following command

msbuild build.proj /t:CI-Build-Android /p:Configuration=Debug /p:XamarinFormsVersion=4.7.0.159 /p:ANDROID_RENDERERS=LEGACY /bl

Which form me yields the following exception

"H:\github\Xamarin.Forms\build.proj" (CI-Build-Android target) (1) ->
"H:\github\Xamarin.Forms\Xamarin.Forms.ControlGallery.Android\Xamarin.Forms.ControlGallery.Android.csproj" (Build;SignAndroidPackage target) (6:6) ->
(_CompileToDalvik target) ->
  R8 : error : Program type already present: com.google.android.gms.auth.api.signin.GoogleSignInOptionsExtension [H:\github\Xamarin.Forms\Xamarin.Forms.ControlGallery.Android\Xama
rin.Forms.ControlGallery.Android.csproj]

When I run this same command on Stable I get a different exception

(_UpdateAndroidResgen target) ->
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1565,2): error XA0000: Unhandled exception: System.IO.IOException: The process cannot access the file 'H:\github\Xamarin.Forms\Xamarin.Forms.ControlGallery.Android\obj\Debug\100\android\src\com\google\android\gms\common\R.java' because it is being used by another process. [H:\github\Xamarin.Forms\Xamarin.
Forms.ControlGallery.Android\Xamarin.Forms.ControlGallery.Android.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1565,2): error XA0000:    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) [H:\github\Xamarin.Forms\Xamarin.Forms.ControlGallery.Android\Xamarin.Forms.ControlGallery.Android.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1565,2): error XA0000:    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) [H:\github\
Xamarin.Forms\Xamarin.Forms.ControlGallery.Android\Xamarin.Forms.ControlGallery.Android.csproj]

You can also grab the binlogs from the following build

https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3691948&view=artifacts&type=publishedArtifacts

OSXArtifacts/android-legacy.binlog

Expected Behavior

Project should build

Actual Behavior

Project doesn't build

Version Information

Ping me on slack if you want/need this

Log File

Ping me on slack if you want/need this

jonathanpeppers commented 4 years ago

This error:

(_UpdateAndroidResgen target) ->
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1565,2): error XA0000: Unhandled exception: System.IO.IOException: The process cannot access the file 'H:\github\Xamarin.Forms\Xamarin.Forms.ControlGallery.Android\obj\Debug\100\android\src\com\google\android\gms\common\R.java' because it is being used by another process. [H:\github\Xamarin.Forms\Xamarin.
Forms.ControlGallery.Android\Xamarin.Forms.ControlGallery.Android.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1565,2): error XA0000:    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) [H:\github\Xamarin.Forms\Xamarin.Forms.ControlGallery.Android\Xamarin.Forms.ControlGallery.Android.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1565,2): error XA0000:    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) [H:\github\
Xamarin.Forms\Xamarin.Forms.ControlGallery.Android\Xamarin.Forms.ControlGallery.Android.csproj]

Means you are using Xamarin.Build.Download 0.7.x, I can see 0.7.1 in the build log.

I would use the latest 0.10.0.

I think it could actually be causing both issues, can you update it and let us know? Thanks!

PureWeen commented 4 years ago

@jonathanpeppers that looks like it fixed it!!