Compiling an Android project Error record in Linux environment using MMM command

Source: Internet
Author: User

This article is based on the previous three articles (the main reference to Lao Luo's "android Source Scenario Analysis book"):

Source code Compilation

Kernel compilation

ADB connection Simulator

------------------------------------------------------------------------------------

After that, a simple Android program Helloandroid was written in the Android source environment.

The file structure is as follows:

~/android/packages/experimental/helloandroid

Androidmanifest.xml

Android.mk

Src

Com/hello

Helloandroid.java

Res

Layout

Main.xml

Values

String.xml

Drawable

Icon.png

Very simple basic structure, the contents of nothing to say, may need to explain is android.mk inside the content.

Local_path: = $ (call My-dir)

Include $ (clear_vars)

Local_module_tags: = Optional

Local_src_files: = $ (call all-subdir-java-files)

Local_package_name: = helloandroid

Include $ (build_package)

As for what ANDROID.MK is and what the syntax of this script means, you can refer to this blog: http://blog.csdn.net/wh_19910525/article/details/7519919

When our program is written, it is time to compile, start, the MMM command is not available, we need to execute in the current terminal Android source code directory build/envsetup.sh script file can be used.

$ source./build/envsetup.sh

After the execution, we can use the MMM command.

$ mmm./packages/experimental/helloandroid/

This time, our location should be in the root directory of Android source code.


Here are some of the errors encountered in this process:

1.build/core/java.mk:9: * * * (call My-dir): Target Java module does not define any source or resource files. Stop.

This problem can be seen should be android.mk provided the location of the wrong, resulting in the compile time, did not find this file, carefully examined the android.mk script, found in Local_path: = $ here more than a space (call my-dir) reason, get rid of it and recompile.


2.package/experimental/helloandroid/res/values/string.xml:1:error:error parsing xml:no element found

Package/experimental/helloandroid/res/layout/main.xml:8:error:errorthis attribute must be localized. (at ' text ' with value ' helloandroid ').

This two is actually the same problem, the reason is very simple, is a textview inside the Mian.xml set the Text property, I do not have local words, that is, do not use the resources in string, but directly write the string, we have used eclipse all know, this in the IDE will give a warning, in this will compile unsuccessful.


And then in accordance with the compilation process error, fix some simple problem, probably that character is wrong to write the same, (said, has been using the IDE to develop, suddenly completely manually to build an Android project, said a variety of not to write Ah, see this way, with the IDE to use the people are silly! ~ Sweat).


After that, the hint is successful:install:out/target/product/generic/system/app/helloandroid.apk


The next step is to look at the effect in the simulator first to regenerate the system.img in Out/target/product/generic.

$ make Snod

This command can only repackage the system.img of the Android system image file, but the west side just succeeds.

Target System FS Image:out/target/product/generic/system.img


Before we succeeded in compiling the source code, some environment variables were set up when we started the simulator:

Export path= $PATH:/usr/local/android/android2.3.7/out/host/linux-x86/bin

Export Android_product_out=/usr/local/android/android_2.3.7/out/target/product/generic

Emulator-kernel./kernel/private_guo/kernel/arch/arm/boot/zimage

This inside Android_product_out is an environment variable, starting the simulator requires four files, namely Zimage, System.img, Userdata.img, Ramdisk.img boot, the previous is the kernel image, we will compile the kernel when we can see, the result is a zimage, the following three is the Android system image file.


OK, start the simulator again.

Dumbfounded, reported a mistake:

Emulator:ERROR:could not find required RAMDisk image (RAMDISK.IMG).
Emulator:did You build everything?

This error is very easy to understand, Is my ramdisk.img no, of course, simulator can not start, so, I ran over to see a bit, my ramdisk.img is not, only system.img and userdata.img, this I really do not know why AH. There was no way, I had to make it again, fortunately the second time will be very soon, and then compiled. If anyone knows the problem, you can tell me!


Sure enough, after a while, after recompiling, my ramdisk.img back, this problem first uncovered, run a simulator to see.

You can see that the program is already inside:


Click to see the effect:


Well, although the process has a little bumpy, but somehow the result is out, as for the loss of ramdisk.img, need to further research and research AH.


Compiling an Android project Error record in Linux environment using MMM command

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.