Bug 8470 - Support Deploying to Android 4.2 with non-admin current user
Summary: Support Deploying to Android 4.2 with non-admin current user
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.5.x
Hardware: PC All
: Low normal
Target Milestone: 5.1
Assignee: Bugzilla
: 13836 ()
Depends on:
Reported: 2012-11-16 16:12 UTC by Jonathan Pryor
Modified: 2015-03-27 14:58 UTC (History)
5 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jonathan Pryor 2012-11-16 16:12:44 UTC
Context: http://forums.xamarin.com/discussion/comment/1303/#Comment_1303

It's not possible to deploy to a Mono for Android application to an Android 4.2 device which doesn't have an admin user as the current user. (Android 4.2 adds multi-user support; not all users are admins.)

1. Take your shiny new Android 4.2 device.
2. Enable developer access: https://twitter.com/jonpryor/status/269531642551476225
3. Create a new user in Settings > Accounts > Ad account
4. Make the device sleep (hit the power button).
5. Wake up the device (hit the power button).
6. Select your new (non-admin) user.
7. Try to install an app.

(7) fails: 

>    TASK: Broadcast am broadcast -a mono.android.intent.action.SEPPUKU -c mono.android.intent.category.SEPPUKU.Mono.Samples.SanityTests Mono.Samples.SanityTests/mono.android.Seppuku completed?:Broadcasting: Intent { act=mono.android.intent.action.SEPPUKU cat=[mono.android.intent.category.SEPP...
>    :Deployment failed
>    Xamarin.AndroidTools.AndroidDeploymentException: The assembly directory could not be created.

It appears to fail because the `Seppuku` task is no longer able to cause the process to exit. Looks like we need to re-engineer Debug/fastdev deployment.


/me weeps.
Comment 1 Jonathan Pryor 2013-03-14 13:57:45 UTC
> It appears to fail because the `Seppuku` task is no longer able to cause the process to exit.

It appears to be worse than that. The problem appears to be that Android will not send the broadcast to the process AT ALL when using `adb shell am broadcast` and the process is not started by the primary user.

I suspect that the only fix is to implement JDWP support and use the JDWP protocol to cause the process to exit.
Comment 2 Jonathan Pryor 2013-05-22 19:51:31 UTC
Causing the process to exit shouldn't be a problem as of 4.6.7, as we're using `adb shell am force-stop` to cause processes to exit.

However, Fast Deployment will be broken because we use the Seppuku task in order to create the fast deployment directory, so without `adb shell am broadcast` support Fast Deployment isn't possible.

Disabling Fast Deployment should allow the app to install, and thus is a workaround.
Comment 3 Jonathan Pryor 2013-05-22 19:51:54 UTC
Another workaround: Install/debug the app as the admin user.
Comment 4 Jonathan Pryor 2013-06-13 12:28:18 UTC
Comment #2 is apparently wrong, or at least not entirely right.

An (the?) issue is that each user gets a separate data directory. The fast deployment sync process assumes that it should sync with /data/data/@PACKAGE_NAME@/files/.__override__, but this is NOT the directory used for non-admin users. Instead, it's something like /data/user/10/Mono.Samples.HelloTests.

The correct directory can be obtained via android.content.pmPackageInfo -> applicationInfo.dataDir.
Comment 6 Jonathan Pryor 2013-08-07 21:57:20 UTC
*** Bug 13836 has been marked as a duplicate of this bug. ***
Comment 7 Jonathan Pryor 2015-02-11 17:22:12 UTC
Fixed in androidtools/2cb4c640 and monodroid/58d28ca9.

IDE's likewise need updates.
Comment 8 Daniel Cazzulino 2015-02-12 14:44:46 UTC
md-addins@master should bump its reference to androidtools to get this.

Not sure who to assign this to.
Comment 9 Jonathan Pryor 2015-03-16 11:41:27 UTC
@kzu: md-addins@master/410686c3 (2015-Feb-11) bumped the androidtools reference to androidtools/2cb4c640.

md-addins@monodevelop-5.9-branch was branched after the above commit, and thus md-addins@monodevelop-5.9-branch will contain the required fixes.