- Running Your Android Application on an Android Device
- Running Your Application with Clean Data and Cache Folders
- Troubleshooting
- Stuck at «Uninstalling» on the Run Dialog Box
- Set Up Device for Development
- Enable Debugging on the Device
- Android 9.0+
- Android 8.0 and Android 8.1
- Android 7.1 and lower
- Verify that USB debugging is enabled
- Android 9.0+
- Android 8.0 and Android 8.1
- Android 7.1 and lower
- Connect the device to the computer
- Alternate connection via Wifi
- Connecting over WiFi
- Troubleshooting
- Install USB Drivers
- Download the USB Drivers
- Installing the USB Driver
- Summary
- Configure on-device developer options
- Enable developer options and USB debugging
- General options
- Debugging
- Networking
- Input
- Drawing
- Hardware accelerated rendering
- Media
- Monitoring
Running Your Android Application on an Android Device
After you prepare your development system for Android development, enable USB debugging in your Android device and configure your system to detect your Android device, you can run a FireMonkey mobile application on a connected Android device.
- Connect your Android device to your development system using your device’s USB cable. You should see your Android device listed under Portable Devices in the Device Manager (available from the Control Panel). For more information, see Configuring Your System to Detect Your Android Device.
- In RAD Studio, select either File > New >FireMonkey Mobile Application — Delphi or File > New >FireMonkey Mobile Application — C++Builder .
- In the Project Manager, activate (double-click) the Android target platform.
- Enable the Android SDK for your device:
- In the Project Manager, right-click the Android node and select Properties.
- In Platform Properties, click the down-arrow in the SDK (Software Development Kit) field and select either:
- Your installed Android SDK version, if it is displayed
- Add New
- In the Add a New SDK dialog box, click the down-arrow in the Select an SDK version field and select your installed Android SDK.
- Complete the fields in the Create a New Android SDK wizard. Most of the fields are completed automatically by the wizard.
- Enable your Android device as the target platform: In the Android target platform in the Project Manager, open the Target node and double-click your Android device. When your Android device is correctly installed, the SDK version number appears after the Android target name; for example: Android — Android SDK 22.0.1Tips: If your device is not shown, try these steps:
- In the IDE, right-click the Target node and select Refresh.
- In the Control Panel, open the Device Manager:
- Verify that your Android device is listed, typically under Portable Devices.
- If your device is not listed, right-click any node and select Scan for hardware changes.
- If necessary, use the Android SDK Manager to uninstall and then reinstall the device driver for your Android device. Select Start | All Programs | Embarcadero RAD Studio XE6 | Android Tools .
The following image shows a populated Android Target node displaying the Nexus 10 device, one emulator that is running, and several emulators that are not running:
- If you selected the Application Store platform configuration on the Configuration node of the Project Manager, you must have a signing certificate configured for the Application Store platform configuration on the Provisioning page. The Debug platform configuration does not require a signing certificate.
- Run your application:
- Run with debugging ( Run >Run or F9 )
- Run without debugging ( Run >Run Without Debugging or Shift+Ctrl+F9 ).
RAD Studio builds your application for Android and runs your application on the selected Android device. If your Android device screen is locked, unlock it to access your application.
Running Your Application with Clean Data and Cache Folders
When you run an application on an Android device, RAD Studio installs your application on your device using the package name that you defined in the Version Info options page to uniquely identify your application. By default, the package name is «com.embarcadero.$(ModuleName)», where $(ModuleName) is the name of your project, such as «Project1».
If you run your application on a device that already contains a previously-installed application with the same package name as the application that you want to run, the Run command reinstalls your application, but only updates the application executable; your application’s data and cache folders are not updated.
To configure RAD Studio so that the Run Without Debugging and Run actions completely uninstall any previously-installed version of your application, including the data and cache folders, before installing the newer version:
- Select Run >Parameters .
- Enter «-cleaninstall» in the Parameters field:
- Click OK to save your changes.
Troubleshooting
Stuck at «Uninstalling» on the Run Dialog Box
You might need to enable USB debugging specifically for your computer if you are running Android 4.2.2 or later and when you click Run or Run Without Debug, RAD Studio does not go beyond the following screen:
You might also need to enable the general USB debugging setting in your device. If this is the case, your device should show a dialog box asking you to allow USB debugging:
Click OK to allow USB debugging.
If you accidentally click Cancel, disconnect your device from your PC and then reconnect it to make the dialog box reappear on your device.
Источник
Set Up Device for Development
This article explains how to setup an Android device and connect it to a computer so that the device may be used to run and debug Xamarin.Android applications.
After testing on an Android emulator, you will want to see and test your apps running on an Android device. You will need to enable debugging and connect the device to the computer.
Each of these steps will be covered in more detail in the sections below.
Enable Debugging on the Device
A device must be enabled for debugging in order to test an Android application. Developer options on Android have been hidden by default since version 4.2, and enabling them can vary based on the Android version.
Android 9.0+
For Android 9.0 and higher, debugging is enabled by following these steps:
- Go to the Settings screen.
- Select About Phone .
- Tap Build Number 7 times until You are now a developer! is visible.
Android 8.0 and Android 8.1
- Go to the Settings screen.
- Select System.
- Select About Phone
- Tap Build Number 7 times until You are now a developer! is visible.
Android 7.1 and lower
- Go to the Settings screen.
- Select About Phone.
- Tap Build Number 7 times until You are now a developer! is visible.
Verify that USB debugging is enabled
After enabling developer mode on your device, you must ensure that USB debugging is enabled on the device. This also varies based on the Android version.
Android 9.0+
Navigate to Settings > System > Advanced > Developer Options and enable USB Debugging.
Android 8.0 and Android 8.1
Navigate to Settings > System > Developer Options and enable USB Debugging.
Android 7.1 and lower
Navigate to Settings > Developer Options and enable USB Debugging.
Once the Developer Options tab is available under Settings > System, open it to reveal developer settings:
This is the place to enable developer options such as USB debugging and stay awake mode.
Connect the device to the computer
The final step is to connect the device to the computer. The easiest and most reliable way is to do so over USB.
You will receive a prompt to trust the computer on your device if you have not used it for debugging before. You can also check Always allow from this computer to prevent requiring this prompt each time you connect the device.
Alternate connection via Wifi
It is possible to connect an Android device to a computer without using a USB cable, over WiFi. This technique requires more effort but could be useful when the device is too far from the computer to remain constantly plugged-in via cable.
Connecting over WiFi
By default, the Android Debug Bridge (ADB) is configured to communicate with an Android device via USB. It is possible to reconfigure it to use TCP/IP instead of USB. To do this, both the device and the computer must be on the same WiFi network. To setup your environment to debug over WiFi complete the following steps from the command line:
Determine the IP address of your Android device. One way to find out the IP address is to look under Settings > Network & internet > Wi-Fi, then tap on the WiFi network that the device is connected to, and then tap on Advanced. This will open a dropdown showing information about the network connection, similar to what is seen in the screenshot below:
On some versions of Android the IP address won’t be listed there but can be found instead under Settings > About phone > Status.
Connect your Android device to your computer via USB.
Next, restart ADB so that it using TCP on port 5555. From a command prompt, type the following command:
After this command is issued, your computer will not be able to listen to devices that are connected via USB.
Disconnect the USB cable connecting your device to your computer.
Configure ADB so that it will connect to your Android device on the port that was specified in step 1 above:
Once this command finishes the Android device is connected to the computer via WiFi.
When you’re finished debugging via WiFi, it’s possible to reset ADB back to USB mode with the following command:
It’s possible to request ADB to list the devices that are connected to the computer. Regardless of how the devices are connected, you can issue the following command at the command prompt to see what is connected:
Troubleshooting
In some cases you might find that your device cannot connect to the computer. In this case you may want to verify that USB drivers are installed.
Install USB Drivers
This step is not necessary for macOS; just connect the device to the Mac with a USB cable.
It may be necessary to install some extra drivers before a Windows computer will recognize an Android device connected by USB.
These are the steps to set up a Google Nexus device and are provided as a reference. Steps for your specific device may vary, but will follow a similar pattern. Search the internet for your device if you have trouble.
Run the android.bat application in the [Android SDK install path]\tools directory. By default, the Xamarin.Android installer will put the Android SDK in following location on a Windows computer:
Download the USB Drivers
Google Nexus devices (with the exception of the Galaxy Nexus) require the Google USB Driver. The driver for the Galaxy Nexus is distributed by Samsung. All other Android devices should use the USB driver from their respective manufacturer.
Install the Google USB Driver package by starting the Android SDK Manager, and expanding the Extras folder, as can be seen in the follow screenshot:
Check the Google USB Driver box, and click the Apply Changes button. The driver files are downloaded to the following location:
[Android SDK install path]\extras\google\usb\_driver
The default path for a Xamarin.Android installation is:
Installing the USB Driver
After the USB drivers are downloaded, it is necessary to install them. To install the drivers on Windows 7:
Connect your device to the computer with a USB cable.
Right-click on the Computer from your desktop or Windows Explorer, and select Manage .
Select Devices in the left pane.
Locate and expand Other Devices in the right pane.
Right-click the device name and select Update Driver Software . This will launch the Hardware Update Wizard.
Select Browse my computer for driver software and click Next .
Click Browse and locate the USB driver folder (the Google USB driver is located in [Android SDK install path]\extras\google\usb_driver).
Click Next to install the driver.
Summary
This article discussed how to configure an Android device for development by enabling debugging on the device. It also covered how to connect the device to a computer using either USB or WiFi.
Источник
Configure on-device developer options
The Settings app on Android includes a screen called Developer options that lets you configure system behaviors that help you profile and debug your app performance. For example, you can enable debugging over USB, capture a bug report, enable visual feedback for taps, flash window surfaces when they update, use the GPU for 2D graphics rendering, and more.
Enable developer options and USB debugging
Figure 1. Developer options
On Android 4.1 and lower, the Developer options screen is available by default. On Android 4.2 and higher, you must enable this screen. To enable developer options, tap the Build Number option 7 times. You can find this option in one of the following locations, depending on your Android version:
- Android 9 (API level 28) and higher: Settings > About Phone > Build Number
- Android 8.0.0 (API level 26) and Android 8.1.0 (API level 26): Settings > System > About Phone > Build Number
- Android 7.1 (API level 25) and lower: Settings > About Phone > Build Number
At the top of the Developer options screen, you can toggle the options on and off (figure 1). You probably want to keep this on. When off, most options are disabled except those that don’t require communication between the device and your development computer.
Before you can use the debugger and other tools, you need to enable USB debugging, which allows Android Studio and other SDK tools to recognize your device when connected via USB. To enable USB debugging, toggle the USB debugging option in the Developer Options menu. You can find this option in one of the following locations, depending on your Android version:
- Android 9 (API level 28) and higher: Settings > System > Advanced > Developer Options > USB debugging
- Android 8.0.0 (API level 26) and Android 8.1.0 (API level 26): Settings > System > Developer Options > USB debugging
- Android 7.1 (API level 25) and lower: Settings > Developer Options > USB debugging
The rest of this page describes some of the other options available on this screen.
General options
On Android 8.0 and higher, you can tap Quick settings developer tiles to add selected developer options to your Quick Settings panel. After you select one or more of the available tiles (figure 2), open the Quick Settings panel and tap the pencil to enter edit mode. Then, drag the developer tiles from the tiles pane onto the Quick settings panel, and tap the pencil again to exit edit mode.
Figure 2. Add to Quick Settings panel
Other general options include the following:
- Memory: (On Android 8.0 and higher) Display memory stats, such as average memory usage, memory performance, total memory available, average memory used, how much free memory is available, and how much memory is being used by apps.
- Take bug report: Get a copy of the current device log files to share with someone. When you get a notification that the bug report is ready, tap the notification to share it.
- System UI demo mode: Makes it easier to take clean screenshots by displaying a generic, preset notification bar that does not show notifications or low battery warnings. Enable Demo Mode allows you to change the appearance of the status bar using adb demo mode commands. Or you can use Show Demo Mode to hide notifications and display a preset status bar. Note: The adb demo mode commands might not work on all devices because they are not verified during Android certification testing. They’re only verified to work on Nexus and Pixel devices.
- Desktop backup password: Sets a backup password so you can use adb commands to back up and restore device apps and data under password protection.
- Stay awake: Sets your screen to stay on every time you plug it in.
- Enable Bluetooth Host Controller Interface (HCI) snoop log: Captures all Bluetooth HCI packets in a file stored at /sdcard/btsnoop_hci.log . You can retrieve the packets, and then use a program like Wireshark to analyze and troubleshoot the information.
Debugging
Figure 3. Debugging options enabled
Debugging options provide ways to configure on-device debugging, and to establish communication between the device and your development computer.
Enable USB debugging (figure 3) so your Android device can communicate with your development machine through Android Debug Bridge (adb). The Wait for Debugger option is unavailable until you use Select debug app to select the app to debug. If you enable Wait for Debugger, the selected app waits for the debugger to attach before it executes.
Other debugging options include the following:
- Store logger data persistently on device: Select the type of log messages you want to store persistently on the device. Options are off, all, all but radio, or kernel only.
- Select mock location app: Use this option to fake the GPS location of the device to test whether your app behaves the same in other locations. To use this option, download and install a GPS mock location app.
Figure 4. View attributes
Networking
Figure 5. Select USB Configuration
Networking options provide ways to configure Wi-Fi and DHCP settings.
Tap Select USB Configuration to specify how you want the computer to identify the device. As shown in figure 5, you can configure devices for charging only, to transfer files (MTP), to transfer pictures (PTP), to use your mobile internet on the PC (RNDIS), or to transfer audio or MIDI files.
Tap Bluetooth AVRCP version and select the profle version you want to use to control all of the Bluetooth A/V equipment to which your device has access. Addiitonally, to fine-tune the audio playback on the device, tap and set the following options:
- Bluetooth Audio Codec: Adjust the sound quality (codec) of your devices by selecting one of the following codecs:
- SBC: Transfer data to Bluetooth audio output devices such as headphones and speakers.
- AAC: Better sound quality from wired devices than MP3 at similar bit rates.
- aptX: A pure wireless sound in high-quality smartphones, speakers, soundbars, headphones, and tablets.
- aptX HD: High-resolution streaming to Bluetooth devices.
- LDAC: Provide high-quality music listening over wireless connections.
- Enable Optional Codecs and Disable Optional Codecs: If you have additional codec implementations installed, use these options to enable and disable them.
- Bluetooth Audio Sample Range: Adjust the number of audio samples per second by selecting an audio codec sample rate. Higher sample rates use more resources.
- Bluetooth Audio Bits Per sample: Set the number of bits of information in each audio sample. With a higher the bit rate, the sound is better but the sample file is larger.
- Bluetooth Audio Channel Mode: Select mono or stereo.
- Bluetooth Audio LDAC Codec: Optimize the sound to increase audio quality, balance audio and connection quality, increase connection quality, or use an adaptive bit rate to balance audio and connection quality.
The followng list describes other ways to configure Wi-Fi and DHCP setup:
- Wireless display certification: Enables advanced configuration controls and settings for Wireless Display certification to the specifications set forth in the Wi-Fi Alliance Wi-Fi Display Specification. The certification applies to Android 4.4 (API level 19) and higher.
- Enable Wi-Fi verbose logging: Increases the Wi-Fi logging level for each wireless network (SSID) you connect to according to its relative received signal strength (RSSI). For more information about logs, see Write and view logs with Logcat.
- Aggressive Wi-Fi to cellular handover: When the signal is low, makes Wi-Fi more efficient in handing over the data connection to a cellular network.
Input
Figure 6. Pointer location
Enable Show taps to display taps when you touch the screen. A circle appears under your finger or stylus and follows you as you move around the screen. A tap works like a pointer when you Record a video on your device.
Enable Pointer Location to show the pointer (tap) location on the device with cross-hairs. A bar appears across the top of the screen to track the cross-hair coordinates (figure 6). As you move the pointer, the coordinates in the bar track the cross-hair location and the pointer path draws on the screen.
Drawing
Figure 7. User interface constructions
Drawing options provide visual cues about the app’s user interface and how it operates.
Enable Show Layout Bounds to show your app’s clip bounds, margins, and other user interface constructions on the device, as shown in figure 7.
Other Drawing options include the following:
- Force RTL layout direction: Forces screen layout direction to be from right to left (RTL) or from left to right (default).
- Window animation scale: Sets the window animation playback speed so you can check its performance at different speeds. A lower scale results in a faster speed.
- Transition animation scale: Sets the transition animation playback speed so you can check its performance at different speeds. A lower scale results in a faster speed.
- Simulate secondary displays: Creates a secondary display as an overlay on the device. This is useful when supporting additional displays with the Presentation API. See Secondary displays.
Hardware accelerated rendering
Figure 8. Deuteranomaly color space
Hardware accelerated rendering options provide ways to optimize your app for its target hardware platforms by leveraging hardware-based options such as the GPU, hardware layers, and multisample anti-aliasing (MSAA).
Tap Simulate color space to change the color scheme of the entire device UI. The options refer to types of color blindness. Choices are Disabled (no simulated color scheme), Monochromacy (black, white, and gray), Deuteranomaly (red-green), Protanomaly (red-green), and Tritanomaly (blue-yellow). Protanomaly refers to red-green color blindness with weakness in red colors, and Deuteranomaly (shown in figure 8) refers to red-green color blindness with weakness in green colors.
If you take screenshots in a simulated color space, they appear normal as if you hadn’t changed the color scheme.
Some other ways to leverage hardware-based options are the following:
- Set GPU renderer: Change the default Open GL graphics engine to the Open GL Skia graphics engine.
- Force GPU rendering: Forces apps to use the GPU for 2D drawing, if they were written without GPU rendering by default.
- Show GPU view updates: Displays any onscreen element drawn with the GPU.
- Debug GPU overdraw: Displays color-coding on your device so you can visualize how how many times the same pixel has been drawn in the same frame. The visualization shows where your app might be doing more rendering than necessary. For more information, see Visualize GPU overdraw.
- Debug non-rectangular clip operations: Turns off the clipping area on the canvas to create unusual (non-rectangular) canvas areas. Normally, the clipping area prevents drawing anything outside the bounds of the circular clipping area.
- Force 4x MSAA: Enables multisample anti-aliasing (MSAA) in Open GL ES 2.0 apps.
- Disable HW overlays: Using the hardware overlay enables each app that displays something on the screen to use less processing power. Without the overlay, an app shares the video memory and has to constantly check for collision and clipping to render a proper image. The checking uses a lot of processing power.
Media
Set Disable USB audio routing on to disable automatic routing to external audio devices connected to a computer through a USB port. Automatic routing can interfere with apps that are USB-aware.
In Android 11 and later, when an application without RECORD_AUDIO permission uses UsbManager to request direct access to a USB audio device with audio capture capability (such as a USB headset), a warning message appears asking the user to confirm permission to use the device. The system ignores any «always use» option, so the user must acknowledge the warning and grant permission every time an app requests access. To avoid this behavior, your app should request the RECORD_AUDIO permission.
Monitoring
Figure 9. Bar representation
Monitoring options provide visual information about app performance, such as long thread and GPU operations.
Tap Profile GPU Rendering and then On screen as bars to display the GPU rendering profile as bars (figure 9). For more information, see Profile GPU rendering.
Figure 10. Set background process limits
App options help you understand how your app operates on the target device.
Tap Background process limit to set the number of processes that can run in the background at one time. Possible settings are shown in figure 10.
Tap Reset ShortcutManager rate-limiting during testing so background apps can continue to call shortcut APIs until the rate limit is reached again. For more information about shortcuts and rate limits, see ShortcutManager .
Enable Don’t keep activities to increase battery life by destroying every activity as soon as the user leaves the activity’s main view.
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.
Источник