Running/debugging your Android app on a device

You can run, test and debug your Android projects on an actual device either via USB or Wi-Fi.

Enabling developer options on your Android device

Before you can debug on your device, you need to enabled the developer options on your device:

  1. Plug your Android device into your computer with a USB cable.

  2. If your computer asks for permission to access the device, grant it.

  3. On your Android device, go to the Settings app.

  4. Find the About screen. It's often found by tapping on System and then About (or About Phone).

  5. On the About screen, look for the Build number.

  6. Tap the Build number 7 times. You may see a message as you tap indicating that more taps will enable developer mode.

  7. A confirmation dialog may appear asking if you want to allow developer settings. Tap OK.

  8. You may need to now authenticate with whatever method you use (PIN, password, etc.)

USB debugging

To debug via USB:

  1. Make sure you have enabled Developer options on your Android device.

  2. On your Android device, go to Settings > Developer options.

  3. Scroll down to the USB debugging option and turn it on.

  4. In Xojo, go to the Navigator, click on Build Settings then click on Android.

  5. The device should now appear in the Debug Device menu. Select it and run your project on your device.

Tip

If you already had the Android Build Settings displayed in the Inspector during this process, the Debug Device menu may not refresh to show your device. Should this happen, click on another item in your project and then back to Android under Build Settings to refresh the Debug Device menu.

Wi-Fi debugging

To debug via Wi-Fi:

  1. Make sure your computer and your Android device are both on the same Wi-Fi network.

  2. Make sure your Android device is running Android 11 or greater.

  3. If you don't have Android Studio installed, do so now.

  4. Launch Android Studio.

  5. On the upper-right side of the Android Studio toolbar, you will see a popup menu. If you have not yet created any Android emulators, it will display "No devices". If you have, then the name of your first emulator will appear there.

    ../../../_images/run_configuration_menu.png
  6. Click on this menu and choose Pair Devices Using Wi-Fi. The Pair Devices over Wi-Fi dialog box appears.

  7. If you haven't enabled Developer options on your Android device, do that now.

  8. On our Android device, go to Settings > System > Developer options.

  9. Scroll down until you find the Wireless Debugging option and turn it on.

  10. Tap on the Wireless Debugging label.

  11. Tap Pair device with QR code.

  12. Scan the QR code with your Android device. The dialog on Android Studio confirms that pairing is complete.

    ../../../_images/pairing_complete.png
  13. In Xojo, go to the Navigator, click on Build Settings then click on Android.

  14. The device should now appear in the Debug Device menu. Select it and run your project on your device.

Tip

If you already had the Android Build Settings displayed in the Inspector during this process, the Debug Device menu may not refresh to show your device. Should this happen, click on another item in your project and then back to Android under Build Settings to refresh the Debug Device menu.

Unpairing your device

To unpair your device from your computer:

  1. On your device go to Settings > System > Developer options.

  2. Scroll down to Wireless Debugging and tap on it (on the item itself, not the switch).

  3. Tap on your computer in the Paired Devices section.

  4. Tap Forget.

  5. Launch Android Studio and open a project or create a new one.

  6. If the Device Manager pane is not displayed, choose Tools > Device Manager.

  7. In that pane, click on Physical.

  8. Click on the Trash can icon next to your device name to remove it. A confirmation dialog appears.

  9. Click the Remove button to remove the device and completely unpair your device from your computer.

  10. You may now quit Android Studio.

Troubleshooting

If on-device debugging has stopped working, there are three possibilities:

  • The device has gone to sleep. It must be awake from the time you press the Run button to the time the app appears on your device. If it's gone to sleep, Xojo will tell you that the device isn't responding. Wake up your device and try again.

  • The device isn't responding to the connection from Xojo. Should this happen, try toggling the USB debugging or wireless debugging option in the Developer Options on your device off and back on. If that does not work, you will need to turn off Developer Options by going to your device, tapping on System > Developer Options and then toggling Use developer options off. Once you do that, you'll need to restart the process of setting up on-device debugging. Once done, you should be able to connect from Xojo to your device again. You may need to relaunch Xojo after going through the process.

  • You are trying to debug a project whose application identifier is the same as one that is already installed on your device. Delete the app on your device and then try debugging again.