shwenzhang/AndResGuard · error · brut.androlib.AndrolibException

can not find \ or raw string in res path =

Error message

can not find \ or raw string in res path = %s

What it means

When rewriting file path strings inside resources.arsc, AndResGuard expects each raw resource path to contain a '/' separating the res directory from the file name. If lastIndexOf("/") finds no separator, it cannot split the path into directory and file components and throws this AndrolibException.

Solutions

  1. Run AndResGuard on the original unobfuscated APK, not one already processed by another resource tool.
  2. Inspect resources.arsc string pool (aapt dump resources) to find the offending path and rebuild the APK from sources.
  3. Enable config.mKeepRoot consistently across runs so path expectations match.
  4. Upgrade AndResGuard — handling of non-res-rooted and already-renamed paths improved over releases.

Example fix

// before
apply AndResGuard to app-release-resguard.apk // already obfuscated
// after
apply AndResGuard to the original app-release.apk from assembleRelease
Defensive patterns

Strategy: validation

Validate before calling

// before running obfuscation, sanity-check raw paths in arsc
if (!rawResPath.contains("/")) {
    throw new IllegalStateException("resource path not res-rooted: " + rawResPath);
}

Try / catch

try {
    ARSCDecoder.decode(arscStream, apkDecoder);
} catch (AndrolibException e) {
    if (e.getMessage().contains("can not find")) {
        // input APK likely already obfuscated or tampered; use original APK
    }
}

Prevention

When it happens

Trigger: A resource entry's raw string value (file path in arsc, e.g. "res/drawable/icon.png") has no slash — occurring when the arsc contains rewritten/malformed path strings, entries from a previous obfuscation without keepRoot, or resource paths not rooted under res/.

Common situations: Double-processing an APK already obfuscated by AndResGuard or another tool (paths already renamed); arsc entries pointing at assets-style paths without slashes; tampered/packed APKs with modified string pools.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of shwenzhang/AndResGuard@e4df245d82 (2026-09-12). Data as JSON: /api/errors/086fc02e76adb0cc. Report an issue: GitHub.

Appendix: source

Thrown at AndResGuard-core/src/main/java/com/tencent/mm/androlib/res/decoder/ARSCDecoder.java:728

    mIn.skipCheckByte((byte) 0);
    byte type = mIn.readByte();
    int data = mIn.readInt();

    //这里面有几个限制,一对于string ,id, array我们是知道肯定不用改的,第二看要那个type是否对应有文件路径
    if (mPkg.isCanResguard()
       && flags
       && type == TypedValue.TYPE_STRING
       && mShouldResguardForType
       && mShouldResguardTypeSet.contains(mType.getName())) {
      if (mTableStringsResguard.get(data) == null) {
        String raw = mTableStrings.get(data).toString();
        if (StringUtil.isBlank(raw) || raw.equalsIgnoreCase("null")) return;

        String proguard = mPkg.getSpecRepplace(mResId);
        //这个要写死这个,因为resources.arsc里面就是用这个
        int secondSlash = raw.lastIndexOf("/");
        if (secondSlash == -1) {
          throw new AndrolibException(String.format("can not find \\ or raw string in res path = %s", raw));
        }

        String newFilePath = raw.substring(0, secondSlash);

        if (!mApkDecoder.getConfig().mKeepRoot) {
          newFilePath = mOldFileName.get(raw.substring(0, secondSlash));
        }
        if (newFilePath == null) {
          System.err.printf("can not found new res path, raw=%s\n", raw);
          return;
        }
        //同理这里不能用File.separator,因为resources.arsc里面就是用这个
        String result = newFilePath + "/" + proguard;
        int firstDot = raw.indexOf(".");
        if (firstDot != -1) {
          result += raw.substring(firstDot);
        }
        String compatibaleraw = new String(raw);

View on GitHub (pinned to e4df245d82)