diff --git a/tools/aapt2/ResourceUtils.cpp b/tools/aapt2/ResourceUtils.cpp index 945f45b8a3376..41c7435b534d5 100644 --- a/tools/aapt2/ResourceUtils.cpp +++ b/tools/aapt2/ResourceUtils.cpp @@ -43,8 +43,9 @@ namespace ResourceUtils { static std::optional ToResourceNamedType(const char16_t* type16, const char* type, size_t type_len) { std::optional parsed_type; + std::string converted; if (type16) { - auto converted = android::util::Utf16ToUtf8(StringPiece16(type16, type_len)); + converted = android::util::Utf16ToUtf8(StringPiece16(type16, type_len)); parsed_type = ParseResourceNamedType(converted); } else if (type) { parsed_type = ParseResourceNamedType(StringPiece(type, type_len));