Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d66afe2 authored by Shane Farmer's avatar Shane Farmer
Browse files

AAPT2: Fix multi APK output

- Ensure that the output directory exists before generating APKs
- Only use the file name (and not the path) for creating output
  file names

Test: manually ran optimize command

Change-Id: I5f5ecb5dcec4d17cdbca5709f2dd17e6d53df986
parent 612e6732
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ bool MultiApkGenerator::FromBaseApk(const std::string& out_dir,
  // TODO(safarmer): Handle APK version codes for the generated APKs.
  // TODO(safarmer): Handle explicit outputs/generating an output file list for other tools.

  const std::string& apk_path = apk_->GetSource().path;
  const std::string& apk_path = file::GetFilename(apk_->GetSource().path).to_string();
  const StringPiece ext = file::GetExtension(apk_path);
  const std::string base_name = apk_path.substr(0, apk_path.rfind(ext.to_string()));

@@ -122,10 +122,14 @@ bool MultiApkGenerator::FromBaseApk(const std::string& out_dir,

    std::unique_ptr<ResourceTable> table = apk_->GetResourceTable()->Clone();


    TableSplitter splitter{{}, splits};
    splitter.SplitTable(table.get());

    std::string out = out_dir;
    if (!file::mkdirs(out)) {
      context_->GetDiagnostics()->Warn(DiagMessage() << "could not create out dir: " << out);
    }
    file::AppendPath(&out, artifact_name.value());

    std::unique_ptr<IArchiveWriter> writer =