Commit 93dfa799 authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Reland "Android: Increase default_min_sdk_version 19 -> 21"

This reverts commit a71864a7.

Reason for revert:
 * Added min_sdk_version to cronet targets
 * Made dex.py not package incremental dex in cronet's test apks

Original change's description:
> Revert "Android: Increase default_min_sdk_version 19 -> 21"
>
> This reverts commit ce14e58b.
>
> Reason for revert: The CL causes failures on Cronet KitKat builders https://ci.chromium.org/p/chromium/builders/ci/android-cronet-kitkat-arm-rel
>
> The error code is INSTALL_FAILED_OLDER_SDK
> https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8878029920810653312/+/steps/cronet_smoketests_missing_native_library_instrumentation_apk_on_Android_device_Nexus_5/0/stdout
>
> Original change's description:
> > Android: Increase default_min_sdk_version 19 -> 21
> >
> > Cronet is the only project that requires a lower minSdkVersion. To
> > continue supporting building of their targets, this change enabled
> > proguard on all of their apks in order to have all files desugared at
> > the proper minApiVersion.
> >
> > This change should speed up compiles somewhat, as it removes the need to
> > generate main-dex-lists for legacy multidex purposes.
> >
> > Bug: 1091919
> > Change-Id: Ifd8089bbf4965b55a13dea11464ccda979fd5028
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2233581
> > Reviewed-by: Peter Wen <wnwen@chromium.org>
> > Commit-Queue: Andrew Grieve <agrieve@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#776166}
>
> TBR=wnwen@chromium.org,agrieve@chromium.org
>
> Change-Id: Id4b92d5549d13de9684f542ce646993c3833795f
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 1091919
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2236715
> Reviewed-by: Pavel Yatsuk <pavely@chromium.org>
> Commit-Queue: Pavel Yatsuk <pavely@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#776237}

