How to Use Android Studio to develop/debug Android source code
This article uses the development/tools/idegen/README in the source code as the guiding document.
Environment: Ubuntu 14.10, openJdk 1.7, Android Studio 1.0.2, android-5.0.1_r1 source code
Because AS is developed based on IntelliJ IDEA, this article also applies to IntelliJ IDEA.
1. Modify the memory configuration of Android Studio ()
Because importing source code consumes a lot of memory, you must first modify the values of-Xms and-Xmx in IDEA_HOME/bin/studio64.vmoptions (x86 machines modify studio. vmoptions. The document uses 748 m and can be modified by yourself.
2. Configure the as jdk and SDK
Add a JDK without classpath to the IDE to ensure that the library files in the source code are used.
And use it as the Java SDK of the SDK to be used. For example
3. Generate the configuration file (*. ipr) required for importing the)
① Compile the source code (to ensure that the. java file is generated, such as R. java; if it has been compiled, no need to compile it again)
② Check whether idegen. jar exists in the out/host/linux-x86/framework/directory
If idegen. jar does not exist, run:
mmm development/tools/idegen/
The res. java folder is generated in the source code 5.0.1, causing FileNotFoundException during idegen. jar runtime, which is caused by the lack of rigorous idegen code.
I shared a patch for modifying this bug, or directly used the idegen. jar I shared.
③ Execution
development/tools/idegen/idegen.sh
Wait for a result similar to the following:
Read excludes: 5msTraversed tree: 44078ms
The configuration files android. ipr and android. iml are generated under the root directory of the source code (AS is developed based on IntelliJ IDEA community edition ).
Tips:
AS is slow in code import. We recommend that you first modify android. iml to exclude unused code. You can follow the filter. repo folder syntax, for example:
<ExcludeFolder url = "file: // $ MODULE_DIR $/. repo"/>
<ExcludeFolder url = "file: // $ MODULE_DIR $/abi"/>
<ExcludeFolder url = "file: // $ MODULE_DIR $/art"/>
In this way, the abi and art folders will be skipped during the import. The more filtered, the faster the AS processing speed will be.
④ Open the newly generated android. ipr under the root directory of the source code in.
If AS appears during import
It is recommended to solve according to its given solution (URL: http://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit), the specific content as follows:
4. troubleshoot redirection errors in source code
① Set the correct SDK and JDK for the current project
② Set the dependency of 'modules'
Delete all dependencies first, leaving only the two pointed to by '1' (Note: delete all here for convenience. If. jar is used, you can add their paths.
For example: 5.0.1 ContactsCommon uses geocoder-2.9.jar and libphonenumber-6.2.jar)
Click '+' to which '2' points, select 'jars or directories 'to which '3' points, and add the frameworks and external folders in sequence. For example:
Code of other versions may be displayed as follows when frameworks is added:
It does not matter, but the problem is displayed. Click OK to add the frameworks path.
If there is a code jump error, follow the steps above to add the corresponding code path or jar file to its Dependencies tab.
V. DEBUG source code
We can add the 'android framework' to the 'modules' of the newly imported project so that the AS can use it AS an Android project to facilitate code debugging.
You can follow '1' and '2' to add Android Framework support.
Add a breakpoint in the code, select 'run'-> 'Attach debugger to Android process', or directly click the icon shown in
In the displayed Choose Process dialog box, select all processes, select the Process where the code to DEBUG resides, and click OK.
Vi. Others
In the code, Call requires API Level x... is prompted because AS regards our project AS an Android Application project, and minSdkVersion is not specified in the source code.
We only need to add an AndroidManifest. xml file that declares minSdkVersion to the source code root directory (sharing an AndroidManifest. xml file ).
You can also consider using build. gradle to solve this problem.
The file address used in this article:
------------------------------------------ Split line ------------------------------------------
Free in http://linux.bkjia.com/
The username and password are both www.bkjia.com
The specific download directory is in/July 6, 2015,/July 19, April,/How to Use Android Studio to develop and debug the Android source code/
For the download method, see
------------------------------------------ Split line ------------------------------------------
Full process of installing Android Studio on Ubuntu 12.04 (64-bit)
Early adopters of Android Studio v0.1
Android Studio tutorial
Android Studio Development Guide
How to solve the problem that Android Studio sets the topic and does not support Chinese Characters
Android Studio download and installation and solutions that cannot be opened
Graphic tutorial for installing Android Studio
Android Studio details: click here
Android Studio: click here
This article permanently updates the link address: