Deploy to Android 4.2 Mutil-User Device

TeHaTeHa DEMember ✭✭✭

Hey folks,

I've got a greate question for friday afternoon:
I updated my Nexus 7 to Android 4.2 and created some different users - just for testing/playing aroud. Now MfA still detect the device so that I can deploy my app, but after successfully deployment process VS10 shows the message:
"The application could not be started. Ensure that the application has been installed to the target device and has a launchable activity. Additionally, check Build->Configuration Manager to ensure this project is set to Deploy for this configuration."

I think that has something to do with new multi-user-android? And it will be fixed with new MfA version that support android 4.2, or am I wrong with this issue

Posts

  • JonathanPryorJonathanPryor USXamarin Team Xamurai
    edited November 2012

    Summary

    When deploying a Mono for Android Debug application to an Android 4.2 ("Jelly Bean") device, the current user on the Android device needs to have admin privileges.

    Deployment of Mono for Android Debug applications works as expected (for me) if the current user on the Android device is the owner/has admin privileges.

    Background

    As the proud new possessor of a Nexus 10, I can now test Android 4.2 behavior 1. The good news is that I can reproduce this:

    1. Take your shiny new Android 4.2 device.
    2. (Optional?) Enable developer access.
    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) is where things fail:

    $ xbuild /t:Install *.csproj /v:diag
    ...
    Task "InstallPackageAssemblies"
        ...
        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.
          at Xamarin.AndroidTools.AndroidDeploySession.WaitForRemoteDirCreation (System.String destinationPath, CancellationToken token) [0x00000] in <filename unknown>:0 
          at Xamarin.AndroidTools.AndroidDeploySession.InstallAssemblies (System.String destinationPath, CancellationToken token) [0x00000] in <filename unknown>:0 
    /Library/Frameworks/Mono.framework/External/xbuild/Novell/Novell.MonoDroid.Common.targets: error : The assembly directory could not be created.
    /Library/Frameworks/Mono.framework/External/xbuild/Novell/Novell.MonoDroid.Common.targets: error : The assembly directory could not be created.  at Xamarin.AndroidTools.AndroidDeploySession.WaitForRemoteDirCreation (System.String destinationPath, CancellationToken token) [0x00000] in <filename unknown>:0 
      at Xamarin.AndroidTools.AndroidDeploySession.InstallAssemblies (System.String destinationPath, CancellationToken token) [0x00000] in <filename unknown>:0 
    Done executing task "InstallPackageAssemblies"
    

    What would previously happen is that we'd try to launch an Activity, which would "fail" (because no assemblies were present to execute) but had the side effect of creating the directory which would hold the assemblies. Then we'd launch the Seppuku receiver which would exit the app, we'd copy over the assemblies, and then the app could be launched normally.

    This (slightly ;-) bizarre process appears to no longer work as intended on Android 4.22, at least not initially. However, if I then re-try, it works:

    $ xbuild /t:Install *.csproj /v:diag
    Build succeeded.
         0 Warning(s)
         0 Error(s)
    

    So we're good, right? Just run it twice?

    No. The problem is that the first ("known bad") execution is still running, and won't exit, and we can't properly load the app until the initial process exits.

    Unfortunately, I can't think of any way to get the process to exit that doesn't rely on Developer options of some form, and non-admin users can't enable Developer options (at least, not on my device).


    1. I'm keeping my Galaxy Nexus on Android 4.1 for test purposes. ↩︎

    2. It looks like the Seppuku receiver is no longer able to exit the process. :-/

      Guess we'll need to figure out (again!) how to get processes to fully exit... ↩︎

  • MaxPavlovMaxPavlov USMember ✭✭

    @JonathanPryor, do you mean the 4.2.2 device has to be rooted to be able to debug the application?

  • JonathanPryorJonathanPryor USXamarin Team Xamurai

    do you mean the 4.2.2 device has to be rooted to be able to debug the application?

    No. I mean that you can only run Debug apps 1 for the first (primary, admin) user on the Android device, because that's the only user which has a /data/data/@[email protected]/files directory that's readable/writable. All other users get a different "Files directory", and since the Files directory is where the fast deployment assemblies are kept... ;-)

    We could fix this, but it isn't currently deemed a high enough priority to work on fixing it anytime soon.

    You should be able to deploy, run, and debug if you disable Fast Deployment.


    1. $(EmbedAssembliesIntoApk)==False, aka "fast deployment" enabled. ↩︎

Sign In or Register to comment.