Skip to content

Commit

Permalink
Cleaned up debugging manuals a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
britzl committed Jul 16, 2022
1 parent 8f1651f commit 094bf6f
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 88 deletions.
62 changes: 3 additions & 59 deletions docs/en/manuals/android.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ Press <kbd>Create Bundle</kbd> when you have configured the application bundle s

### Installing an APK

An *.apk* file can be copied to your device with the `adb` tool (see below), or to Google Play via the [Google Play developer console](https://play.google.com/apps/publish/).
An *.apk* file can be copied to your device with the `adb` tool, or to Google Play via the [Google Play developer console](https://play.google.com/apps/publish/).

:[Android ADB](../shared/android-adb.md)

```
$ adb install Defold\ examples.apk
Expand All @@ -87,64 +89,6 @@ Allows an application to write to external storage. Starting in API level 19, th
Allows using PowerManager WakeLocks to keep processor from sleeping or screen from dimming. This permission is needed to temporarily prevent the device from sleeping while receiving a push notification. ([Android official docs](https://developer.android.com/reference/android/Manifest.permission#WAKE_LOCK))


## Android Debug Bridge

The `adb` command line tool is an easy to use and versatile program that is used to interact with Android devices. You can download and install `adb` as part of the Android SDK Platform-Tools, for Mac, Linux or Windows.

Download the Android SDK Platform-Tools from: https://developer.android.com/studio/releases/platform-tools. You find the *adb* tool in */platform-tools/*. Alternatively, platform specific packages can be installed through respective package managers.

On Ubuntu Linux:

```
$ sudo apt-get install android-tools-adb
```

On Fedora 18/19:

```
$ sudo yum install android-tools
```

On macOS (Homebrew)

```
$ brew cask install android-platform-tools
```

You can verify that `adb` works by connecting your Android device to your computer via USB and issue the following command:

```
$ adb devices
List of devices attached
31002535c90ef000 device
```

If your device does not show up, verify that you have enabled *USB debugging* on the Android device. Open the device *Settings* and look for *Developer options* (or *Development*).

![Enable USB debugging](images/android/usb_debugging.png)

## Debugging an application bundle

A bundle built with the debug mode version of the engine (i.e. "Debug" selected as variant during bundling) will send all its console output to the Android system log. Access the log with the `adb` tool and give the `logcat` command. You probably want to filter the output by a tag (`-s [tagname]`):

```
$ adb logcat -s "defold"
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
I/defold ( 6210): INFO:DLIB: SSDP started (ssdp://192.168.0.97:58089, http://0.0.0.0:38637)
I/defold ( 6210): INFO:ENGINE: Defold Engine 1.2.50 (8d1b912)
I/defold ( 6210): INFO:ENGINE: Loading data from:
I/defold ( 6210): INFO:ENGINE: Initialised sound device 'default'
I/defold ( 6210):
D/defold ( 6210): DEBUG:SCRIPT: Hello there, log!
...
```


### Uploading symbols to Google Play
You can [upload the debug symbols to Google Play](https://developer.android.com/studio/build/shrink-code#android_gradle_plugin_version_40_or_earlier_and_other_build_systems) so that any crashes logged in Google Play will show symbolicated call stacks. Learn more about this in the [manual on native code debugging](/manuals/debugging-native-code).


## Using AndroidX
AndroidX is a major improvement to the original Android Support Library, which is no longer maintained. AndroidX packages fully replace the Support Library by providing feature parity and new libraries. Most of the Android extensions in the [Asset Portal](/assets) support AndroidX. If you do not wish to use AndroidX you can explicitly disable it in favour of the old Android Support Library:

Expand Down
51 changes: 31 additions & 20 deletions docs/en/manuals/debugging-game-and-system-logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,46 @@ Logs can be read using the developer tools provided by most browsers.

### Android

You can use the [Android Debug Bridge (ADB) tool](https://developer.android.com/studio/command-line/adb.html) to view the game and system log.
You can use the Android Debug Bridge (ADB) tool to view the game and system log.

Once installed and setup, connect your device with USB, open a terminal and run:
:[Android ADB](../shared/android-adb.md)

```txt
cd <path_to_android_sdk>/platform-tools/
adb logcat
```
Once installed and setup, connect your device with USB, open a terminal and run:

The device will then dump all the output to the current terminal, along with any prints from the game.

If you want to see only Defold application outputs use this command:
```txt
$cd <path_to_android_sdk>/platform-tools/
$adb logcat
```

```txt
cd <path_to_android_sdk>/platform-tools/
adb logcat -s defold
```
The device will then dump all the output to the current terminal, along with any prints from the game.

If you want to see only Defold application outputs use this command:

```txt
$ cd <path_to_android_sdk>/platform-tools/
$ adb logcat -s defold
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
I/defold ( 6210): INFO:DLIB: SSDP started (ssdp://192.168.0.97:58089, http://0.0.0.0:38637)
I/defold ( 6210): INFO:ENGINE: Defold Engine 1.2.50 (8d1b912)
I/defold ( 6210): INFO:ENGINE: Loading data from:
I/defold ( 6210): INFO:ENGINE: Initialised sound device 'default'
I/defold ( 6210):
D/defold ( 6210): DEBUG:SCRIPT: Hello there, log!
...
```

### iOS

You can use the [Console tool](https://support.apple.com/guide/console/welcome/mac) to read game and system log. You can use the LLDB debugger to attach to a game running on device. To debug a game it needs to be signed with a “Apple Developer Provisioning Profile” that include the device you want to debug on. Bundle the game from the editor and supply the provisioning profile in the bundle dialog (bundling for iOS is only available on macOS).

To launch the game and attach the debugger you will need a tool called [ios-deploy](https://github.com/phonegap/ios-deploy). Install and debug your game by running the following in a terminal:
To launch the game and attach the debugger you will need a tool called [ios-deploy](https://github.com/phonegap/ios-deploy). Install and debug your game by running the following in a terminal:

```txt
ios-deploy --debug --bundle <path_to_game.app> # NOTE: not the .ipa file
```
```txt
$ ios-deploy --debug --bundle <path_to_game.app> # NOTE: not the .ipa file
```

This will install the app on your device, start it and automatically attach a LLDB debugger to it. If you are new to LLDB, read [Getting Started with LLDB](https://developer.apple.com/library/content/documentation/IDEs/Conceptual/gdb_to_lldb_transition_guide/document/lldb-basics.html).
This will install the app on your device, start it and automatically attach a LLDB debugger to it. If you are new to LLDB, read [Getting Started with LLDB](https://developer.apple.com/library/content/documentation/IDEs/Conceptual/gdb_to_lldb_transition_guide/document/lldb-basics.html).


## Reading the game log from the log file
Expand All @@ -88,5 +99,5 @@ iOS

Once the container has been extracted it will be shown in *Finder*. Right click the container and select <kbd>Show Package Content</kbd>. Locate the file "log.txt", which should be located in "AppData/Documents/".

Android
: The ability to extract the "log.txt" depends on OS version and manufacturer. Here is a short and simple step by step guide: https://stackoverflow.com/a/48077004/129360
Android(
: The ability to extract the "log.txt" depends on OS version and manufacturer. Here is a short and simple [step by step guide](https://stackoverflow.com/a/48077004/]129360).
5 changes: 3 additions & 2 deletions docs/en/manuals/debugging-native-code-android.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---
title: Debugging on Android
brief: This manual describes how to debug a build running on an Android device.
brief: This manual describes how to debug a build using Android Studio.
---

# Debugging on Android

Here we list some ways to debug your executable running on an Android device
Here we describe how to debug a build using [Android Studio](https://developer.android.com/studio/), the official IDE for Google's Android operating system.


## Android Studio

Expand Down
6 changes: 3 additions & 3 deletions docs/en/manuals/debugging-native-code-ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ Here we describe how to debug a build using [Xcode](https://developer.apple.com/

## Xcode

* Bundle the app by using bob, with the `--with-symbols` option
* Bundle the app by using bob, with the `--with-symbols` option ([more info](/manuals/debugging-native-code/#symbolicate-a-callstack)):

$ cd myproject
$ wget http://d.defold.com/archive/<sha1>/bob/bob.jar
$ java -jar bob.jar --platform armv7-darwin build --with-symbols debug --archive bundle -bo build/ios -mp <app>.mobileprovision --identity "iPhone Developer: Your Name (ID)"
$ java -jar bob.jar --platform armv7-darwin build --with-symbols --variant debug --archive bundle -bo build/ios -mp <app>.mobileprovision --identity "iPhone Developer: Your Name (ID)"

* Install the app, either with `Xcode`, `iTunes` or [ios-deploy](https://github.com/ios-control/ios-deploy)

Expand Down Expand Up @@ -82,7 +82,7 @@ You have a few options to debug an app

![select_device](images/extensions/debugging/ios/attach_to_process_name.png)

1. Start the app on the device
1. Start the app on the device

1. In `Edit Scheme` add the <AppName>.app folder as the executable

Expand Down
4 changes: 2 additions & 2 deletions docs/en/manuals/debugging-native-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ In the `Xcode -> Devices` window, you can also select the crash logs

If you get a callstack from either a `_crash` file or a [log file](/manuals/debugging-game-and-system-logs), you can symbolicate it. This means translating each address in the callstack into a filename and line number, which in turn helps when finding out the root cause.

It is important that you match the correct engine with the callstack, otherwise it's very likely to send you debugging the incorrect things! Use the flag [--with-symbols](https://www.defold.com/manuals/bob/) when bundling with [bob](https://www.defold.com/manuals/bob/) or check the "Generate debug symbols" checkbox from the bundle dialog in the editor:
It is important that you match the correct engine with the callstack, otherwise it's very likely to send you debugging the incorrect things! Use the flag [`--with-symbols`](https://www.defold.com/manuals/bob/) when bundling with [bob](https://www.defold.com/manuals/bob/) or check the "Generate debug symbols" checkbox from the bundle dialog in the editor:

* iOS - the `dmengine.dSYM.zip` folder in `build/arm64-ios` contains the debug symbols for iOS builds.
* macOS - the `dmengine.dSYM.zip` folder in `build/x86_64-darwin` contains the debug symbols for macOS builds.
Expand All @@ -96,7 +96,7 @@ You can [upload the debug symbols to Google Play](https://developer.android.com/

### Symbolicate an Android callstack

1. Get it from your build folder
1. Get the engine from your build folder

$ ls <project>/build/<platform>/[lib]dmengine[.exe|.so]

Expand Down
33 changes: 33 additions & 0 deletions docs/en/shared/android-adb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
The `adb` command line tool is an easy to use and versatile program that is used to interact with Android devices. You can download and install `adb` as part of the Android SDK Platform-Tools, for Mac, Linux or Windows.

Download the Android SDK Platform-Tools from: https://developer.android.com/studio/releases/platform-tools. You find the *adb* tool in */platform-tools/*. Alternatively, platform specific packages can be installed through respective package managers.

On Ubuntu Linux:

```
$ sudo apt-get install android-tools-adb
```

On Fedora 18/19:

```
$ sudo yum install android-tools
```

On macOS (Homebrew)

```
$ brew cask install android-platform-tools
```

You can verify that `adb` works by connecting your Android device to your computer via USB and issue the following command:

```
$ adb devices
List of devices attached
31002535c90ef000 device
```

If your device does not show up, verify that you have enabled *USB debugging* on the Android device. Open the device *Settings* and look for *Developer options* (or *Development*).

![Enable USB debugging](images/android/usb_debugging.png)
2 changes: 1 addition & 1 deletion docs/ru/manuals/debugging-game-and-system-logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ iOS
Как только контейнер будет извлечен, он появится в приложении *Finder*. Щелкните по контейнеру правой кнопкой мыши и выберите <kbd>Show Package Content</kbd>. Найдите файл «log.txt», который должен находиться в «AppData/Documents/».

Android
: Возможность извлечения файла "log.txt" зависит от версии ОС и производителя. Вот краткое и простое пошаговое руководство: https://stackoverflow.com/a/48077004/129360
: Возможность извлечения файла "log.txt" зависит от версии ОС и производителя. Вот краткое и простое пошаговое руководство: [https://stackoverflow.com/a/48077004/129360](https://stackoverflow.com/a/48077004/129360).
2 changes: 1 addition & 1 deletion docs/zh/manuals/debugging-game-and-system-logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ iOS
容器被下载解压之后就可以在 *Finder* 中看到了. 右键单击容器选择 <kbd>Show Package Content</kbd>. 找到 "log.txt", 一般位于 "AppData/Documents/".

Android
: "log.txt" 的获取取决于操作系统版本和制造商. 在这里有一个简单的获取步骤: https://stackoverflow.com/a/48077004/129360
: "log.txt" 的获取取决于操作系统版本和制造商. 在这里有一个简单的获取步骤: [https://stackoverflow.com/a/48077004/129360](https://stackoverflow.com/a/48077004/129360).

0 comments on commit 094bf6f

Please sign in to comment.