Skip to content

ArgumentException on binding Java library #10353

Closed

Description

@rgroenewoudt

Android framework version

net9.0-android

Affected platform version

17.14.10

Description

1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\35.0.78\tools\Xamarin.Android.Bindings.JavaDependencyVerification.targets(27,5): error XAJDV7004: System.ArgumentException: Value cannot be null or an empty string.
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\35.0.78\tools\Xamarin.Android.Bindings.JavaDependencyVerification.targets(27,5): error XAJDV7004: Parameter name: value
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\35.0.78\tools\Xamarin.Android.Bindings.JavaDependencyVerification.targets(27,5): error XAJDV7004:    at NuGet.Versioning.NuGetVersion.Parse(String value)
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\35.0.78\tools\Xamarin.Android.Bindings.JavaDependencyVerification.targets(27,5): error XAJDV7004:    at Xamarin.Android.Tasks.NuGetPackageVersionFinder.GetArtifactsInNugetPackage(String library, String version, TaskLoggingHelper log) in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/JavaDependencyVerification.cs:line 375
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\35.0.78\tools\Xamarin.Android.Bindings.JavaDependencyVerification.targets(27,5): error XAJDV7004:    at Xamarin.Android.Tasks.DependencyResolver.AddPackageReferences(ITaskItem[] tasks) in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/JavaDependencyVerification.cs:line 164
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\35.0.78\tools\Xamarin.Android.Bindings.JavaDependencyVerification.targets(27,5): error XAJDV7004:    at Xamarin.Android.Tasks.JavaDependencyVerification.RunTask() in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/JavaDependencyVerification.cs:line 77
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\35.0.78\tools\Xamarin.Android.Bindings.JavaDependencyVerification.targets(27,5): error XAJDV7004:    at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 25
1>Done building project "PdfViewer.csproj" -- FAILED.

Steps to Reproduce

New Android project:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net9.0-android</TargetFramework>
    <SupportedOSPlatformVersion>26</SupportedOSPlatformVersion>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <IsTrimmable>true</IsTrimmable>
  </PropertyGroup>
    <ItemGroup>
	    <AndroidMavenLibrary Include="com.github.bhuvaneshw.pdfviewer:ui" Version="1.1.1" Repository="https://jitpack.io/" />
    </ItemGroup>
</Project>

Same issue when using:

		<AndroidLibrary
			Update="ui-1.1.1.aar"
			Manifest="ui-1.1.1.pom"
			JavaArtifact="com.github.bhuvaneshw.pdfviewer:ui:1.1.1"
			JavaVersion="1.1.1" />

Did you find any workaround?

No response

Relevant log output

Activity

  1. added
    needs-triage
    on Jul 30, 2025
  2. jonathanpeppers commented on Jul 30, 2025

    @jonathanpeppers
    Member

    I tried dotnet new androidlib and added the package:

    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <TargetFramework>net9.0-android</TargetFramework>
        <SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
        <Nullable>enable</Nullable>
        <ImplicitUsings>enable</ImplicitUsings>
        <!--
          Enable trim analyzers for Android class libraries.
          To learn more, see: https://learn.microsoft.com/dotnet/core/deploying/trimming/prepare-libraries-for-trimming
        -->
        <IsTrimmable>true</IsTrimmable>
      </PropertyGroup>
      <ItemGroup>
        <AndroidMavenLibrary Include="com.github.bhuvaneshw.pdfviewer:ui" Version="1.1.1" Repository="https://jitpack.io/" />
      </ItemGroup>
    </Project>

    But I get errors with missing dependencies:

    Restore complete (0.4s)
      helloandroid failed with 4 error(s) (0.2s)
        C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\35.0.78\tools\Xamarin.Android.Bindings.JavaDependencyVerification.targets(27,5): error XA4242: Java dependency 'org.jetbrains.kotlin:kotlin-stdlib:2.1.20' is not satisfied. Microsoft maintains the NuGet package 'Xamarin.Kotlin.StdLib' that could fulfill this dependency.
        C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\35.0.78\tools\Xamarin.Android.Bindings.JavaDependencyVerification.targets(27,5): error XA4242: Java dependency 'androidx.core:core-ktx:1.16.0' is not satisfied. Microsoft maintains the NuGet package 'Xamarin.AndroidX.Core.Core.Ktx' that could fulfill this dependency.
        C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\35.0.78\tools\Xamarin.Android.Bindings.JavaDependencyVerification.targets(27,5): error XA4242: Java dependency 'androidx.appcompat:appcompat:1.7.0' is not satisfied. Microsoft maintains the NuGet package 'Xamarin.AndroidX.AppCompat' that could fulfill this dependency.
        C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\35.0.78\tools\Xamarin.Android.Bindings.JavaDependencyVerification.targets(27,5): error XA4241: Java dependency 'com.github.bhuvaneshw.pdfviewer:core:1.1.1' is not satisfied.
    

    Do you have a sample project that resolves the missing dependencies?

    Some of them could be fixed by adding <PackageReference/> as the error mentions.

  3. added
    need-info
    and removed
    needs-triage
    on Jul 30, 2025
  4. rgroenewoudt commented on Jul 31, 2025

    @rgroenewoudt
    Author

    Most of the time I don't get the missing dependencies message, just the ArgumentException. (randomly cleaning & rebuilding and sometimes the missing dependencies message shows)

    Same situation for dotnet build. It's difficult to fix the missing dependencies if I don't the message about missing them...

  5. added
    need-attention
    and removed
    need-info
    on Jul 31, 2025
  6. rgroenewoudt commented on Jul 31, 2025

    @rgroenewoudt
    Author

    Ah, if Central Package Management is enabled for the solution the ArgumentException shows up.
    Without CPM I don't have any issues

  7. jonathanpeppers commented on Jul 31, 2025

    @jonathanpeppers
    Member

    @rgroenewoudt can you share an example project?

    There might be a general bug with CPM + AndroidMavenLibrary item group.

  8. rgroenewoudt commented on Aug 4, 2025

    @rgroenewoudt
    Author
  9. added
    Area: App+Library Build
    and removed
    need-attention
    on Aug 4, 2025
  10. moved this from Todo to Consideration in .NET for Android Backlogon Aug 4, 2025
  11. added a commit that references this issue on Nov 16, 2026
    b084353
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: App+Library Build

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions