我在 Android 中找到了这段代码:
bool DexFile::OpenFromZip(const ZipArchive& zip_archive, const std::string& location,
std::string* error_msg, std::vector<const DexFile*>* dex_files) {
ZipOpenErrorCode error_code;
std::unique_ptr<const DexFile> dex_file(Open(zip_archive, kClassesDex, location, error_msg,
&error_code));
if (dex_file.get() == nullptr) {
return false;
} else {
// Had at least classes.dex.
dex_files->push_back(dex_file.release());
// Now try some more.
size_t i = 2;
while (i < 100) {
// We could try to avoid std::string allocations by working on a char array directly. As we
// do not expect a lot of iterations, this seems too involved and brittle.
std::string name = StringPrintf("classes%zu.dex", i);
std::string fake_location = location + ":" + name;
std::unique_ptr<const DexFile> next_dex_file(Open(zip_archive, name.c_str(), fake_location,
error_msg, &error_code));
if (next_dex_file.get() == nullptr) {
if (error_code != ZipOpenErrorCode::kEntryNotFound) {
LOG(WARNING) << error_msg;
}
break;
} else {
dex_files->push_back(next_dex_file.release());
}
i++;
}
return true;
来自https://android.googlesource.com/platform/art/+/master/runtime/dex_file.cc master
这是否意味着如果 APK 在根目录中有多个 dex,则 dex2oat 会在使用 ART 时将所有 DEX 转换为 OAT?
安装apk时如何将所有dex转换为oat?