Do not try to compile resource-only dex files.
This changes behavior in the case where we are asked to load a dex
file that does not exist or has no classes.dex entry.
Previously we would run dex2oat, which would log an error message and
fail. Now we skip running dex2oat, we report the DexOptStatus as
kNoDexOptNeeded, and we do not try to fall back to the missing
original dex files.
Bug: 21722039
(cherry picked from commit cb44b11a926696e34b3dc44288e762b4303cc128)
Change-Id: I84a85dc9ece54bcc0a5283f871e09bf68471c6e7
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 91b5000..7936dd3 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -987,13 +987,18 @@
// Fall back to running out of the original dex file if we couldn't load any
// dex_files from the oat file.
if (dex_files.empty()) {
- if (Runtime::Current()->IsDexFileFallbackEnabled()) {
- if (!DexFile::Open(dex_location, dex_location, &error_msg, &dex_files)) {
- LOG(WARNING) << error_msg;
- error_msgs->push_back("Failed to open dex files from " + std::string(dex_location));
+ if (oat_file_assistant.HasOriginalDexFiles()) {
+ if (Runtime::Current()->IsDexFileFallbackEnabled()) {
+ if (!DexFile::Open(dex_location, dex_location, &error_msg, &dex_files)) {
+ LOG(WARNING) << error_msg;
+ error_msgs->push_back("Failed to open dex files from " + std::string(dex_location));
+ }
+ } else {
+ error_msgs->push_back("Fallback mode disabled, skipping dex files.");
}
} else {
- error_msgs->push_back("Fallback mode disabled, skipping dex files.");
+ error_msgs->push_back("No original dex files found for dex location "
+ + std::string(dex_location));
}
}
return dex_files;