MuntashirAkon/AppManager · critical

Error! %s could not be found or copied.\n

Error message

Error! %s could not be found or copied.\n

What it means

Neither the pre-copied /data/local/tmp/<am_jar_name> nor any of the four /sdcard/Android/data/<app_id>/cache fallback paths could be located and copied into place (copy_file failed for all candidates and no valid direct path existed). resolved_am_jar_path stayed NULL, so the binary aborts.

Source

Thrown at app/src/main/cpp/run_server.c:158

             main_jar_name);
    snprintf(main_jar_fallbacks[3], sizeof(main_jar_fallbacks[3]), "/storage/emulated/%s/AppManager/%s",
             user_id,
             main_jar_name);

    uid_t uid = getuid();
    gid_t gid = getgid();
    printf("Starting %s as %d:%d...\n", SERVER_NAME, uid, gid);

    // Copy am.jar as /data/local/tmp/am.jar
    const char *resolved_am_jar_path = NULL;
    for (int i = 0; i < 4; i++) {
        if (copy_file(am_jar_fallbacks[i], exec_jar_path) == 0) {
            resolved_am_jar_path = am_jar_fallbacks[i];
            break;
        }
    }
    if (resolved_am_jar_path == NULL) {
        fprintf(stderr, "Error! %s could not be found or copied.\n", am_jar_name);
        return 1;
    }
    // Fix ownership
    if (chown(exec_jar_path, uid, gid) != 0) {
        fprintf(stderr, "Warning: chown failed: %s\n", strerror(errno));
        // Although it failed, still proceed
    }

    // Copy main.jar as /data/local/tmp/main.jar
    const char *resolved_main_jar_path = NULL;
    for (int i = 0; i < 4; i++) {
        if (copy_file(main_jar_fallbacks[i], main_jar_path) == 0) {
            resolved_main_jar_path = main_jar_fallbacks[i];
            break;
        }
    }
    if (resolved_main_jar_path == NULL) {
        fprintf(stderr, "Error! %s could not be found or copied.\n", main_jar_name);

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Ensure the app copies am.jar to its external cache (context.getExternalCacheDir) or /data/local/tmp before launching this binary
  2. Verify app_id is correct so the /sdcard/Android/data/<app_id>/cache fallback paths are valid
  3. Check that storage is mounted and readable; test with `ls` on the fallback paths via adb
  4. Re-deploy/ship am.jar with the app and stage it on every launch

Example fix

// before
exec(binary + " " + port + ...); // jar never staged
// after
copyAssetToCache("am.jar");
exec(binary + " " + port + ...);
Defensive patterns

Strategy: fallback

Validate before calling

File[] candidates = {new File("/data/local/tmp/am.jar"),
    new File(getExternalCacheDir(), "am.jar")};
boolean staged = Arrays.stream(candidates).anyMatch(File::exists);
if (!staged) copyAssetToCache("am.jar");

Try / catch

try {
    runServer(...);
} catch (IOException e) {
    if (e.getMessage().contains("could not be found or copied")) {
        stageJarFromAssets("am.jar");
        runServer(...); // retry once after staging
    }
}

Prevention

When it happens

Trigger: am.jar is absent from TMP_PATH and every fallback candidate path; copy_file fails on all fallbacks due to missing files or unreadable storage.

Common situations: First launch where the app never staged am.jar to its cache dir; /sdcard storage unmounted or scoped-storage restrictions hide the cache path; wrong app_id makes fallback paths point to a nonexistent package directory; am.jar deleted by a cleaner app.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/7fcc8977f4523b30. Report an issue: GitHub.