Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I modify and rerelease an AOSP app?

I'm annoyed by a simple feature lack in the stock android email application. As this application is released as open source I can fix this quite easily.

Question: How can I release this modification in such a way that me and other users can install the modified EMail application (without root access)? I tried the following:

  1. With a lot of copying I was able to build the EMail application with the standard Eclipse/ant toolchain and without the ASOP toolchain which uses make-scripts.
  2. Installing this application now leads to an error, because the package is already installed (obviously, and I do not have the singing keys to update)
  3. Disableing the EMail app on the device does not help either, I still can not install my new application.

I though about changing the package name of the application in the manifest, but it is not that simple: You also have to move all classes into the new package. Additionally, as you can see in the AndroidManifest, the application defines new permissions (com.android.email.permission.READ_ATTACHMENT) and other things which lead to duplication errors when installing the modified package. These permissions are references as strings in the source.

Is modifining every file by hand and then debugging every error really the only solution to my problem? These modifications would also make pulling in new versions of the EMail application very difficult as I have modified and move every file.

like image 448
theomega Avatar asked Feb 07 '13 19:02

theomega


2 Answers

I though about changing the package name of the application in the manifest

That will be required.

You also have to move all classes into the new package

Not necessarily. R will be generated into the package declared in the manifest, and so you will need to arrange to import that R class. And you will need to update the manifest itself to use fully-qualified class names instead of bare class names, if applicable.

Additionally, as you can see in the AndroidManifest, the application defines new permissions (com.android.email.permission.READ_ATTACHMENT) and other things which lead to duplication errors when installing the modified package.

It is entirely possible to define an existing permission. I have no idea where/how you are getting "duplication errors".

Is modifining every file by hand and then debugging every error really the only solution to my problem?

More or less. See the "not necessarily" paragraph above.

These modifications would also make pulling in new versions of the EMail application very difficult as I have modified and move every file.

You were the one who decided to embark on this quest, as opposed to contributing your changes to an existing open source mail app, such as K-9 Mail (which also forked the AOSP Email app, years ago), or the AOSP Email app itself (via the AOSP contribution process).

like image 54
CommonsWare Avatar answered Oct 26 '22 18:10

CommonsWare


This topic may be stale, but I thought I'd share what I've done for posterity. I was able to use the above info to modify the Browser source and create my own version of the app (that can be installed in parallel to the stock app). What I did:

  • In the manifest, change the package name
  • In res->values->strings, change the application label (this is just for convenience, to avoid having 2 apps with the same name)
  • In the manifest, Remove the "original-package" attribute (may not be required)
  • In the manifest, change the provider authorities (to match my new package name)
  • Make sure all class names in the manifest are fully qualified.

The last step took a few attempts, but it was just a matter of building, installing, launching, and checking LogCat for the erroneous references.

like image 35
rainrunner Avatar answered Oct 26 '22 18:10

rainrunner