Android programming:pushing The Limits--Chapter 1:fine-tuning Your development environment

Source: Internet
Author: User

ADB commandApplication Exerciser MonkeyGradleProguardCode reuseVersion controlStatic code AnalysisCode refactoringDeveloper modeADB command:

@, adb help: View adb commands.

@, ADB devices: Lists all connected Android devices and emulators.

@, adb push <local> <remote> copy files from your computer to your device.

ADB push e:\test.xml/sdcard/files.ldb/

@, adb pull <remote> <local> copy files from your device to your computer

@, ADB devices: You can view the serial number of the connected device (serial numbers)

@, adb {–s <serial number>} logcat

@, adb logcat <tag>:<priority>

Example:

Define a log label in your custom class, such as:

private static final String Log_tag = "myactivity";

This tag is then used in the code in this custom class to log logs, such as:

LOG.D (Log_tag, "adb logcat test");

This allows you to use the myactivity tag on the command line for log filtering and command format:

ADB logcat myactivity:* *:s

Note: *:s can not be less, *:s said let Logcat not show other logs (original: *:s,which tells Logcat to silence all messages.)

@, use the ADB command to connect devices over WiFi. Note: The Android device uses the same wifi as the computer.

1, first use USB connection device and computer;

2. Enter the following command on the command line

ADB devices//Confirm that the serial number is visible under connected devices.

ADB tcpip 5555//The ADB process of restarting the device in TCP/IP mode and listening on 5555 ports (adb default port)

ADB connect <IP>//Notifies the computer of the ADB Service connection IP address, where IP is the IP of the device.

ADB devices//confirm the connected device again, and you can see a <ip>:5555 device at this time.

3. After you unplug the USB cable, you can still use this device for debugging.

4, when restarting the device, or using the ADB USB command, the device's ADB process and restore the USB mode.

@, adb shell can use command-line operations on devices, similar to operating on Linux.

@, adb shell am <options> can start the service,intent on the device and so on.

@, adb shell pm <options> can view, install, and operate the features and permissions on the device.

Learn more about ADB commands to view http://developer.android.com/tools/help/adb.html

Application Exerciser Monkey:

@, a command-line tool capable of simulating user actions by generating pseudo-random events to stress test the application.

@, command: adb shell monkey–p <package name> <event count>

@, regression testing through Monkeyrunner. You can find the API for the Monkeyrunner at http://developer.android.com/tools/help/monkeyrunner_concepts.html#APIClasses

Gradle:

The User guide for the new Gradle build system can be found at

Http://tools.android.com/tech-docs/new-build-system/user-guide

Proguard:

@, a tool integrated in the Android SDK, can use this tool to disrupt code (obfuscate your codes) when publishing an app, which makes it more difficult to decompile the application. How to use: Add in the Build.gradle file:

Buildtypes {

Release {

Runproguard true

Proguardfile getdefaultproguardfile (' Proguard-android.txt ')

}

}

@, you can optimize your code, remove useless code, and reduce the size of your publishing app.

Code reuse:

@, using jar packages, typically used to reference third-party code. How to use: Copy the jar package to the Libs directory and then add it to the Build.gradle file:

dependencies{

Compile files (' Libs/xxx.jar ')//XXX is the name of the jar package to be referenced.

}

@, using the Library project, commonly used in a project in a number of applications, server and client share some tool classes, general view and so on. To use the method, create a module in the project, type select Android Library, and then add in the Build.gradle file of the other module:

dependencies{

Compile project (': Libraries:xxx ')//XXX is the name of the library project that was created.

}

Version control:

@, Git:

1, https://git-scm.com/

2. Version Control with git a book about git.

@, create your own gitolite server, so you can access git respositories remotely.

You can find the documentation and download for Gitolite at

Http://gitolite.com/gitolite

An excellent-quick installation guide can is found at

Http://gitolite.com/gitolite/qi.html

@, using off-the-shelf servers, such as GitHub http://github.com

@, Code checker tool Gerrit

You can find out more about Gerrit and download the server at

Https://code.google.com/p/gerrit (new address: https://www.gerritcodereview.com/)

Static code Analysis:

@, using the lint tool that comes with the Android SDK for code analysis. How to use: In Project view of Android Studio, right >> Analyze >> Inspect Code ...

Code refactoring:

@, through the refactor function, to achieve static variable extraction, method extraction, method signature changes and other functions. For more information, see: http://www.jetbrains.com/idea/features/refactoring.html

Developer Mode:

@, Android 4.2 and later versions of the system, the developer menu is hidden, open method: Go to "about Phone" >> "version number" Click 7 times >> return to the previous layer, you can see the developer menu.

Android programming:pushing The Limits--Chapter 1:fine-tuning Your development environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.