After upgrading Visual Studio to 15.6, my Android build fails with the following error. Does anybody know how I can resolve this?
The problem is occurring no matter which device I am deploying to, so the arm64 that appears below is just one example - the others do it too.
AndroidZipAlign Task
Alignment: 4
Source: G:\tfs\MyApp\Top\MyApp.Android\obj\Debug\android\bin\com.MyApp.MyApp-arm64-v8a.apk
DestinationDirectory: bin\Debug\
C:\ProgramFiles\Android\AndroidSDK\build-tools\25.0.2\zipalign.exe 4 "G:\tfs\MyApp\Top\MyApp.Android\obj\Debug\android\bin\com.MyApp.MyApp-arm64-v8a.apk" "bin\Debug\com.MyApp.MyApp-arm64-v8a-Signed.apk"
Output file 'bin\Debug\com.MyApp.MyApp-arm64-v8a-Signed.apk' exists
"zipalign.exe" exited with code 1.
Done executing task "AndroidZipAlign" -- FAILED.
@batmaci - By trial and error, got the deploy working again.
It seems that using VS 15.6, the Android deploy will fail if "Generate one package (.apk) per selected ABI" is checked. Un-checking that gets it deploying again for me.
I've logged it as a bug at https://github.com/xamarin/Xamarin.Forms/issues/2243
Answers
Turned up the logging level to Diagnostics, and now see:
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICA...
DEBUG RunShellCommand 28d981dd rm "/data/local/tmp/com.MyApp.MyApp-Signed.apk"
TASK: DeleteFile rm "/data/local/tmp/com.MyApp.MyApp-Signed.apk" completed?:
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__DisplayClass94_0.b__0(Task
1 t) at System.Threading.Tasks.ContinuationTaskFromResultTask
1.InnerInvoke()at System.Threading.Tasks.Task.Execute()
The package was not properly signed (NO_CERTIFICATES).
at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName)
at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass94_0.b__0(Task
1 t) at System.Threading.Tasks.ContinuationTaskFromResultTask
1.InnerInvoke()at System.Threading.Tasks.Task.Execute()
Off to read the release notes to find out what has changed in 15.6 that would cause this...
@JohnHardman I am having the same issue. I thought it was support libraries 27 but obviously something to do with VS 15.6. it is pretty annoying, I need to delete obj, bin, tmp and restart VS every time, i want to test in release. Have you yet found something about it?
One other thing happes, after cleaning all those folders and restarting VS2017, i can deploy to my phone in release but app crashes at start up, when I check the error using android device manager, it shows that mainactivity is corrupted. If I remove already installed instance and redeploy, it works. I started worrying about package now if that is the case. we may upload a corrupted package or even a healthy package but existing users might get such error on update.
And this what you get when you create apk and try to upload on android store
@batmaci - No, not solved this yet. Had to spend a chunk of time sorting out the iOS build after upgrading VS to 15.6 . Android is next on the list. This has not been a pain-free upgrade :-(
@batmaci - By trial and error, got the deploy working again.
It seems that using VS 15.6, the Android deploy will fail if "Generate one package (.apk) per selected ABI" is checked. Un-checking that gets it deploying again for me.
I've logged it as a bug at https://github.com/xamarin/Xamarin.Forms/issues/2243
@batmaci - I agree - it's a workaround, but not an acceptable solution. Personally, I believe there are multiple errors around the Packaging properties in the Android Options. Working on a large app that requires Multi-Dex, for which I want to use ProGuard, and that needs to run on multiple different Android devices and versions, I have encountered many problems with Packaging properties. It feels like whenever I change a property to get everything working on one Android version/device, it breaks things on a different version/device. Not good.
Also people running into it here:
https://developercommunity.visualstudio.com/content/problem/210073/msb6006-zipalign-exited-with-code-1.html
Thanks @saltydog. I'm surprised that Google didn't list that when I tried searching before doing the trial & error route. Would have saved me some time.
Hey @JohnHardman
While this works, this is not necessarily needed.
You can re-check the "Generate one package (.apk) per selected ABI". Instead,
right click on the project > reveal in finder/windows equivalent to show where the project is > find and delete the
bin
andobj
folders > Close and reopen project in visual studio's.This allows you to build and deploy to the device without the zip align error.
However...... I am now having issues packaging the apk. Once packaged the apk is corrupt and will not install.
Here is my post on the Visual Studios for Mac forums
https://developercommunity.visualstudio.com/content/problem/224202/the-package-appears-to-be-corrupt-when-trying-to-i.html
they just pushed a new VS2017 with 15.6.5 version and all these trials dont work anymore. what are they seriously doing? and now weekend, we just should all abandon freaking xamarin development.
@batmaci - I've been on the verge of binning Xamarin.Forms for the last couple of years. With hindsight, for me, it was definitely the wrong toolset to use. Unfortunately, there was no way of knowing that in advance, and the comparative evaluation done about 3 years ago against Apache Cordova really didn't come to a conclusive result, so it was pretty much a flip of a coin back then. Do wish the coin had landed the other way up.
hi, It looks more stable for me on 15.6.7. what is your experience? I am always clearing bin and obj before i do archiving but even this one wasnt working for me in the previous version. how does to work for you?
I have this error. @JohnHardman - in my opinion you are right, this is a constant running around in a circle. Writing my app on a native android took much less time.
@batmaci - I'm still on 15.6.4 - now that I have a usable environment again, I'm avoiding upgrading until I really have to
I'm on all the latest and greatest on my mac as of May 3, 2018. I deleted the bin and obj folders, no love. I did a clean and rebuild, no love. I restarted my mac, no love. I went in and played with certificates on my system, no love and hope I didn't mess anything up there (finger's crossed). I unchecked the "Generate one package (.apk) per selected ABI" checkbox, and it is now deploying and working on my Android 6 device.
As for the right platform, I feel for everyone with this problem, and I get the issues that you guys have. It is very frustrating, incredibly frustrating. For me, I just wasn't going to learn a new platform and new language and new ide. that would have been too much for me to overcome. I've had to learn ios, android, and now forms. I could recognize Xam studio on the mac. I already knew c# and .net. It wasn't a hard conversion for me. forcing too much on me would have been too much and I would have just not.
Having the same Problem. I'm on VS 2017 15.6.7.
For me it works if I always clear the obj and bin folder of the android project before build and run the project on a device or simulator. But this is still annoying ....
@HannesGanthaler.6589 this is the problem. it was working before without doing these. they screwed release built on 15.6.5. using this version even clearing all those folder and rebuilding didnt help. you had to restart VS. then 15.6.6 came out with small improvement, you dont need to restart VS but you still have to clear. as @JohnHardman stated 15.6.4 just works fine without doing any of these.
yesterday i found another problem on VS 2017 Pre release, that release built doesnt work at all but I dont want to report that I am so tired of "can you give us a repo?"... as if I am their tester and have to spent my precious time to build repos for them. I mean if it was my own exception, i could understand that they are asking for something that is significant bug for everybody and i need to create repo and logs for them.
somebody some updates about this issue? I still have to sometimes clear obj and bin folder to get build and run the android project..
@HannesGanthaler.6589
no there is no fix yet. Xamarin people keep telling us that it is fixed but probably they are just fooling us. they even closed the github issue without solving it. for them this is not a prio 1 issue. And now another bug, see my message about 2nd paragraph, this bug went live on "Stable Release" with 15.7.0 and we are just stuck on development. see the issue below
https://github.com/xamarin/xamarin-android/issues/1651
this feature "bundle into native assemblies" option is only available on VS2017 premium(you can still use it changing cs.proj file manually) and they sold it as part of premium and they dont even test it and they dont fix it.