Couldn't locate the top of the tree. Always source build/envsetup.sh from the root of the tree.

162 views
Skip to first unread message

Julian Waters

unread,
Dec 29, 2025, 3:12:26 PM12/29/25
to Android Building
Hi all,

I'm trying to compile Android following the instructions at https://source.android.com/docs/setup/build/building but running source build/envsetup.sh in the platform directory always returns "Couldn't locate the top of the tree. Always source build/envsetup.sh from the root of the tree." without fail. Trying to run the command from anywhere else just leads to bash not being able to find envsetup.sh at all, so that's out of the question. Some digging into the source code reveals that the script is looking for build/make/core/envsetup.mk but no such file exists in the entire source tree, only build/core/envsetup.mk so this will always fail. But I seem to be the only one who cannot compile Android at all, it works for everyone else despite the file not existing, otherwise this strange code would've been changed long ago. Is there anything I am doing wrong running the command? Thanks in advance!

best regards,
Julian

Dan Willemsen

unread,
Dec 29, 2025, 3:18:30 PM12/29/25
to android-...@googlegroups.com
Something has gone very wrong in your sync -- build/make has existed ever since Android 8 in 2017 (at which point build/core became a symlink to build/make/core). I'd recommend you verify your sync procedures in https://source.android.com/docs/setup/download

- Dan

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/android-building/da48daf2-a5ff-4785-8868-7b44d1ed920bn%40googlegroups.com.

Doan Pham

unread,
Jan 7, 2026, 1:35:55 AM (6 days ago) Jan 7
to android-...@googlegroups.com

Hi Julian,

My build/envsetup.sh also searches for build/make/core/envsetup.mk, but in my case, both build/make/core/envsetup.mk and build/core/envsetup.mk exist in the source tree.

image.png


So I’m thinking maybe some issues occurred during the repo init/sync process?

Fyi, this is the results when I asked Gemini about my theory, maybe you can try?

Q: I’ve just pulled AOSP source code (android-latest) but it’s missing build/make/core/envsetup.mk

Gemini: If build/make/core/envsetup.mk is absent, it usually points to an issue with how the repo was initialized or synced, rather than a bug in the source code itself.

Here are the most likely reasons and how to fix them:

  1. Incomplete Sync (repo sync) The most common culprit is a network interruption or a timeout during the repo sync process. Because AOSP consists of hundreds of individual Git repositories, it’s easy for one project (in this case, the build/make project) to fail silently.

    • The Fix: Run the sync again, but specifically target the missing project to save time:

      repo sync -j8 build/make
      

      If that doesn’t work, try a “force-sync”:

      repo sync -d --force-sync
      
  2. Shallow Clone Issues If you initialize your repo using the --depth=1 flag to save space or time, the sync is much more fragile. Sometimes specific files or history links aren’t pulled correctly if the manifest has complex dependencies.

    • The Fix: If you used a shallow clone, try deepening the history or re-syncing without the depth flag for that specific repository.
  3. Missing Submodules or Wrong Branch You mentioned android-latest. If you didn’t specify a stable release tag (like android-14.0.0_rXX), you might be tracking a development branch that is currently in a “broken” state or undergoing a major restructuring.

    • Check your branch:

      repo info build/make
      

      Ensure it is actually tracking the branch you expect.

  4. Case-Sensitivity (macOS Users) If you are building on a Mac and didn’t create a case-sensitive disk image (sparse bundle), the build system will behave unpredictably. While envsetup.mk is lowercase, other parts of the build system rely on case sensitivity, and errors here often manifest as “missing” files because the internal pathing fails.

How to Verify the File Path In the android-latest structure, verify the file exists locally by navigating directly to the subdirectory:

  1. Go to your AOSP root.
  2. Navigate to: cd build/make/core/
  3. Run ls -l envsetup.mk

If the directory build/make is empty or doesn’t exist: Your repo init didn’t map the projects correctly. You should check your .repo/manifest.xml to ensure the build/make project is defined.


Sincerely,

Doan Pham - an Android-enthusiast passing by

Julian Waters

unread,
Jan 7, 2026, 1:36:26 AM (6 days ago) Jan 7
to Android Building
Hi,

Thanks for the quick response, just before this was approved by moderation I got it working, I simply deleted everything and then ran repo init and repo sync again and eventually it worked, thank goodness. Still have no idea what the issue was, but at least it's fixed now. I actually have another few (Hopefully simple) questions, to avoid spam I'll just ask them here: I've shifted from trying to compile all of Android to just compiling Bionic for an ARM64 phone, I was trying to follow the instructions and ran lunch aosp_arm64_only_phone-aosp_current-user in the root repository, but it errored saying:

build/make/core/product_config.mk:226: error: Cannot locate config makefile for product "aosp_arm64_only_phone"

Is this the correct target for a phone with an ARM64 processor? I don't have a specific phone in mind so this should hopefully work for any ARM64 phone. I omitted cf as the instructions say it's optional and only for when you want to run it on a cuttlefish emulator.

Also, is there an mm target to install Bionic to a specific directory, akin to the --prefix= option in many configure scripts which instruct make install to place the compiled binaries in that directory? And is there a way to use a custom compiler binary when compiling Bionic besides just the prebuilt clang in the AOSP repository? I'm doing some experimentation here, fully accept that this may be unsupported, but I just would like to know if I can just export CC and CXX before running any commands to change the compiler used to my own.

Thanks for the help, have a good day!

best regards,
Julian

Reply all
Reply to author
Forward
0 new messages