Skip to content

Instantly share code, notes, and snippets.

@fadookie
Last active September 21, 2022 08:56
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save fadookie/96cafaa4342ec32a43c7 to your computer and use it in GitHub Desktop.
Save fadookie/96cafaa4342ec32a43c7 to your computer and use it in GitHub Desktop.
Script to install, run, and open logcat for a Unity Android App
#!/bin/sh
# Script to install, run, and open logcat for a Unity Android App.
# I needed this as one of my libraries has a critical post-build script so I can't use "Build and Run" anymore - this is the "and Run" part.
# Be sure to update these variables to match your app's publishing/build settings:
APK_PATH='builds/android/basecode.apk'
BUNDLE_ID='com.eliotlash.basecode'
alias unilogcat='adb logcat|egrep "Unity"'
adb install -r "${APK_PATH}" && adb logcat -c && adb shell am start -n "${BUNDLE_ID}/com.unity3d.player.UnityPlayerNativeActivity" && echo 'DONE, LOG:' && unilogcat
@zezba9000
Copy link

zezba9000 commented Mar 26, 2020

This is much easier to launch and works with any version of Unity.

adb shell monkey -p com.company.appname -c android.intent.category.LAUNCHER 1

@fadookie
Copy link
Author

Thanks for sharing!

@blongho
Copy link

blongho commented Nov 11, 2020

This is much easier to launch and works with any version of Unity.

adb shell monkey -p com.company.appname -c android.intent.category.LAUNCHER 1

Works like magic. Thanks 😄

@zezba9000
Copy link

zezba9000 commented Nov 11, 2020

The other approach that would only work for me on a device behaving oddly (Pico2 VR device) & had a custom AndroidManifies.xml that overrides default activity etc. This is the @fadookie example shows but simplified. IDK why the monkey command stopped working on this device but an FYI for others.

.\adb.exe shell am start -n com.company.appname/com.unity3d.player.UnityPlayerNativeActivityPico

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment