diff --git a/Android.bp b/Android.bp
deleted file mode 100644
index 4335e618ceeaa72b7ccafdedb154808f452b9f51..0000000000000000000000000000000000000000
--- a/Android.bp
+++ /dev/null
@@ -1,105 +0,0 @@
-soong_namespace {
-    imports: [
-        "device/google/cheets2/codec2",
-        "hardware/google/av",
-    ],
-}
-
-cc_library_shared {
-    name: "libv4l2_codec2_arcva_factory",
-    vendor_available: true,
-    product_variables: {
-        arc: {
-            srcs: ["C2ArcVideoAcceleratorFactory.cpp"],
-
-            shared_libs: [
-                "libarcbridge",
-                "libarcbridgeservice",
-                "libarcvideobridge",
-                "libbinder",
-                "libchrome",
-                "liblog",
-                "libmojo",
-                "libutils",
-            ],
-
-            // -Wno-unused-parameter is needed for libchrome/base codes
-            cflags: [
-                "-Wall",
-                "-Werror",
-                "-Wno-unused-parameter",
-                "-std=c++14",
-            ],
-        },
-    },
-    clang: true,
-    export_include_dirs: [
-        "include",
-    ],
-}
-
-cc_library_shared {
-    name: "libv4l2_codec2",
-
-    srcs: [
-        "C2VDAComponent.cpp",
-        "C2VDAAdaptor.cpp",
-    ],
-
-    shared_libs: [
-        "libbinder",
-        "libchrome",
-        "liblog",
-        "libmedia",
-        "libstagefright",
-        "libstagefright_codec2",
-        "libstagefright_codec2_vndk",
-        "libstagefright_foundation",
-        "libstagefright_simple_c2component",
-        "libutils",
-        "libv4l2_codec2_vda",
-        "libvda_c2componentstore",
-    ],
-
-    cflags: [
-        "-Wall",
-        "-Werror",
-        "-Wno-unknown-warning-option",
-        "-Wno-unused-lambda-capture",
-        "-Wno-unused-parameter",
-        "-std=c++14",
-    ],
-
-    clang: true,
-
-    sanitize: {
-        misc_undefined: [
-            "unsigned-integer-overflow",
-            "signed-integer-overflow",
-        ],
-    },
-
-    ldflags: [
-        "-Wl",
-        "-Bsymbolic",
-    ],
-
-    product_variables: {
-        arc: {
-            srcs: ["C2VDAAdaptorProxy.cpp"],
-            exclude_srcs : ["C2VDAAdaptor.cpp"],
-            shared_libs: [
-                "libarcbridge",
-                "libarcbridgeservice",
-                "libmojo",
-                "libv4l2_codec2_arcva_factory",
-            ],
-            cflags: [
-                "-DV4L2_CODEC2_ARC",
-            ],
-        }
-    },
-    export_include_dirs: [
-        "include",
-    ],
-}
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000000000000000000000000000000000000..0ba1e46bb6b211847bf2c3252d017b99bfca4404
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,97 @@
+# Build only if both hardware/google/av and device/google/cheets2/codec2 are
+# visible; otherwise, don't build any target under this repository.
+ifneq (,$(findstring hardware/google/av,$(PRODUCT_SOONG_NAMESPACES)))
+ifneq (,$(findstring device/google/cheets2/codec2,$(PRODUCT_SOONG_NAMESPACES)))
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+# Build C2ArcVideoAcceleratorFactory only in cheets build.
+ifneq (,$(findstring cheets_,$(TARGET_PRODUCT)))
+LOCAL_SRC_FILES:= \
+                   C2ArcVideoAcceleratorFactory.cpp \
+
+LOCAL_C_INCLUDES := \
+        $(TOP)/external/gtest/include \
+        $(TOP)/external/libchrome \
+        $(TOP)/external/v4l2_codec2/include \
+
+LOCAL_MODULE:= libv4l2_codec2_arcva_factory
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SHARED_LIBRARIES += libarcbridge \
+                          libarcbridgeservice \
+                          libarcvideobridge \
+                          libbinder \
+                          libchrome \
+                          liblog \
+                          libmojo \
+                          libutils \
+
+# -Wno-unused-parameter is needed for libchrome/base codes
+LOCAL_CFLAGS := -Werror -Wall -Wno-unused-parameter -std=c++14
+LOCAL_CLANG := true
+
+include $(BUILD_SHARED_LIBRARY)
+include $(CLEAR_VARS)
+endif # ifneq (,$(findstring cheets_,$(TARGET_PRODUCT)))
+
+LOCAL_SRC_FILES:= \
+        C2VDAComponent.cpp \
+        C2VDAAdaptor.cpp   \
+
+LOCAL_C_INCLUDES += \
+        $(TOP)/device/google/cheets2/codec2/vdastore/include \
+        $(TOP)/external/libchrome \
+        $(TOP)/external/gtest/include \
+        $(TOP)/external/v4l2_codec2/include \
+        $(TOP)/external/v4l2_codec2/vda \
+        $(TOP)/frameworks/av/media/libstagefright/include \
+        $(TOP)/hardware/google/av/codec2/include \
+        $(TOP)/hardware/google/av/codec2/vndk/include \
+        $(TOP)/hardware/google/av/media/codecs/base/include \
+
+LOCAL_MODULE:= libv4l2_codec2
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SHARED_LIBRARIES := libbinder \
+                          libchrome \
+                          liblog \
+                          libmedia \
+                          libstagefright \
+                          libstagefright_codec2 \
+                          libstagefright_codec2_vndk \
+                          libstagefright_simple_c2component \
+                          libstagefright_foundation \
+                          libutils \
+                          libv4l2_codec2_vda \
+                          libvda_c2componentstore \
+
+# -Wno-unused-parameter is needed for libchrome/base codes
+LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter -std=c++14
+LOCAL_CFLAGS += -Wno-unused-lambda-capture -Wno-unknown-warning-option
+LOCAL_CLANG := true
+LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow
+
+LOCAL_LDFLAGS := -Wl,-Bsymbolic
+
+# Build C2VDAAdaptorProxy only for ARC++ case.
+ifneq (,$(findstring cheets_,$(TARGET_PRODUCT)))
+LOCAL_CFLAGS += -DV4L2_CODEC2_ARC
+LOCAL_SRC_FILES += \
+                   C2VDAAdaptorProxy.cpp \
+
+LOCAL_SRC_FILES := $(filter-out C2VDAAdaptor.cpp, $(LOCAL_SRC_FILES))
+LOCAL_SHARED_LIBRARIES += libarcbridge \
+                          libarcbridgeservice \
+                          libmojo \
+                          libv4l2_codec2_arcva_factory \
+
+endif # ifneq (,$(findstring cheets_,$(TARGET_PRODUCT)))
+
+include $(BUILD_SHARED_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
+
+endif  #ifneq (,$(findstring device/google/cheets2/codec2,$(PRODUCT_SOONG_NAMESPACES)))
+endif  #ifneq (,$(findstring hardware/google/av,$(PRODUCT_SOONG_NAMESPACES)))
diff --git a/cmds/Android.bp b/cmds/Android.bp
deleted file mode 100644
index c7e7b16e5f3deac3784f12a2dbfaaa21c567857e..0000000000000000000000000000000000000000
--- a/cmds/Android.bp
+++ /dev/null
@@ -1,36 +0,0 @@
-cc_binary {
-    name: "v4l2_codec2_testapp",
-    srcs: ["codec2.cpp"],
-
-    include_dirs: [
-        "frameworks/native/include",
-    ],
-
-    shared_libs: [
-        "android.hardware.media.bufferpool@1.0",
-        "libbinder",
-        "libchrome",
-        "libcutils",
-        "libgui",
-        "liblog",
-        "libmedia",
-        "libmediaextractor",
-        "libstagefright",
-        "libstagefright_codec2",
-        "libstagefright_codec2_vndk",
-        "libstagefright_foundation",
-        "libstagefright_simple_c2component",
-        "libui",
-        "libutils",
-        "libv4l2_codec2",
-        "libv4l2_codec2_vda",
-    ],
-
-    // -Wno-unused-parameter is needed for libchrome/base codes
-    cflags: [
-        "-Wall",
-        "-Werror",
-        "-Wno-unused-parameter",
-    ],
-    clang: true,
-}
diff --git a/cmds/Android.mk b/cmds/Android.mk
new file mode 100644
index 0000000000000000000000000000000000000000..6cc84ae249a3b4f809f80a2d390650fc718191eb
--- /dev/null
+++ b/cmds/Android.mk
@@ -0,0 +1,42 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+        codec2.cpp \
+
+LOCAL_C_INCLUDES += \
+        $(TOP)/external/libchrome \
+        $(TOP)/external/gtest/include \
+        $(TOP)/external/v4l2_codec2/include \
+        $(TOP)/external/v4l2_codec2/vda \
+        $(TOP)/frameworks/av/media/libstagefright/include \
+        $(TOP)/frameworks/native/include \
+        $(TOP)/hardware/google/av/codec2/include \
+        $(TOP)/hardware/google/av/codec2/vndk/include \
+	$(TOP)/hardware/google/av/media/codecs/base/include \
+
+LOCAL_MODULE := v4l2_codec2_testapp
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SHARED_LIBRARIES := libbinder \
+                          libchrome \
+                          libcutils \
+                          libgui \
+                          liblog \
+                          libmedia \
+                          libmediaextractor \
+                          libstagefright \
+                          libstagefright_codec2 \
+                          libstagefright_foundation \
+                          libstagefright_codec2_vndk \
+                          libui \
+                          libutils \
+                          libv4l2_codec2 \
+                          libv4l2_codec2_vda \
+                          android.hardware.media.bufferpool@1.0 \
+
+# -Wno-unused-parameter is needed for libchrome/base codes
+LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter
+LOCAL_CLANG := true
+
+include $(BUILD_EXECUTABLE)
diff --git a/tests/Android.bp b/tests/Android.bp
deleted file mode 100644
index 6c800020b129a43f248a6e6c18113d3deedb8771..0000000000000000000000000000000000000000
--- a/tests/Android.bp
+++ /dev/null
@@ -1,65 +0,0 @@
-cc_test {
-    name: "C2VDACompIntf_test",
-
-    srcs: ["C2VDACompIntf_test.cpp"],
-
-    shared_libs: [
-        "libchrome",
-        "libcutils",
-        "liblog",
-        "libstagefright_codec2",
-        "libstagefright_codec2_vndk",
-        "libstagefright_simple_c2component",
-        "libutils",
-        "libv4l2_codec2",
-        "libv4l2_codec2_vda",
-    ],
-
-    cflags: [
-        "-Werror",
-        "-Wall",
-        "-std=c++14",
-    ],
-    clang: true,
-
-    ldflags: [
-        "-Wl",
-        "-Bsymbolic",
-    ],
-}
-
-cc_test {
-    name: "C2VDAComponent_test",
-    srcs: ["C2VDAComponent_test.cpp"],
-
-    shared_libs: [
-        "android.hardware.media.bufferpool@1.0",
-        "libchrome",
-        "libcutils",
-        "liblog",
-        "libmedia",
-        "libmediaextractor",
-        "libstagefright",
-        "libstagefright_codec2",
-        "libstagefright_codec2_vndk",
-        "libstagefright_foundation",
-        "libstagefright_simple_c2component",
-        "libutils",
-        "libv4l2_codec2",
-        "libv4l2_codec2_vda",
-    ],
-
-    // -Wno-unused-parameter is needed for libchrome/base codes
-    cflags: [
-        "-Wall",
-        "-Werror",
-        "-Wno-unused-parameter",
-        "-std=c++14",
-    ],
-    clang: true,
-
-    ldflags: [
-        "-Wl",
-        "-Bsymbolic",
-    ],
-}
diff --git a/tests/Android.mk b/tests/Android.mk
new file mode 100644
index 0000000000000000000000000000000000000000..4bafb4adff37ef1b62d1aa74b1aa7cecbc89eac2
--- /dev/null
+++ b/tests/Android.mk
@@ -0,0 +1,78 @@
+# Build the unit tests.
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+
+LOCAL_MODULE := C2VDACompIntf_test
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := \
+  C2VDACompIntf_test.cpp \
+
+LOCAL_SHARED_LIBRARIES := \
+  libchrome \
+  libcutils \
+  liblog \
+  libstagefright_codec2 \
+  libstagefright_codec2_vndk \
+  libutils \
+  libv4l2_codec2 \
+  libv4l2_codec2_vda \
+
+LOCAL_C_INCLUDES += \
+  $(TOP)/external/v4l2_codec2/include \
+  $(TOP)/external/v4l2_codec2/vda \
+  $(TOP)/hardware/google/av/codec2/include \
+  $(TOP)/hardware/google/av/codec2/vndk/include \
+  $(TOP)/hardware/google/av/media/codecs/base/include \
+
+LOCAL_CFLAGS += -Werror -Wall -std=c++14
+LOCAL_CLANG := true
+
+LOCAL_LDFLAGS := -Wl,-Bsymbolic
+
+include $(BUILD_NATIVE_TEST)
+
+
+include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+
+LOCAL_MODULE := C2VDAComponent_test
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := \
+  C2VDAComponent_test.cpp \
+
+LOCAL_SHARED_LIBRARIES := \
+  libchrome \
+  libcutils \
+  liblog \
+  libmedia \
+  libmediaextractor \
+  libstagefright \
+  libstagefright_codec2 \
+  libstagefright_codec2_vndk \
+  libstagefright_foundation \
+  libutils \
+  libv4l2_codec2 \
+  libv4l2_codec2_vda \
+  android.hardware.media.bufferpool@1.0 \
+
+LOCAL_C_INCLUDES += \
+  $(TOP)/external/libchrome \
+  $(TOP)/external/v4l2_codec2/include \
+  $(TOP)/external/v4l2_codec2/vda \
+  $(TOP)/frameworks/av/media/libstagefright/include \
+  $(TOP)/hardware/google/av/codec2/include \
+  $(TOP)/hardware/google/av/codec2/vndk/include \
+  $(TOP)/hardware/google/av/media/codecs/base/include \
+
+# -Wno-unused-parameter is needed for libchrome/base codes
+LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter -std=c++14
+LOCAL_CLANG := true
+
+LOCAL_LDFLAGS := -Wl,-Bsymbolic
+
+include $(BUILD_NATIVE_TEST)
diff --git a/vda/Android.bp b/vda/Android.bp
deleted file mode 100644
index 5f8453567a8822cd377f7947d8a980c2082e875c..0000000000000000000000000000000000000000
--- a/vda/Android.bp
+++ /dev/null
@@ -1,53 +0,0 @@
-cc_library_shared {
-    name: "libv4l2_codec2_vda",
-    srcs: [
-        "bit_reader.cc",
-        "bit_reader_core.cc",
-        "bitstream_buffer.cc",
-        "h264_bit_reader.cc",
-        "h264_decoder.cc",
-        "h264_dpb.cc",
-        "h264_parser.cc",
-        "native_pixmap_handle.cc",
-        "picture.cc",
-        "ranges.cc",
-        "shared_memory_region.cc",
-        "v4l2_device.cc",
-        "v4l2_slice_video_decode_accelerator.cc",
-        "v4l2_video_decode_accelerator.cc",
-        "video_codecs.cc",
-        "video_decode_accelerator.cc",
-        "vp8_bool_decoder.cc",
-        "vp8_decoder.cc",
-        "vp8_parser.cc",
-        "vp8_picture.cc",
-        "vp9_bool_decoder.cc",
-        "vp9_compressed_header_parser.cc",
-        "vp9_decoder.cc",
-        "vp9_parser.cc",
-        "vp9_picture.cc",
-        "vp9_raw_bits_reader.cc",
-        "vp9_uncompressed_header_parser.cc",
-    ],
-
-    shared_libs: ["libchrome"],
-    // -Wno-unused-parameter is needed for libchrome/base codes
-    cflags: [
-        "-Wall",
-        "-Werror",
-        "-Wno-unused-parameter",
-    ],
-    clang: true,
-    sanitize: {
-        misc_undefined: [
-            "unsigned-integer-overflow",
-            "signed-integer-overflow",
-        ],
-    },
-
-    ldflags: [
-        "-Wl",
-        "-Bsymbolic",
-    ],
-    export_include_dirs: ["."],
-}
diff --git a/vda/Android.mk b/vda/Android.mk
new file mode 100644
index 0000000000000000000000000000000000000000..12f0ea17624698c9fb07a23840a4df320e45b94f
--- /dev/null
+++ b/vda/Android.mk
@@ -0,0 +1,50 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_CPP_EXTENSION:= .cc
+LOCAL_SRC_FILES:= \
+        bit_reader.cc       \
+        bit_reader_core.cc  \
+        bitstream_buffer.cc \
+        h264_bit_reader.cc  \
+        h264_decoder.cc     \
+        h264_dpb.cc         \
+        h264_parser.cc      \
+        native_pixmap_handle.cc \
+        picture.cc          \
+        ranges.cc           \
+        shared_memory_region.cc \
+        v4l2_device.cc      \
+        v4l2_slice_video_decode_accelerator.cc \
+        v4l2_video_decode_accelerator.cc \
+        video_codecs.cc     \
+        video_decode_accelerator.cc \
+        vp8_bool_decoder.cc \
+        vp8_decoder.cc      \
+        vp8_parser.cc       \
+        vp8_picture.cc      \
+        vp9_bool_decoder.cc \
+        vp9_compressed_header_parser.cc \
+        vp9_decoder.cc      \
+        vp9_parser.cc       \
+        vp9_picture.cc      \
+        vp9_raw_bits_reader.cc \
+        vp9_uncompressed_header_parser.cc \
+
+# gtest/include is for included file from libchrome/base/gtest_prod_util.h
+LOCAL_C_INCLUDES += \
+        $(TOP)/external/libchrome \
+        $(TOP)/external/gtest/include \
+
+LOCAL_MODULE:= libv4l2_codec2_vda
+
+LOCAL_SHARED_LIBRARIES := libchrome \
+
+# -Wno-unused-parameter is needed for libchrome/base codes
+LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter
+LOCAL_CLANG := true
+LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow
+
+LOCAL_LDFLAGS := -Wl,-Bsymbolic
+
+include $(BUILD_SHARED_LIBRARY)