Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Briefcase Does Not Detect Failure to Install an APK on an Android version which is too old #1157

Closed
rmartin16 opened this issue Mar 30, 2023 · 3 comments · Fixed by #1378
Closed
Labels
android The issue relates to Android mobile support. bug A crash or error in behavior. good first issue Is this your first time contributing? This could be a good place to start!

Comments

@rmartin16
Copy link
Member

rmartin16 commented Mar 30, 2023

Describe the bug

During briefcase run android, the attempt to install the APK on the device can fail if the API level of the APK is beyond what the device can support. Briefcase does not detect this error and eventually errors out when attempting to run the app.

           >>> Running Command:                                                                                                                                    subprocess.py:665
           >>>     'C:\Users\domin\AppData\Local\BeeWare\briefcase\Cache\tools\android_sdk\platform-tools\adb.exe' -s PLI5T31F7E install -r                        subprocess.py:666
           'C:\Users\domin\beeware-tutorial\smartmirrortab\android\gradle\SmartMirrorTab\app\build\outputs\apk\debug\app-debug.apk'                                                 
           >>> Working Directory:                                                                                                                                  subprocess.py:673
           >>>     C:\Users\domin\beeware-tutorial\smartmirrortab                                                                                                  subprocess.py:674
[17:31:11] >>> Command Output:                                                                                                                                     subprocess.py:690
           >>>     Performing Push Install                                                                                                                         subprocess.py:692
           >>>     C:\Users\domin\beeware-tutorial\smartmirrortab\android\gradle\SmartMirrorTab\app\build\outputs\apk\debug\app-debug.apk: 1 file pushed, 0        subprocess.py:692
           skipped. 5.5 MB/s (33125287 bytes in 5.768s)                                                                                                                             
           >>>             pkg: /data/local/tmp/app-debug.apk                                                                                                      subprocess.py:692
           >>>                                                                                                                                                     subprocess.py:692
           >>>     Failure [INSTALL_FAILED_OLDER_SDK]                                                                                                              subprocess.py:692
           >>>                                                                                                                                                     subprocess.py:692
           >>> Return code: 0                                                                                                                                      subprocess.py:701
           Installing new app version... done                                                                                                                          gradle.py:336
                                                                                                                                                                   subprocess.py:664
           >>> Running Command:                                                                                                                                    subprocess.py:665
           >>>     'C:\Users\domin\AppData\Local\BeeWare\briefcase\Cache\tools\android_sdk\platform-tools\adb.exe' -s PLI5T31F7E shell am start                    subprocess.py:666
           com.example.smartmirrortab/org.beeware.android.MainActivity -a android.intent.action.MAIN -c android.intent.category.LAUNCHER                                            
           >>> Working Directory:                                                                                                                                  subprocess.py:673
           >>>     C:\Users\domin\beeware-tutorial\smartmirrortab                                                                                                  subprocess.py:674
           >>> Command Output:                                                                                                                                     subprocess.py:690
           >>>     Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]                                                        subprocess.py:692
           cmp=com.example.smartmirrortab/org.beeware.android.MainActivity }                                                                                                        
           >>>                                                                                                                                                     subprocess.py:692
           >>>     Error type 3                                                                                                                                    subprocess.py:692
           >>>                                                                                                                                                     subprocess.py:692
           >>>     Error: Activity class {com.example.smartmirrortab/org.beeware.android.MainActivity} does not exist.                                             subprocess.py:692
           >>>                                                                                                                                                     subprocess.py:692
           >>> Return code: 0                                                                                                                                      subprocess.py:701
[17:31:12] Launching app...                                                                                                                                            gradle.py:355
                                                                                                                                                                      __main__.py:30
           Activity class not found while starting app.                                                                                                               __main__.py:31
                                                                                                                                                                      __main__.py:31
           `adb` output:                                                                                                                                              __main__.py:31
                                                                                                                                                                      __main__.py:31
               Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]                                                               __main__.py:31
           cmp=com.example.smartmirrortab/org.beeware.android.MainActivity }                                                                                                        
                                                                                                                                                                      __main__.py:31
           Error type 3                                                                                                                                               __main__.py:31
                                                                                                                                                                      __main__.py:31
           Error: Activity class {com.example.smartmirrortab/org.beeware.android.MainActivity} does not exist.                                                        __main__.py:31

Steps to reproduce

Attempt briefcase run android with a device running Android 4.

Expected behavior

Briefcase should detect the failure to install the APK and inform the user as such.

Screenshots

No response

Environment

  • Operating System: Windows 10
  • Python version: Python 3.8
  • Software versions:
    • Briefcase: 0.3.12

Logs

briefcase.2023_03_30-17_31_12.run.log

Additional context

Reported in discord.

@rmartin16 rmartin16 added bug A crash or error in behavior. android The issue relates to Android mobile support. labels Mar 30, 2023
@mhsmith
Copy link
Member

mhsmith commented Mar 30, 2023

I've noticed this before: I think the root cause is actually the installer process running on the device, which incorrectly returns 0 on failure in old versions of Android. So the only way Briefcase could work around this is to parse the text in the output.

Since our minimum API level is compatible with over 90% of active devices (beeware/rubicon-java#74 (comment)), I don't think this is worth fixing unless someone is particularly interested in it.

@mhsmith mhsmith changed the title Android / Briefcase Does Not Detect Failure From Attempting to Install an APK on to an Unsupported Device Briefcase Does Not Detect Failure to Install an APK on an Android version which is too old Mar 30, 2023
@freakboy3742
Copy link
Member

I agree it wouldn't be worth doing major invasive work to accomodate this edge case. However:

  1. I'm not convinced it would be major invasive work. The call to adb install -r is effectively a check_output() call where we're ignoring the output; running a regex over the output to look for Failure [(.*)] and raising an appropriate error shouldn't be too difficult.
  2. If there's some complication that I'm not seeing, then at the very least we should add a FAQ entry about minimum supported Android versions, and a note in the Android docs about how this problem (and other Android deployment issues) manifests.

On that basis, I'm going to flag this as a candidate for first timers - it's not a high priority, but it shouldn't be too hard to narrow down whether this is trivial or impossible.

@freakboy3742 freakboy3742 added the good first issue Is this your first time contributing? This could be a good place to start! label Mar 30, 2023
@MN193
Copy link
Contributor

MN193 commented Jul 22, 2023

I just wanted to note, that I'm working on this error at EuroPython 2023 sprints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android The issue relates to Android mobile support. bug A crash or error in behavior. good first issue Is this your first time contributing? This could be a good place to start!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants