Issue
Can't deploy to Android 11 emulator. (I can deploy to Android 10 emulator)
ADB0010: Deployment failed
Mono.AndroidTools.InstallFailedException: The package was not properly signed (NO_CERTIFICATES).
at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName)
at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass97_0.<InstallPackage>b__0(Task`1 t)
at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at AndroidDeviceExtensions.<PushAndInstallPackage>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at AndroidDeviceExtensions.<PushAndInstallPackage>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Xamarin.AndroidTools.AndroidDeploySession.<InstallPackage>d__116.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Xamarin.AndroidTools.AndroidDeploySession.<RunAsync>d__110.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xamarin.AndroidTools.AndroidDeploySession.<RunLoggedAsync>d__108.MoveNext()
This is a debug build, so I'm not explicitly signing it.
But I notice that it's automatically being signed anyway with an androiddebugkey:
C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\bin\jarsigner.exe -keystore "C:\Users\$USERNAME$\AppData\Local\Xamarin\Mono for Android\debug.keystore" -storepass android -keypass android -digestalg SHA-256 -sigalg SHA256withRSA -signedjar bin\Debug\$UNSIGNEDAPKNAME$.apk $PATHTOAPK$.apk androiddebugkey
In case debug.keystore, was somehow out of date, (mine was timestamped 2018-03-26), I removed it and it got regenerated by the build. (with reasonable sized differences), But I still received the "Mono.AndroidTools.InstallFailedException: The package was not properly signed (NO_CERTIFICATES)."
error.
I've tried cleaning and rebuilding. I'm targeting Android 11.0 (API Level 30 -R)
Update:
I received a little more information when I manually attempting to installing with adb:
adb -e install $myapp$.apk
...
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES: Scanning Failed.: No signature found in package of version 2 or newer for package $PACKAGE$]
Solution
APK Signature Scheme v2 now required :
"Apps that target Android 11 (API level 30) that are currently only signed using APK Signature Scheme v1 must now also be signed using APK Signature Scheme v2 or higher. Users can't install or update apps that are only signed with APK Signature Scheme v1 on devices that run Android 11."
Signing with jarsigner.exe isn't good enough, when Targeting android 11. Signing with apksigner, includes the v2 scheme.
For example signing like this, using the same debug.keystore
allows the apk to be installed on android 11.
Manually signing
"C:\Program Files (x86)\Android\android-sdk\build-tools\30.0.2\apksigner.bat" sign -ks "C:\Users\%USERNAME%\AppData\Local\Xamarin\Mono for Android\debug.keystore" --ks-pass "pass:android" $APKNAME$.apk
Switching to apksigner via csproj file
The Xamarin build can be switched to apksigner, by adding <AndroidUseApkSigner>true</AndroidUseApkSigner>
to the csproj file. (I haven't found a way to do this in the UI. perhaps this is an experimental feature?)
You must be using a relatively new BuildTools version to do this eg:
<AndroidSdkBuildToolsVersion>28.0.3</AndroidSdkBuildToolsVersion>
Now the build signs the apk like this:
C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\bin\java.exe -jar "C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.3\lib\apksigner.jar" sign --ks "C:\Users\%USERNAME%\AppData\Local\Xamarin\Mono for Android\debug.keystore" --ks-pass pass:android --ks-key-alias androiddebugkey --key-pass pass:android --min-sdk-version 22 --max-sdk-version 30 $APKNAME$
Answered By - Tom
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.