Bug: 1091919
Change-Id: Ie2dc5d64739a3f57c36f3380502d290129d634f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2235737
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarPeter Wen <wnwen@chromium.org>
Reviewed-by: default avatarPaul Jensen <pauljensen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776952}
parent 9e3a101f
......@@ -62,6 +62,9 @@ def _ParseArgs(args):
'--multi-dex',
action='store_true',
help='Allow multiple dex files within output.')
parser.add_argument('--library',
action='store_true',
help='Allow numerous dex files within output.')
parser.add_argument('--r8-jar-path', required=True, help='Path to R8 jar.')
parser.add_argument('--desugar', action='store_true')
parser.add_argument(
......@@ -334,13 +337,15 @@ def _PerformDexlayout(tmp_dir, tmp_dex_output, options):
def _CreateFinalDex(d8_inputs, output, tmp_dir, dex_cmd, options=None):
tmp_dex_output = os.path.join(tmp_dir, 'tmp_dex_output.zip')
if (output.endswith('.dex')
or not all(f.endswith('.dex') for f in d8_inputs)):
needs_dexing = not all(f.endswith('.dex') for f in d8_inputs)
needs_dexmerge = output.endswith('.dex') or not (options and options.library)
if needs_dexing or needs_dexmerge:
if options:
if options.main_dex_list_path:
dex_cmd = dex_cmd + ['--main-dex-list', options.main_dex_list_path]
elif options.multi_dex and int(options.min_api or 1) < 21:
# When dexing library targets, it doesn't matter what's in the main dex.
elif options.library and int(options.min_api or 1) < 21:
# When dexing D8 requires a main dex list pre-21. For library targets,
# it doesn't matter what's in the main dex, so just use a dummy one.
tmp_main_dex_list_path = os.path.join(tmp_dir, 'main_list.txt')
with open(tmp_main_dex_list_path, 'w') as f:
f.write('Foo.class\n')
......
......@@ -46,9 +46,8 @@ if (is_android || is_chromeos) {
enable_chrome_android_internal = has_chrome_android_internal
# The default to use for android:minSdkVersion for targets that do
# not explicitly set it. This can generally be set higher than the
# default, but not lower.
default_min_sdk_version = 19
# not explicitly set it.
default_min_sdk_version = 21
# Android API level for 32 bits platforms
android32_ndk_api_level = 16
......
......@@ -1304,6 +1304,9 @@ if (enable_java_templates) {
}
}
# It's not safe to dex merge with libraries dex'ed at higher api versions.
assert(!_is_dex_merging || _min_sdk_version >= default_min_sdk_version)
# For D8's backported method desugaring to work properly, the dex merge step
# must not be set to a higher minSdkVersion than it was for the libraries.
if (_enable_desugar && _is_dex_merging) {
......@@ -1413,13 +1416,14 @@ if (enable_java_templates) {
}
}
} else { # !_proguard_enabled
_is_library = defined(invoker.is_library) && invoker.is_library
_input_class_jars = []
if (defined(invoker.input_class_jars)) {
_input_class_jars = invoker.input_class_jars
}
_deps = invoker.deps
if (_is_dex_merging && enable_bazel_desugar) {
if (!_is_library && enable_bazel_desugar) {
# It would be more efficient to use the pre-dex'ed copy of the runtime,
# but it's easier to add it in this way.
_deps += [ "//third_party/bazel/desugar:desugar_runtime_java" ]
......@@ -1537,11 +1541,10 @@ if (enable_java_templates) {
deps += [ ":${_main_dex_list_target_name}" ]
inputs += [ _main_dex_list_path ]
}
} else if (defined(invoker.enable_library_multidex) &&
invoker.enable_library_multidex) {
args += [ "--multi-dex" ]
}
if (_is_library) {
args += [ "--library" ]
}
if (defined(invoker.input_dex_filearg)) {
inputs += [ invoker.build_config ]
args += [ "--dex-inputs-filearg=${invoker.input_dex_filearg}" ]
......@@ -1579,7 +1582,7 @@ if (enable_java_templates) {
# 1) not require recompiles when toggling is_java_debug,
# 2) allow incremental_install=1 to still have local variable
# information even when is_java_debug=false.
if (!is_java_debug && _is_dex_merging) {
if (!is_java_debug && !_is_library) {
args += [ "--release" ]
}
......@@ -3252,8 +3255,6 @@ if (enable_java_templates) {
# from the final .jar file.
# jar_included_patterns: Optional list of .class file patterns to include
# in the final .jar file. jar_excluded_patterns take precedence over this.
# min_sdk_version: Optional. The minimum Android SDK version this target
# supports.
#
# For 'android_apk' and 'android_app_bundle_module' targets only:
#
......@@ -3789,10 +3790,8 @@ if (enable_java_templates) {
deps += _classpath_deps + [ ":$_header_target_name" ]
}
# For library targets, we do not need a proper main dex list, but do
# need to allow multiple dex files.
enable_multidex = false
enable_library_multidex = true
is_library = true
}
_public_deps += [ ":${target_name}__dex" ]
}
......
......@@ -2430,9 +2430,7 @@ if (enable_java_templates) {
_final_deps = []
_enable_main_dex_list =
_enable_multidex &&
(!defined(invoker.min_sdk_version) || invoker.min_sdk_version < 21)
_enable_main_dex_list = _enable_multidex && _min_sdk_version < 21
if (_enable_main_dex_list) {
_generated_proguard_main_dex_config =
"$_base_path.resources.main-dex-proguard.txt"
......@@ -2927,12 +2925,16 @@ if (enable_java_templates) {
deps += _deps + [ ":$_compile_resources_target" ]
proguard_mapping_path = _proguard_mapping_path
proguard_sourcefile_suffix = "$android_channel-$_version_code"
} else {
} else if (_min_sdk_version >= default_min_sdk_version) {
# Enable dex merging only when min_sdk_version is >= what the library
# .dex files were created with.
input_dex_filearg =
"@FileArg(${_rebased_build_config}:final_dex:all_dex_files)"
if (_enable_main_dex_list) {
main_dex_list_input_classes_filearg = "@FileArg(${_rebased_build_config}:deps_info:java_runtime_classpath)"
}
} else {
input_classes_filearg = "@FileArg($_rebased_build_config:deps_info:java_runtime_classpath)"
}
if (_is_static_library_provider) {
......
......@@ -10,7 +10,6 @@
xmlns:tools="http://schemas.android.com/tools"
package="org.chromium.android_browsertests_apk">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="23" />
<uses-feature android:glEsVersion="0x00020000" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
......
......@@ -1110,6 +1110,7 @@ if (!is_component_build) {
"cronet_smoketests_missing_native_library_instrumentation_apk") {
apk_name = "MissingNativeLibrarySmokeTestInstrumentation"
android_manifest = "test/javatests/AndroidManifest.xml"
min_sdk_version = _cronet_min_sdk_version
sources = cronet_smoketests_native_common_srcs + [ "test/smoketests/src/org/chromium/net/smoke/MissingNativeLibraryTest.java" ]
deps = [
......@@ -1179,6 +1180,7 @@ if (!is_component_build) {
}
test("cronet_unittests_android") {
min_sdk_version = _cronet_min_sdk_version
deps = [
":cronet_impl_native_base_java",
":cronet_static",
......@@ -1204,6 +1206,7 @@ if (!is_component_build) {
}
test("cronet_tests_android") {
min_sdk_version = _cronet_min_sdk_version
deps = [
":cronet_impl_native_base_java",
":cronet_static",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment