Environment: Ubuntu 14.10,openjdk 1.7,android Studio 3.0.0,android-5.1.1_r1 Source
Build Android Project Engineering:
Compile the source code first
Mmm development/tools/idegen/
development/tools/idegen/idegen.sh
After executing the above command sequentially, the following file is generated at the root of the system
. Classpath (Eclipse)
ANDROID.IPR (intellij/android Studio)
ANDROID.IML (intellij/android Studio)
First, modify the memory configuration of Android Studio (hereinafter referred to as)
Because of the need to consume a lot of memory when importing the source code, so first modify the Idea_home/bin/studio64.vmoptions (x86 machine modification studio.vmoptions) -xms and -xmx The value. 748m is used in the document and can be modified by itself.
Ii. JDK, SDK for configuring as
Add a JDK with no classpath in the IDE to Ensure that the library files in the source code are used
and use it as the Java SDK for the SDK to be used. Such as
Iii. generating the required configuration file for import as (*.IPR)
① Compile the source code (to ensure that a. java file is generated, such as R.java; if compiled, no need to compile again)
② Check if there are Idegen.jar in the out/host/linux-x86/framework/directory
If Idegen.jar does not exist, execute:
Mmm development/tools/idegen/
In the source code of the 5.0.1 will generate Res.java folder, resulting in Idegen.jar run-time throw filenotfoundexception, which is not strict idegen codes caused.
My share has patches to fix this bug, or I'll use the Idegen.jar I shared directly.
③ execution
Development/tools/idegen/idegen. SH
Wait for a result similar to the following:
Read excludes:5mstraversed tree:44078ms
The ANDROID.IPR and ANDROID.IML two IntelliJ idea (as is based on IntelliJ Idea Community Edition) are generated in the root directory of the source code.
Tips:
As in the import code is relatively slow, it is recommended to modify ANDROID.IML, the code will not be used to exclude out. You can imitate the filter. Repo The syntax of the folder, such as:
<excludefolder url= "file://$MODULE _dir$/.repo"/>
<excludefolder url= "file://$MODULE _dir$/abi"/>
<excludefolder url= "file://$MODULE _dir$/art"/>
Remove all unwanted module-library items PS: Thanks for @dezng advice
This will skip the ABI and art folders when importing. The more you filter, the faster the as will be processed.
④ Open source root in as to the newly generated ANDROID.IPR
If as appears at import
It is recommended that the solution (URL: http://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit) be resolved according to its given resolution, as follows:
Iv. solve the problem of jumping error in source code
① set up the correct SDK and JDK for the current project
② setting ' Modules ' dependency
Delete all dependencies first, leaving only ' 1 ' pointing to the two (note: This is all just for convenience.) If you do use the. jar, add them to the path.
such as: 5.0.1 's Contactscommon used to Geocoder-2.9.jar and Libphonenumber-6.2.jar)
Click the ' + ' point in ' 2 ' and select ' 3 ' point to the ' Jars or directories ' option, then add the frameworks and external folders in turn. For example:
Note: It is recommended to move both frameworks and external to the top so that when the code jumps, it is preferred to look in the two folders instead of Android.jar.
Other versions of the code may appear when adding frameworks:
No matter, just show the problem, click OK or the frameworks path will be added.
If you have a code jump error, follow the steps above to add the path or jar file of the code to its Dependencies tab.
Five, Debug source code
We can make it as an Android project by adding the ' Android Framework ' to the project we just imported in ' Modules ', which makes it easier for us to debug the code.
Android Framework support can be added as in ' 1 ' and ' 2 '.
Add a breakpoint in your code and select ' Run '--' Attach debugger to Android process ' or simply click on the icon shown
In the Choose Process dialog box, tick Show All processes, select the process where the code to debug is located, and click OK.
Vi. Other
There are many places in the code that prompt the call requires API level x .... This problem arises because as works for our project as an Android application, and minsdkversion is not specified in the source code.
We just need to add a Androidmanifest.xml file that declares minsdkversion to the root of the source (sharing a androidmanifest.xml).
You might also consider using build.gradle to solve the problem.
How to develop/debug Android source using Android Studio