Use prebuilt stub org.apache.http.legacy for unbundled build.

Even though the stub org.apache.http.legacy.jar itself can be
built from source against the SDK, its dependency conscrypt must
be built against libcore-art.
(Actually we could remove the droiddoc module apache-http-stubs-gen's
dependency on conscrypt. It would lead doclava to complain error of
unresolved symbols of conscrypt. Such error isn't fatal because the
stub java files don't reference any conscrypt symbols.)

Also by using prebuilt org.apache.http.legacy, unbundled branches don't
need to pull in external/doclava and its many dependency projects.

Bug: 20221594
Change-Id: I6fb4377d35a70ad544cb8a91695e23625365df60
diff --git a/Android.mk b/Android.mk
index d4c1410..9dffd55 100644
--- a/Android.mk
+++ b/Android.mk
@@ -92,12 +92,14 @@
 include $(BUILD_DROIDDOC)
 apache_http_stubs_gen_stamp := $(full_target)
 
+# For unbundled build we'll use the prebuilt jar from prebuilts/sdk.
+ifeq (,$(TARGET_BUILD_APPS))
 ###############################################
 # Build the stub source files into a jar.
 include $(CLEAR_VARS)
 LOCAL_MODULE := org.apache.http.legacy
-LOCAL_JAVA_LIBRARIES := $(apache_http_java_libs)
 LOCAL_SOURCE_FILES_ALL_GENERATED := true
+LOCAL_SDK_VERSION := 21
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
 # Make sure to run droiddoc first to generate the stub source files.
@@ -106,6 +108,7 @@
 
 # Archive a copy of the classes.jar in SDK build.
 $(call dist-for-goals,sdk win_sdk,$(full_classes_jar):org.apache.http.legacy.jar)
+endif  # not TARGET_BUILD_APPS
 
 apache_http_src_files :=
 apache_http_java_libs :=