Partial revert of r7014 (Android APK refactor)

This reverts selected parts of r7014 to enable
rolling WebRTC in Chromium DEPS.

This works around the problem with GYP includes
being processed in the first pass (i.e. variables
cannot be used for paths). Using a dependency with
a path using a variable that is conditioned for
build_with_chromium being 0 or 1 solves the Chromium
build.

These changes will be restored once I've finished
a major GYP refactoring that will break out all
test related code (at least the parts that includes
the Android APK targets) into a separate chain
of GYP targets that are not processed when generating
projects for Chromium (which is why r7014 is breaking
the Chromium build).

BUG=3741
TESTED=Passing compilation of standalone using:
GYP_DEFINES="OS=android component=static_library fastbuild=1 target_arch=arm" webrtc/build/gyp_webrtc
ninja -C out/Debug
Then verified the *_apk  targets are generated and compiled.

Passing compilation from a Chromium checkout with third_party/webrtc
directory removed and a new empty third_party/webrtc mapped to the
standalone checkout using:
sudo mount --bind /path/to/trunk/webrtc third_party/webrtc
Then running build/gyp_chromium
I also verified WebRTC GYP targets exist and are able to compile.

R=henrike@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/20299004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7040 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/build/apk_tests.gyp b/webrtc/build/apk_tests.gyp
new file mode 100644
index 0000000..eed0799
--- /dev/null
+++ b/webrtc/build/apk_tests.gyp
@@ -0,0 +1,235 @@
+# Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
+#
+# Use of this source code is governed by a BSD-style license
+# that can be found in the LICENSE file in the root of the source
+# tree. An additional intellectual property rights grant can be found
+# in the file PATENTS.  All contributing project authors may
+# be found in the AUTHORS file in the root of the source tree.
+
+# This file exists in two versions. A no-op version under
+# webrtc/build/apk_tests_noop.gyp and this one. This gyp file builds the apk
+# unit tests (for Android) assuming that WebRTC is built inside a Chromium
+# workspace. The no-op version is included when building WebRTC without
+# Chromium. This is a workaround for the fact that 'includes' don't expand
+# variables and that the relative location of apk_test.gypi is different for
+# WebRTC when built as part of Chromium and when it is built without Chromium.
+{
+  'includes': [
+    'common.gypi',
+  ],
+  'targets': [
+    {
+      'target_name': 'audio_decoder_unittests_apk',
+      'type': 'none',
+      'variables': {
+        'test_suite_name': 'audio_decoder_unittests',
+        'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)audio_decoder_unittests<(SHARED_LIB_SUFFIX)',
+      },
+      'dependencies': [
+        '<(webrtc_root)/modules/modules.gyp:audio_decoder_unittests',
+      ],
+      'includes': [
+        '../../build/apk_test.gypi',
+      ],
+    },
+    {
+      'target_name': 'common_audio_unittests_apk',
+      'type': 'none',
+      'variables': {
+        'test_suite_name': 'common_audio_unittests',
+        'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)common_audio_unittests<(SHARED_LIB_SUFFIX)',
+      },
+      'dependencies': [
+        '<(webrtc_root)/common_audio/common_audio.gyp:common_audio_unittests',
+      ],
+      'includes': [
+        '../../build/apk_test.gypi',
+      ],
+    },
+    {
+      'target_name': 'common_video_unittests_apk',
+      'type': 'none',
+      'variables': {
+        'test_suite_name': 'common_video_unittests',
+        'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)common_video_unittests<(SHARED_LIB_SUFFIX)',
+      },
+      'dependencies': [
+        '<(webrtc_root)/common_video/common_video_unittests.gyp:common_video_unittests',
+      ],
+      'includes': [
+        '../../build/apk_test.gypi',
+      ],
+    },
+    {
+      'target_name': 'modules_tests_apk',
+      'type': 'none',
+      'variables': {
+        'test_suite_name': 'modules_tests',
+        'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)modules_tests<(SHARED_LIB_SUFFIX)',
+      },
+      'dependencies': [
+        '<(webrtc_root)/modules/modules.gyp:modules_tests',
+      ],
+      'includes': [
+        '../../build/apk_test.gypi',
+      ],
+    },
+    {
+      'target_name': 'modules_unittests_apk',
+      'type': 'none',
+      'variables': {
+        'test_suite_name': 'modules_unittests',
+        'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)modules_unittests<(SHARED_LIB_SUFFIX)',
+      },
+      'dependencies': [
+        '<(webrtc_root)/modules/modules.gyp:modules_unittests',
+      ],
+      'includes': [
+        '../../build/apk_test.gypi',
+      ],
+    },
+    {
+      'target_name': 'system_wrappers_unittests_apk',
+      'type': 'none',
+      'variables': {
+        'test_suite_name': 'system_wrappers_unittests',
+        'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)system_wrappers_unittests<(SHARED_LIB_SUFFIX)',
+      },
+      'dependencies': [
+        '<(webrtc_root)/system_wrappers/source/system_wrappers_tests.gyp:system_wrappers_unittests',
+      ],
+      'includes': [
+        '../../build/apk_test.gypi',
+      ],
+    },
+    {
+      'target_name': 'test_support_unittests_apk',
+      'type': 'none',
+      'variables': {
+        'test_suite_name': 'test_support_unittests',
+        'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)test_support_unittests<(SHARED_LIB_SUFFIX)',
+      },
+      'dependencies': [
+        '<(webrtc_root)/test/test.gyp:test_support_unittests',
+      ],
+      'includes': [
+        '../../build/apk_test.gypi',
+      ],
+    },
+    {
+      'target_name': 'tools_unittests_apk',
+      'type': 'none',
+      'variables': {
+        'test_suite_name': 'tools_unittests',
+        'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)tools_unittests<(SHARED_LIB_SUFFIX)',
+      },
+      'dependencies': [
+        '<(webrtc_root)/tools/tools.gyp:tools_unittests',
+      ],
+      'includes': [
+        '../../build/apk_test.gypi',
+      ],
+    },
+    {
+      'target_name': 'video_engine_core_unittests_apk',
+      'type': 'none',
+      'variables': {
+        'test_suite_name': 'video_engine_core_unittests',
+        'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)video_engine_core_unittests<(SHARED_LIB_SUFFIX)',
+      },
+      'dependencies': [
+        '<(webrtc_root)/video_engine/video_engine.gyp:video_engine_core_unittests',
+      ],
+      'includes': [
+        '../../build/apk_test.gypi',
+      ],
+    },
+    {
+      'target_name': 'video_engine_tests_apk',
+      'type': 'none',
+      'variables': {
+        'test_suite_name': 'video_engine_tests',
+        'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)video_engine_tests<(SHARED_LIB_SUFFIX)',
+      },
+      'dependencies': [
+        '<(webrtc_root)/webrtc.gyp:video_engine_tests',
+      ],
+      'includes': [
+        '../../build/apk_test.gypi',
+      ],
+     },
+     {
+      'target_name': 'voice_engine_unittests_apk',
+      'type': 'none',
+      'variables': {
+        'test_suite_name': 'voice_engine_unittests',
+        'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)voice_engine_unittests<(SHARED_LIB_SUFFIX)',
+      },
+      'dependencies': [
+        '<(webrtc_root)/voice_engine/voice_engine.gyp:voice_engine_unittests',
+      ],
+      'includes': [
+        '../../build/apk_test.gypi',
+      ],
+    },
+    {
+      'target_name': 'webrtc_perf_tests_apk',
+      'type': 'none',
+      'variables': {
+        'test_suite_name': 'webrtc_perf_tests',
+        'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)webrtc_perf_tests<(SHARED_LIB_SUFFIX)',
+      },
+      'dependencies': [
+        '<(webrtc_root)/webrtc.gyp:webrtc_perf_tests',
+      ],
+      'includes': [
+        '../../build/apk_test.gypi',
+      ],
+    },
+    {
+      'target_name': 'audio_codec_speed_tests_apk',
+      'type': 'none',
+      'variables': {
+        'test_suite_name': 'audio_codec_speed_tests',
+        'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)audio_codec_speed_tests<(SHARED_LIB_SUFFIX)',
+      },
+      'dependencies': [
+        '<(webrtc_root)/modules/modules.gyp:audio_codec_speed_tests',
+      ],
+      'includes': [
+        '../../build/apk_test.gypi',
+      ],
+    },
+    {
+      'target_name': 'video_capture_tests_apk',
+      'type': 'none',
+       'variables': {
+         'test_suite_name': 'video_capture_tests',
+         'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)video_capture_tests<(SHARED_LIB_SUFFIX)',
+       },
+       'dependencies': [
+         '<(webrtc_root)/modules/modules.gyp:video_capture_tests',
+         'video_capture_java',
+       ],
+       'includes': [
+         '../../build/apk_test.gypi',
+       ],
+    },
+    {
+      # Used only by video_capture_tests_apk above, and impossible to use in the
+      # standalone build, which is why it's declared here instead of under
+      # modules/video_capture/ (to avoid the need for a forked _noop.gyp file
+      # like this file has; see comment at the top of this file).
+      'target_name': 'video_capture_java',
+      'type': 'none',
+      'variables': {
+        'java_in_dir': '<(webrtc_root)/modules/video_capture/android/java',
+      },
+      'includes': [
+        '../../build/java.gypi',
+      ],
+    },
+  ],
+}
+
+
diff --git a/webrtc/build/apk_tests_noop.gyp b/webrtc/build/apk_tests_noop.gyp
new file mode 100644
index 0000000..3523e79
--- /dev/null
+++ b/webrtc/build/apk_tests_noop.gyp
@@ -0,0 +1,69 @@
+# Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
+#
+# Use of this source code is governed by a BSD-style license
+# that can be found in the LICENSE file in the root of the source
+# tree. An additional intellectual property rights grant can be found
+# in the file PATENTS.  All contributing project authors may
+# be found in the AUTHORS file in the root of the source tree.
+
+# See webrtc/build/apk_tests.gyp for more information about this file.
+{
+  'targets': [
+    {
+      'target_name': 'audio_decoder_unittests_apk',
+      'type': 'none',
+    },
+    {
+      'target_name': 'common_audio_unittests_apk',
+      'type': 'none',
+    },
+    {
+      'target_name': 'common_video_unittests_apk',
+      'type': 'none',
+    },
+    {
+      'target_name': 'modules_tests_apk',
+      'type': 'none',
+    },
+    {
+      'target_name': 'modules_unittests_apk',
+      'type': 'none',
+    },
+    {
+      'target_name': 'system_wrappers_unittests_apk',
+      'type': 'none',
+    },
+    {
+      'target_name': 'test_support_unittests_apk',
+      'type': 'none',
+    },
+    {
+      'target_name': 'tools_unittests_apk',
+      'type': 'none',
+    },
+    {
+      'target_name': 'video_engine_core_unittests_apk',
+      'type': 'none',
+    },
+    {
+      'target_name': 'video_engine_tests_apk',
+      'type': 'none',
+    },
+    {
+      'target_name': 'voice_engine_unittests_apk',
+      'type': 'none',
+    },
+    {
+      'target_name': 'webrtc_perf_tests_apk',
+      'type': 'none',
+    },
+    {
+      'target_name': 'audio_codec_speed_tests_apk',
+      'type': 'none',
+    },
+    {
+      'target_name': 'video_capture_tests_apk',
+      'type': 'none',
+    },
+  ],
+}
diff --git a/webrtc/build/common.gypi b/webrtc/build/common.gypi
index 6d7d533..6a911f8 100644
--- a/webrtc/build/common.gypi
+++ b/webrtc/build/common.gypi
@@ -23,11 +23,13 @@
           ['build_with_chromium==1', {
             'build_with_libjingle': 1,
             'webrtc_root%': '<(DEPTH)/third_party/webrtc',
+            'apk_tests_path%': '<(DEPTH)/third_party/webrtc/build/apk_tests_noop.gyp',
             'modules_java_gyp_path%': '<(DEPTH)/third_party/webrtc/modules/modules_java_chromium.gyp',
             'gen_core_neon_offsets_gyp%': '<(DEPTH)/third_party/webrtc/modules/audio_processing/gen_core_neon_offsets_chromium.gyp',
           }, {
             'build_with_libjingle%': 0,
             'webrtc_root%': '<(DEPTH)/webrtc',
+            'apk_tests_path%': '<(DEPTH)/webrtc/build/apk_tests.gyp',
             'modules_java_gyp_path%': '<(DEPTH)/webrtc/modules/modules_java.gyp',
             'gen_core_neon_offsets_gyp%':'<(DEPTH)/webrtc/modules/audio_processing/gen_core_neon_offsets.gyp',
           }],
