Skip to content

[HelloWorld] Fix app install #9822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2025
Merged

Conversation

jonpryor
Copy link
Contributor

When I try installing samples/HelloWorld, installation fails:

./dotnet-local.sh build -t:Install samples/HelloWorld/HelloWorld/HelloWorld.DotNet.csproj
  HelloWorld.DotNet failed with 2 error(s) (139.4s) → samples/HelloWorld/HelloWorld/bin/Debug/net10.0-android/HelloWorld.DotNet.dll
    /Users/jon/Developer/src/dotnet/android/bin/Debug/lib/packs/Microsoft.Android.Sdk.Darwin/35.99.0/tools/Xamarin.Android.Common.targets(2824,3): error MSB6006: "adb" exited with code 1.
    /Users/jon/Developer/src/dotnet/android/bin/Debug/lib/packs/Microsoft.Android.Sdk.Darwin/35.99.0/tools/Xamarin.Android.Common.targets(2824,3): error XAAADB0000:
      Serving...
      All files should be loaded. Notifying the device.
      adb: failed to install bin/Debug/net10.0-android/com.xamarin.android.helloworld-Signed.apk: Failure [INSTALL_FAILED_VERIFICATION_FAILURE: Install not allowed for file
      :///data/app/vmdl911578471.tmp]
      Performing Incremental Install
      Failure [INSTALL_FAILED_DEPRECATED_SDK_VERSION: App package must target at least SDK version 24, but found 21]
      Performing Streamed Install

If I look at the device screen, it shows a dialog:

⛨ Google Play Protect
Unsafe app blocked
⬣ HelloWorld
This app was built for an older version of Android and doesn't
include the latest privacy protections
More options ˯
Installing this app may put your device at risk.
Learn more about Play Protect
[Install anyway]
[Got it]

Developer Guidance for Google Play Protect Warnings states:

Reason for this notification: These Play Protect warnings will
show only if the app's targetSdkVersion is more than 2 versions
lower than the current Android API level.

Updating Properties/AndroidManifest.xml to remove the <uses-sdk/> element allows .NET for Android to use its default logic, causing the "final" AndroidManifest.xml to contain:

<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="35" />

This allows the app to install without error:

% ./dotnet-local.sh build -t:Install samples/HelloWorld/HelloWorld/HelloWorld.DotNet.csproj
Restore complete (1.9s)
  HelloLibrary.DotNet succeeded (1.5s) → samples/HelloWorld/HelloLibrary/bin/Debug/net10.0-android/HelloLibrary.DotNet.dll
  HelloLibrary.DotNet succeeded (0.1s) → samples/HelloWorld/HelloLibrary/bin/Debug/net10.0-android/HelloLibrary.DotNet.dll
  HelloWorld.DotNet succeeded (52.9s) → samples/HelloWorld/HelloWorld/bin/Debug/net10.0-android/HelloWorld.DotNet.dll

Build succeeded in 57.8s

When I try installing `samples/HelloWorld`, installation fails:

	./dotnet-local.sh build -t:Install samples/HelloWorld/HelloWorld/HelloWorld.DotNet.csproj
	  HelloWorld.DotNet failed with 2 error(s) (139.4s) → samples/HelloWorld/HelloWorld/bin/Debug/net10.0-android/HelloWorld.DotNet.dll
	    /Users/jon/Developer/src/dotnet/android/bin/Debug/lib/packs/Microsoft.Android.Sdk.Darwin/35.99.0/tools/Xamarin.Android.Common.targets(2824,3): error MSB6006: "adb" exited with code 1.
	    /Users/jon/Developer/src/dotnet/android/bin/Debug/lib/packs/Microsoft.Android.Sdk.Darwin/35.99.0/tools/Xamarin.Android.Common.targets(2824,3): error XAAADB0000:
	      Serving...
	      All files should be loaded. Notifying the device.
	      adb: failed to install bin/Debug/net10.0-android/com.xamarin.android.helloworld-Signed.apk: Failure [INSTALL_FAILED_VERIFICATION_FAILURE: Install not allowed for file
	      :///data/app/vmdl911578471.tmp]
	      Performing Incremental Install
	      Failure [INSTALL_FAILED_DEPRECATED_SDK_VERSION: App package must target at least SDK version 24, but found 21]
	      Performing Streamed Install

If I look at the device screen, it shows a dialog:

> ⛨ Google Play Protect
> **Unsafe app blocked**
> ⬣ HelloWorld
> This app was built for an older version of Android and doesn't
> include the latest privacy protections
> More options ˯
> Installing this app may put your device at risk.
> Learn more about Play Protect
> [Install anyway]
> [**Got it**]

[Developer Guidance for Google Play Protect Warnings][0] states:

> **Reason for this notification**: These Play Protect warnings will
> show only if the app's [targetSdkVersion][1] is more than 2 versions
> lower than the current Android API level.

Updating `Properties/AndroidManifest.xml` to *remove* the
`<uses-sdk/>` element allows .NET for Android to use its default
logic, causing the "final" `AndroidManifest.xml` to contain:

	<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="35" />

This allows the app to install without error:

	% ./dotnet-local.sh build -t:Install samples/HelloWorld/HelloWorld/HelloWorld.DotNet.csproj
	Restore complete (1.9s)
	  HelloLibrary.DotNet succeeded (1.5s) → samples/HelloWorld/HelloLibrary/bin/Debug/net10.0-android/HelloLibrary.DotNet.dll
	  HelloLibrary.DotNet succeeded (0.1s) → samples/HelloWorld/HelloLibrary/bin/Debug/net10.0-android/HelloLibrary.DotNet.dll
	  HelloWorld.DotNet succeeded (52.9s) → samples/HelloWorld/HelloWorld/bin/Debug/net10.0-android/HelloWorld.DotNet.dll

	Build succeeded in 57.8s

[0]: https://developers.google.com/android/play-protect/warning-dev-guidance
[1]: https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#target
@jonpryor
Copy link
Contributor Author

The warning message I saw:

Google Play Protect- HelloWorld

@jonpryor jonpryor merged commit f370b72 into main Feb 21, 2025
58 checks passed
@jonpryor jonpryor deleted the dev/jonp/jonp-fix-HelloWorld-install branch February 21, 2025 20:20
@github-actions github-actions bot locked and limited conversation to collaborators Mar 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants