简体   繁体   中英

Android R - Are the generated IDs identical between build?

Android R IDs are generated by the IDE (Android Studio or Eclipse ADT).

Are they identical between builds?

If yes, will they be the same if generated on different machines?

Firstly, Android IDs are not generated by the IDE but by aapt, a command line tool which is run during a build. Yes, the IDE ultimately triggers it, but it isn't strictly part of Android Studio, it's part of the build tools package.

The numbers are essentially assigned alphabetically, so the resource IDs will be identical for the same project - but not if you modify the resource file tree. I am only prepared to guarantee that on the same file system, operating system and version of build tools. If you change any of those, all bets are off.

Ultimately, relying on this would be a really bad idea, because someone will break it by modifying the project one day, probably sooner rather than later.

I looked into this fairly extensively some years ago when I wrote an APK decompiler for the purposes of patching in resources.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM