How to Use Android Studio to develop/debug the Android source code, studioandroid

Source: Internet
Author: User

How to Use Android Studio to develop/debug the Android source code, studioandroid

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/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 ).

④ 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: http://yunpan.cn/cf3MBa2688eBw (extraction code: 64e5)

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.