<h1 dir="auto">Summary</h1>
<p dir="auto">Basically, if you have multiple users on an android phone, flutter deploys sometimes to the wrong user account. Unless you switch accounts, this looks like the deploy totally failed.</p>
<h2 dir="auto">Steps to Reproduce</h2>
<ol dir="auto">
<li>Setup an Android phone with multiple accounts</li>
<li>Build a flutter app</li>
<li>do a "flutter run"</li>
<li>flutter seems to hang, nothing happens (if actually used user has not logged in yet) or flutter seems to run but no app appears on phone (because it gets installed to an other account)<br>
When checking the App via "Settings/memory/other apps" it sometimes says "not available for user".</li>
</ol>
<h2 dir="auto">Used hardware</h2>
<p dir="auto">BQ Aquaris X with Android 8.1.</p>
<h2 dir="auto">Output from flutter doctor -v</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Flutter (Channel beta, v0.11.3, on Microsoft Windows [Version 10.0.17134.345], locale de-DE)
    • Flutter version 0.11.3 at C:\tools\flutter
    • Framework revision 72bf075e8d (4 days ago), 2018-11-09 20:36:17 -0800
    • Engine revision 5646e86a6f
    • Dart version 2.1.0 (build 2.1.0-dev.9.3 9c07fb64c4)

[!] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at C:\Users\Oliver\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    X Android license status unknown.

[√] Android Studio (version 3.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 30.0.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[√] IntelliJ IDEA Community Edition (version 2018.2)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.2
    • Flutter plugin version 29.1.2
    • Dart plugin version 182.3569.4

[!] VS Code (version 1.28.2)
    • VS Code at C:\Users\Oliver\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (1 available)
    • Aquaris X • BJ106805 • android-arm64 • Android 8.1.0 (API 27)"><pre class="notranslate"><code class="notranslate">Flutter (Channel beta, v0.11.3, on Microsoft Windows [Version 10.0.17134.345], locale de-DE)
    • Flutter version 0.11.3 at C:\tools\flutter
    • Framework revision 72bf075e8d (4 days ago), 2018-11-09 20:36:17 -0800
    • Engine revision 5646e86a6f
    • Dart version 2.1.0 (build 2.1.0-dev.9.3 9c07fb64c4)

[!] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at C:\Users\Oliver\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    X Android license status unknown.

[√] Android Studio (version 3.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 30.0.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[√] IntelliJ IDEA Community Edition (version 2018.2)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.2
    • Flutter plugin version 29.1.2
    • Dart plugin version 182.3569.4

[!] VS Code (version 1.28.2)
    • VS Code at C:\Users\Oliver\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (1 available)
    • Aquaris X • BJ106805 • android-arm64 • Android 8.1.0 (API 27)
</code></pre></div>
<h2 dir="auto">Logs and explanation</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from flutter run --verbose:
&quot;executing: C:\Users\Oliver\AppData\Local\Android\sdk\platform-tools\adb -s BJ106805 shell am start -a
android.intent.action.RUN -f 0x20000000 --ez enable-background-compilation true --ez enable-dart-profiling true
klages.de.bla/klages.de.bla.MainActivity&quot;"><pre class="notranslate"><code class="notranslate">from flutter run --verbose:
"executing: C:\Users\Oliver\AppData\Local\Android\sdk\platform-tools\adb -s BJ106805 shell am start -a
android.intent.action.RUN -f 0x20000000 --ez enable-background-compilation true --ez enable-dart-profiling true
klages.de.bla/klages.de.bla.MainActivity"
</code></pre></div>
<p dir="auto">This is missing the --user parameter. From the ADB manual:<br>
"--user user_id | current: Specify which user to run as; if not specified, then run as the current user."</p>
<p dir="auto">"then run as current user " either doesn't work or the definition of current  user is not what i would expect :-)</p>
<p dir="auto">Internal: b/142944798</p>
<p dir="auto"><code class="notranslate">flutter run</code> cannot pass <code class="notranslate">--user</code> flag to adb launcher.</p>
<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/flutter/flutter/blob/8dd06a119015b1053df0b9af564e14684f7ca995/packages/flutter_tools/lib/src/android/android_device.dart#L414-L420">flutter/packages/flutter_tools/lib/src/android/android_device.dart</a>
    </p>
    <p class="mb-0 color-fg-muted">
        Lines 414 to 420
      in
      <a data-pjax="true" class="commit-tease-sha" href="/flutter/flutter/commit/8dd06a119015b1053df0b9af564e14684f7ca995">8dd06a1</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L414" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="414"></td>
          <td id="LC414" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> cmd <span class="pl-k">=</span> <span class="pl-en">adbCommandForDevice</span>(<span class="pl-k">&lt;</span><span class="pl-c1">String</span><span class="pl-k">&gt;</span>[ </td>
        </tr>

        <tr class="border-0">
          <td id="L415" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="415"></td>
          <td id="LC415" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-s">'shell'</span>, <span class="pl-s">'am'</span>, <span class="pl-s">'start'</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L416" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="416"></td>
          <td id="LC416" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-s">'-a'</span>, <span class="pl-s">'android.intent.action.RUN'</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L417" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="417"></td>
          <td id="LC417" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-s">'-f'</span>, <span class="pl-s">'0x20000000'</span>, <span class="pl-c">// FLAG_ACTIVITY_SINGLE_TOP</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L418" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="418"></td>
          <td id="LC418" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-s">'--ez'</span>, <span class="pl-s">'enable-background-compilation'</span>, <span class="pl-s">'true'</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L419" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="419"></td>
          <td id="LC419" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-s">'--ez'</span>, <span class="pl-s">'enable-dart-profiling'</span>, <span class="pl-s">'true'</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L420" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="420"></td>
          <td id="LC420" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> ]); </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">That means users can't select to launch their apps in work profile vs personal profile. This is critical for any enterprise app that needs to be tested in this mode.</p>
<p dir="auto">See work profile section in <a href="https://developer.android.com/studio/run/" rel="nofollow">https://developer.android.com/studio/run/</a>.</p>