Android - How do I dynamically set the package name at build time for an Open-source project?

后端 未结 3 1789
天命终不由人
天命终不由人 2020-12-24 15:30

I\'m working on an Open-source project. As it is intended that anyone can download the source and build it themselves, I do not want to hard-code the package name anywhe

3条回答
  •  长情又很酷
    2020-12-24 15:41

    Easiest way might be replace the package name as late as possible. This way, you don't even have to touch your code. There is a nice article named Renaming the Android Manifest package(http://www.piwai.info/renaming-android-manifest-package/). Summary:

    • You can use aapt --rename-manifest-package to modify the package name

    • Alternatively, if you want package name replacement to be a part of the ant build process, you can override the -package-resources target:

      • copy the -package-resources target from SDK's build.xml
      • add manifestpackage parameter

提交回复
热议问题