Android source compilation with android studio

Hello viewer, You can now have our Tutorial Lessons in your android mobile device and read it offline.
Download kotlin Programming APP on PlayStore
Download Website SEO Lessons APP on PlayStore

Android source compilation with android studio

Android source compiler best tutorial is a little bit Operating google official step, http://source.android.com/ .

But in the actual process there are always some pit.

Download or compile the source suggest using 64-bit ubuntu12.04 or 14.04 This can guarantee the same and the official environment, to avoid the unpredictable problems, window or mac system recommended to consider using the virtual machine vbox install ubuntu.

Android source compilation with android studio.

1. Pre-preparation. Android source compilation with android studio.

Before downloading the source code to do some configuration on the environment, the first need to install jdk, but need to pay attention to:

Compile android 5.x need to install the source jdk1.7.x version

Android source compilation with android studio.

Compile android 6.x source need to install jdk1.8.x version

Note that the installation is necessary to rely on the process of the library is likely to error, such as gcc version, cpp version of the problem.

The best solution is to ensure that your software source /etc/apt/sources.list is correct.

Here is the full content of my sources.list (ubuntu 12.04)

  Deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
 # Deb-src http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse
 Deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
 # Deb-src http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
 Deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
 # Deb-src http://archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
 # Deb http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
 # Deb-src http://archive.ubuntu.com/ubuntu/ precise-proposed main restricted universe multiverse
 Deb http://security.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
 # Deb-src http://security.ubuntu.com/ubuntu precise-security main restricted universe multiverse

 Deb http://archive.canonical.com/ubuntu trusty partner
 # Deb-src http://archive.canonical.com/ubuntu precise partner
 Deb http://extras.ubuntu.com/ubuntu trusty main
 # Deb-src http://extras.ubuntu.com/ubuntu precise main

Android source compilation with android studio.

 

2. Download source

Android official suggestion is to use repo synchronization branch code, but the speed of the domestic you know, it is recommended to download a good package android source code, of course, the premise to ensure the source of safe and secure source (think about some time ago xcode vulnerability).

There is a way to download the source in foreign vps, packaged back home, so at least to ensure that the source code is true and reliable.

If you want to download the source code in accordance with the official recommendations, please refer http://source.android.com/source/downloading.html

3. Compile the source code

Referring to the compilation process http://source.android.com/source/building.html

About 3,4 hours to look at the specific machine configuration.

After the completion of the translation can be exported android studio project can be happy to use android studio to read the entire code.

Specific steps:

carried out

  Make idegen && development / tools / idegen / idegen.sh

If you compile the aosp branch it may appear

Exception in thread “main” java.io.FileNotFoundException: ./out/target/product/generic/obj/GYP/shared_intermediates/res.java (Is a directory)

The solution is to change the name res.java

  Mv out / target / product / hammerhead / obj / GYP / shared_intermediates / res.java out / target / product / hammerhead / obj / GYP / shared_intermediates / res.j

Re-implementation

  Make idegen && development / tools / idegen / idegen.sh

Wait until the successful translation can be changed back.

Android source compilation with android studio.

4. Related downloads

Here is what I use android 5.1.1_rc1 source

Android.ipr also inside, you can not compile directly into the android studio to read the source code (I believe many people do not need to compile the source code, just want to be able to easily read the android source code).

About The Author

Related posts

1 Comment

Leave a Reply