B02a: Fix your First Build Issue

B02a: Fix your First Build Issue

Try to Build the Source Code

Navigate to the ~/android directory. This task assumes you're in the same shell environment you have configured in B01c: Setup AOSP Build Environment.

Now start building the source with

m -j24

Don't worry about the argument -j24 for now. It will be explained in a later exercise.

Under normal circumstances, this command would take several hours to complete. However, for the source code release *_lts4 and the selected build target aosp_cf_x86_64_auto it quickly fails with an error.

The error you should see is:

platform_testing/build/tasks/tests/native_test_list.mk: error: continuous_native_tests: Unknown installed file for module 'sv_2d_session_tests'
platform_testing/build/tasks/tests/native_test_list.mk: error: continuous_native_tests: Unknown installed file for module 'sv_3d_session_tests'
In file included from build/make/core/main.mk:1469:
In file included from build/make/core/Makefile:7667:
In file included from platform_testing/build/tasks/continuous_native_tests.mk:27:
build/make/core/tasks/tools/package-modules.mk:93: error: done.
18:01:37 ckati failed with: exit status 1

#### failed to build some targets (01:10 (mm:ss)) ####

That is bad. The source code does not built. But it’s often the case for large projects, like the AOSP, that some build configurations are broken.

The next sections walk you trough the process of debugging and fixing this build issue.

Note

The next sections will guide you through the exercise and provide the solutions, too. Don't just read passively. Instead, try to perform the steps on the command line yourself and invest the effort of solving the issue at hand!

Selecting a Search Term

Find a string or symbol name to search for. In our case you may use name of the failing modules, e.g., sv_2d_session_tests and sv_3d_session_tests.

Using this search term you can find the right place in the source code and learn more about it.

Let's go with sv_2d_session_tests for now.

Searching the AOSP Code Base

There are some special grepping tools in the AOSP environment. Here just use mgrep to search in Android.mk and Android.bp files. It will be explained in more detail later.

When you type in the command mgrep sv_2d_session_tests, you get the output:

./platform_testing/build/tasks/tests/native_test_list.mk:240:    sv_2d_session_tests \

There is only one result for the search term sv_2d_session_tests. The match is found in one file in a subdirectory of platform_testing.

When you look into the file

platform_testing/build/tasks/tests/native_test_list.mk

you see that two modules, sv_2d_session_tests and sv_3d_session_tests are added to native-tests, a variable that combines a lot of targets that are built together.

Also, you can see that this line is the only line/file that contains the string sv_2d_session_tests. There is no Android.bp file that is defining the module, e.g. adding some C/C++ sources to build something.

This is strange. Where is the source code of that sv_2d_session_tests tests?

Tip

See also some other tips in the blog post AOSP: Advanced Development Tricks under the topic “grep faster”.

Search Online on cs.android.com

Let’s search the entire AOSP tree and all versions on cs.android.com for the string sv_2d_session_tests:

Warning

There's currently a known and reported issue with cs.android.com.

The search won't show any results.

The code is still there. Use the direct links below.

There is only a single file where the string is found. See https://cs.android.com/android/platform/superproject/+/android14-qpr3-release:platform_testing/build/tasks/tests/native_test_list.mk?q=sv_2d_session_tests&ss=android

This is super strange. There is no source code for that module sv_2d_session_tests. It seems that it’s a tool that was not released as open source by Google. It’s used in the AOSP source code internally at Google, but wasn't published.

When you do a git blame, on the line for sv_2d_session_tests, you will find the commit b6975bd

See the link: https://cs.android.com/android/platform/superproject/+/android14-qpr3-release:platform_testing/build/tasks/tests/native_test_list.mk;bpv=1;bpt=0

It just adds the two lines sv_2d_session_tests and sv_3d_session_tests.

The Fix

Since there is no released source code for these two build modules and it exists only for testing, it is most likely safe to just remove the whole lines. These modules were removed a couple of releases ago. We just sneakily added them back in to give you a problem to work on.

At the moment th output of repo diff should look similar to this:

project platform_testing/
diff --git a/build/tasks/tests/native_test_list.mk b/build/tasks/tests/native_test_list.mk
index bf671731f..64e1e9584 100644
--- a/build/tasks/tests/native_test_list.mk
+++ b/build/tasks/tests/native_test_list.mk
@@ -236,7 +236,9 @@ native_tests := \
 ifeq ($(BOARD_IS_AUTOMOTIVE), true)
 native_tests += \
     libwatchdog_test \
-    evsmanagerd_test
+    evsmanagerd_test \
+    sv_2d_session_tests \
+    sv_3d_session_tests
 endif

ifneq ($(strip $(BOARD_PERFSETUP_SCRIPT)),)

You can now either edit and remove these two lines by hand using your favorite editor:

nano platform_testing/build/tasks/tests/native_test_list.mk

Or enter the platform_testing folder, and run git reset --hard which will revert to a working setup.

The output of repo diff should now be empty.

Testing the Fix

To test if the fix is sufficient, continue compiling the AOSP source code. E.g.

m -j24

Since your tree has not been built before, the above command will take a while to complete.

When the built has finished successfully, the following output will be shown:

#### build completed successfully (XX seconds) ####

Great. The fix was sufficient and the build is successful.

Note

The build does not need a lot of time to exit successfully. We have pre-built it to speed up the exercise.