@@ -36,6 +38,7 @@
       'build_with_chromium%': '<(build_with_chromium)',
       'build_with_libjingle%': '<(build_with_libjingle)',
       'webrtc_root%': '<(webrtc_root)',
+      'apk_tests_path%': '<(apk_tests_path)',
       'modules_java_gyp_path%': '<(modules_java_gyp_path)',
       'gen_core_neon_offsets_gyp%': '<(gen_core_neon_offsets_gyp)',
       'webrtc_vp8_dir%': '<(webrtc_root)/modules/video_coding/codecs/vp8',
@@ -45,6 +48,7 @@
     'build_with_chromium%': '<(build_with_chromium)',
     'build_with_libjingle%': '<(build_with_libjingle)',
     'webrtc_root%': '<(webrtc_root)',
+    'apk_tests_path%': '<(apk_tests_path)',
     'modules_java_gyp_path%': '<(modules_java_gyp_path)',
     'gen_core_neon_offsets_gyp%': '<(gen_core_neon_offsets_gyp)',
     'webrtc_vp8_dir%': '<(webrtc_vp8_dir)',
diff --git a/webrtc/common_audio/common_audio.gyp b/webrtc/common_audio/common_audio.gyp
index 699a7eb..e9abf82 100644
--- a/webrtc/common_audio/common_audio.gyp
+++ b/webrtc/common_audio/common_audio.gyp
@@ -240,17 +240,10 @@
         ['OS=="android"', {
           'targets': [
             {
-              'target_name': 'common_audio_unittests_apk',
+              'target_name': 'common_audio_unittests_apk_target',
               'type': 'none',
-              'variables': {
-                'test_suite_name': 'common_audio_unittests',
-                'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)common_audio_unittests<(SHARED_LIB_SUFFIX)',
-              },
               'dependencies': [
-                'common_audio_unittests',
-              ],
-              'includes': [
-                '../../build/apk_test.gypi',
+                '<(apk_tests_path):common_audio_unittests_apk',
               ],
             },
           ],
diff --git a/webrtc/common_video/common_video_unittests.gyp b/webrtc/common_video/common_video_unittests.gyp
index b839e85..0405ba0 100644
--- a/webrtc/common_video/common_video_unittests.gyp
+++ b/webrtc/common_video/common_video_unittests.gyp
@@ -42,17 +42,10 @@
     ['OS=="android"', {
       'targets': [
         {
-          'target_name': 'common_video_unittests_apk',
+          'target_name': 'common_video_unittests_apk_target',
           'type': 'none',
-          'variables': {
-            'test_suite_name': 'common_video_unittests',
-            'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)common_video_unittests<(SHARED_LIB_SUFFIX)',
-          },
           'dependencies': [
-            'common_video_unittests',
-          ],
-          'includes': [
-            '../../build/apk_test.gypi',
+            '<(apk_tests_path):common_video_unittests_apk',
           ],
         },
       ],
diff --git a/webrtc/modules/audio_coding/codecs/tools/audio_codec_speed_tests.gypi b/webrtc/modules/audio_coding/codecs/tools/audio_codec_speed_tests.gypi
index 30a8715..6503a51 100644
--- a/webrtc/modules/audio_coding/codecs/tools/audio_codec_speed_tests.gypi
+++ b/webrtc/modules/audio_coding/codecs/tools/audio_codec_speed_tests.gypi
@@ -37,17 +37,10 @@
     ['OS=="android"', {
       'targets': [
         {
-          'target_name': 'audio_codec_speed_tests_apk',
+          'target_name': 'audio_codec_speed_tests_apk_target',
           'type': 'none',
-          'variables': {
-            'test_suite_name': 'audio_codec_speed_tests',
-            'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)audio_codec_speed_tests<(SHARED_LIB_SUFFIX)',
-          },
           'dependencies': [
-            'audio_codec_speed_tests',
-          ],
-          'includes': [
-            '../../../../../build/apk_test.gypi',
+            '<(apk_tests_path):audio_codec_speed_tests_apk',
           ],
         },
       ],
diff --git a/webrtc/modules/audio_coding/neteq/neteq.gypi b/webrtc/modules/audio_coding/neteq/neteq.gypi
index 2bdb359..01143bc 100644
--- a/webrtc/modules/audio_coding/neteq/neteq.gypi
+++ b/webrtc/modules/audio_coding/neteq/neteq.gypi
@@ -201,17 +201,10 @@
         ['OS=="android"', {
           'targets': [
             {
-              'target_name': 'audio_decoder_unittests_apk',
+              'target_name': 'audio_decoder_unittests_apk_target',
               'type': 'none',
-              'variables': {
-                'test_suite_name': 'audio_decoder_unittests',
-                'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)audio_decoder_unittests<(SHARED_LIB_SUFFIX)',
-              },
               'dependencies': [
-                'audio_decoder_unittests',
-              ],
-              'includes': [
-                '../../../../build/apk_test.gypi',
+                '<(apk_tests_path):audio_decoder_unittests_apk',
               ],
             },
           ],
diff --git a/webrtc/modules/modules.gyp b/webrtc/modules/modules.gyp
index 7254fee..8ea3079 100644
--- a/webrtc/modules/modules.gyp
+++ b/webrtc/modules/modules.gyp
@@ -367,31 +367,17 @@
         ['OS=="android"', {
           'targets': [
             {
-              'target_name': 'modules_unittests_apk',
+              'target_name': 'modules_unittests_apk_target',
               'type': 'none',
-              'variables': {
-                'test_suite_name': 'modules_unittests',
-                'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)modules_unittests<(SHARED_LIB_SUFFIX)',
-              },
               'dependencies': [
-                'modules_unittests',
-              ],
-              'includes': [
-                '../../build/apk_test.gypi',
+                '<(apk_tests_path):modules_unittests_apk',
               ],
             },
             {
-              'target_name': 'modules_tests_apk',
+              'target_name': 'modules_tests_apk_target',
               'type': 'none',
-              'variables': {
-                'test_suite_name': 'modules_tests',
-                'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)modules_tests<(SHARED_LIB_SUFFIX)',
-              },
               'dependencies': [
-                'modules_tests',
-              ],
-              'includes': [
-                '../../build/apk_test.gypi',
+                '<(apk_tests_path):modules_tests_apk',
               ],
             },
           ],
diff --git a/webrtc/modules/video_capture/video_capture.gypi b/webrtc/modules/video_capture/video_capture.gypi
index 1a26eef..0e874c4 100644
--- a/webrtc/modules/video_capture/video_capture.gypi
+++ b/webrtc/modules/video_capture/video_capture.gypi
@@ -141,34 +141,13 @@
   ],
   'conditions': [
     ['include_tests==1 and OS=="android"', {
-      'targets': [
-        {
-          'target_name': 'video_capture_tests_apk',
-          'type': 'none',
-          'variables': {
-            'test_suite_name': 'video_capture_tests',
-            'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)video_capture_tests<(SHARED_LIB_SUFFIX)',
-          },
-          'dependencies': [
-            'video_capture_tests',
-            'video_capture_java',
-          ],
-          'includes': [
-            '../../../build/apk_test.gypi',
-          ],
-        },
-        {
-          # Used only by video_capture_tests_apk above.
-          'target_name': 'video_capture_java',
-          'type': 'none',
-          'variables': {
-            'java_in_dir': '<(webrtc_root)/modules/video_capture/android/java',
-          },
-          'includes': [
-            '../../../build/java.gypi',
-          ],
-        },
-      ],
+      # Use WebRTC capture code for Android APK tests that are built from a
+      # Chromium checkout. Normally when built as a part of Chromium the
+      # Chromium video capture code is used. This overrides the default in
+      # webrtc/build/common.gypi.
+      'variables': {
+        'include_internal_video_capture': 1,
+      },
     }],
     ['include_tests==1', {
       'targets': [
diff --git a/webrtc/system_wrappers/source/system_wrappers_tests.gyp b/webrtc/system_wrappers/source/system_wrappers_tests.gyp
index 29ac602..75081b9 100644
--- a/webrtc/system_wrappers/source/system_wrappers_tests.gyp
+++ b/webrtc/system_wrappers/source/system_wrappers_tests.gyp
@@ -58,20 +58,13 @@
     },
   ],
   'conditions': [
-    ['OS=="android"', {
+    ['include_tests==1 and OS=="android"', {
       'targets': [
         {
-          'target_name': 'system_wrappers_unittests_apk',
+          'target_name': 'system_wrappers_unittests_apk_target',
           'type': 'none',
-          'variables': {
-            'test_suite_name': 'system_wrappers_unittests',
-            'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)system_wrappers_unittests<(SHARED_LIB_SUFFIX)',
-          },
           'dependencies': [
-            'system_wrappers_unittests',
-          ],
-          'includes': [
-            '../../../build/apk_test.gypi',
+            '<(apk_tests_path):system_wrappers_unittests_apk',
           ],
         },
       ],
diff --git a/webrtc/test/test.gyp b/webrtc/test/test.gyp
index 54634fa..f4467ca 100644
--- a/webrtc/test/test.gyp
+++ b/webrtc/test/test.gyp
@@ -223,20 +223,13 @@
         },  # target buildbot_tests_scripts
       ],
     }],
-    ['OS=="android"', {
+    ['include_tests==1 and OS=="android"', {
       'targets': [
         {
-          'target_name': 'test_support_unittests_apk',
+          'target_name': 'test_support_unittests_apk_target',
           'type': 'none',
-          'variables': {
-            'test_suite_name': 'test_support_unittests',
-            'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)test_support_unittests<(SHARED_LIB_SUFFIX)',
-          },
           'dependencies': [
-            'test_support_unittests',
-          ],
-          'includes': [
-            '../../build/apk_test.gypi',
+            '<(apk_tests_path):test_support_unittests_apk',
           ],
         },
       ],
diff --git a/webrtc/tools/tools.gyp b/webrtc/tools/tools.gyp
index 0a38c90..38a19fc 100644
--- a/webrtc/tools/tools.gyp
+++ b/webrtc/tools/tools.gyp
@@ -147,17 +147,10 @@
         ['OS=="android"', {
           'targets': [
             {
-              'target_name': 'tools_unittests_apk',
+              'target_name': 'tools_unittests_apk_target',
               'type': 'none',
-              'variables': {
-                'test_suite_name': 'tools_unittests',
-                'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)tools_unittests<(SHARED_LIB_SUFFIX)',
-              },
               'dependencies': [
-                'tools_unittests',
-              ],
-              'includes': [
-                '../../build/apk_test.gypi',
+                '<(apk_tests_path):tools_unittests_apk',
               ],
             },
           ],
diff --git a/webrtc/video_engine/video_engine_core.gypi b/webrtc/video_engine/video_engine_core.gypi
index 76c7018..8ce2523 100644
--- a/webrtc/video_engine/video_engine_core.gypi
+++ b/webrtc/video_engine/video_engine_core.gypi
@@ -148,19 +148,12 @@
         ['OS=="android"', {
           'targets': [
             {
-              'target_name': 'video_engine_core_unittests_apk',
+              'target_name': 'video_engine_core_unittests_apk_target',
               'type': 'none',
-              'variables': {
-                'test_suite_name': 'video_engine_core_unittests',
-                'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)video_engine_core_unittests<(SHARED_LIB_SUFFIX)',
-              },
               'dependencies': [
-                'video_engine_core_unittests',
+                '<(apk_tests_path):video_engine_core_unittests_apk',
               ],
-              'includes': [
-                '../../build/apk_test.gypi',
-              ],
-             },
+            },
           ],
         }],
         ['test_isolation_mode != "noop"', {
diff --git a/webrtc/voice_engine/voice_engine.gyp b/webrtc/voice_engine/voice_engine.gyp
index 99a7886..deed467 100644
--- a/webrtc/voice_engine/voice_engine.gyp
+++ b/webrtc/voice_engine/voice_engine.gyp
@@ -275,17 +275,10 @@
         ['OS=="android"', {
           'targets': [
             {
-              'target_name': 'voice_engine_unittests_apk',
+              'target_name': 'voice_engine_unittests_apk_target',
               'type': 'none',
-              'variables': {
-                'test_suite_name': 'voice_engine_unittests',
-                'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)voice_engine_unittests<(SHARED_LIB_SUFFIX)',
-              },
               'dependencies': [
-                'voice_engine_unittests',
-              ],
-              'includes': [
-                '../../build/apk_test.gypi',
+                '<(apk_tests_path):voice_engine_unittests_apk',
               ],
             },
           ],
diff --git a/webrtc/webrtc_tests.gypi b/webrtc/webrtc_tests.gypi
index 4bbc5df..68b738d 100644
--- a/webrtc/webrtc_tests.gypi
+++ b/webrtc/webrtc_tests.gypi
@@ -130,31 +130,17 @@
     ['OS=="android"', {
       'targets': [
         {
-          'target_name': 'video_engine_tests_apk',
+          'target_name': 'video_engine_tests_apk_target',
           'type': 'none',
-          'variables': {
-            'test_suite_name': 'video_engine_tests',
-            'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)video_engine_tests<(SHARED_LIB_SUFFIX)',
-          },
           'dependencies': [
-            'video_engine_tests',
-          ],
-          'includes': [
-            '../build/apk_test.gypi',
+            '<(apk_tests_path):video_engine_tests_apk',
           ],
         },
         {
-          'target_name': 'webrtc_perf_tests_apk',
+          'target_name': 'webrtc_perf_tests_apk_target',
           'type': 'none',
-          'variables': {
-            'test_suite_name': 'webrtc_perf_tests',
-            'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)webrtc_perf_tests<(SHARED_LIB_SUFFIX)',
-          },
           'dependencies': [
-            'webrtc_perf_tests',
-          ],
-          'includes': [
-            '../build/apk_test.gypi',
+            '<(apk_tests_path):webrtc_perf_tests_apk',
           ],
         },
       ],