Update system app in android - android

I have developed an android app and put this as prebuilt APK in AOSP.
So the app will be installed in /system/app as a system app.
The app has update function itself by downloading and installing the newer version APK.
But it does not work because system app cannot be updated.
Is there any way to update self-made system app?

System app can be updated, in two ways:
Updated by the ota updating, this will change the app directly, and the app still exist on /system.
updated by using package install api, this need the new version apk have the same signature with the one on /system, and the new version will be installed on /data. That means, if the device is reset, the new version will lose.
Ota update is a normal way for system app updating.

Yes, you can install an updated version of your original system app into the /data partition, provided that:
1. Both app versions are signed with the same key;
2. The updated app’s versionCode is greater than or equal to the original app’s.
One way to do this update is to use the following adb command: adb install -r <your updated apk file>. Then you can test your updated version without having to rebuild your AOSP code.
Note that your updated version in the /data partition will be removed via a factory data reset. In this case your original system app will take effect again.

Related

How to debug an app upgrade in Android Studio on a USB connected device

I have the production release of my Google Play Store app on my phone and have an updated version of the app in Android Studio. I would like to test the upgrade process, but have run into a versioning problem, then a logging problem.
To get a "clean" install, I can go into my phone's settings Backup & reset > Automatic restore, turn that off, then de-install the app, and install it from the Play Store. Alternatively, I could download the production APK and install it from the adb command line (details below). The result is my device should be the same as a regular production user.
Not directly germane to the question, but to understand my motivation for watching the upgrade process is that the app has an SQLite database and I extend SQLiteOpenHelper, so onUpgrade() is called, and some database schema work is being done.
Update Incompatible
If I click the button to deploy the app, then select my connected device, it wants to uninstall before proceeding:
Installation failed with message Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE
Obviously I could uninstall, but that would not test the upgrade process!
Generating Signed APK
I built a "release" APK, using Generate Signed APK..., which is the same process I use when generating a release for uploading to the Play Store. This gets around the versioning problem, but causes a logging visibility problem. The release configuration used in the past and now looks like this:
Installing APK to the device from Command Line
"C:\Program Files (x86)\HTC\HTC Sync Manager\HTC Sync\adb" install -r app-release.apk
The above did upgrade without uninstalling. The process I used was to open Terminal within Android Studio, change directory to where the generated APK was stored, then type the above command.
Logging / Debugging Problems
The adb command line triggered the upgrade process, but it did not start feeding the Logcat window immediately with debug information. I could connect to Logcat for all processes, but I could not get debug information for just my process, and did not have access to debugging tools.
Question
How can I start with a device that's running a signed production release then cause an updated version, contained in Android Studio, to run, without uninstalling, and with the ability to see the debugging output during the upgrade process? Or how can I modify a signed production release such that it allows an new version to update and allow debugging?
Because you're starting with an APK that is Debuggable=false, your work-around that includes building an update to the app using the same process as your production release process and getting a Logcat with all processes is probably the best you can do.
Rebuilding from Previous Source Control Version
One option would be to pull the specific version of the app out of your source control system and build it with Debuggable=true, and use that generated APK as your starting point instead of using the APK from the Play Store.
For the Future
Instead of making only one APK release version and uploading that to Play Store, make two versions. One version would be signed and uploaded as usual. And with the exact same source code, make another APK that has Debuggable=true. Rename each file with the version number. Then, later, if you ever want to try an upgrade from any version to any version, you can do that, and still have debugging capability.

Self updating android system application with root access

I have created my custom ROM from aosp. I have also included my application, lets call it myCustomInstaller.apk (1.0) in the custom ROM while building. The application basically is kind of Google play Store. The application has system privileges and can install or remove applications silently.
I am able to install, update or remove any other applications. The problem I am facing is, When I am updating the myCustomInstaller.apk to 2.0 itself, the application is also installed silently, I am able to see the latest version installed in installed apps, but when i restart the phone, myCustomInstaller app reverts back to the original version.
I really don't know how to proceed, How is google playstore updating itself, and installing other application? Do I need any other permissions to make the updated version of myCustomInstaller app persist?
I am using this for silently installing, yes I do modified code for updating and removing
https://code.google.com/p/auto-update-apk-client/
Did you make sure to increment the android:versionCode in your Manifest? If not, the updated version, which will only get stored in the /data/ directory will be deleted when you boot.

android update/install version checking

i'm new in android developing. (and in developing after all)
Here is my problem: If i install my android application onto my mobile device or AVD, i want it to check the current app version number and if it's lower than the one i want to install currently then install it, and if it is higher , then alert the users that they already use the latest version.
Because now when i install the .apk file, it just installs the app again and nothing happens.
Is it possible to develop this?
Best regards,
weeyas
The install process is managed at the system level, so your application has no control over it. As per the versioning guide, the Android system will only allow you to install updates from the same or newer version codes (i.e., version 1 can be replaced by version 2, but version 2 can never be overridden by version 1 unless you do a complete uninstall/reinstall). This applies to both Google Play updates and sideloading APKs yourself.
I don't know if it is possible if you try to install application from .APK file. However, you will not be able to publish the newest apk to Google Play if it has the same or lower version number than the current one.

Android apk replace vs Update

I have an application already installed on the mobile, am trying to install the update version of it.
I placed the apk inside the data/data folder, using file manager at the path,am trying to install it -
it shows a dialog to replace but not upgarde (Signed with the same key-store and version code/version name has an incremental value).
Could someone explain me more on this?
There is a difference between installing and subsequently, updating, apps off Google Play. Applications installed via a File Manager, for instance, will always prompt you to replace and not update an application. Side-loading apps on devices directly, does not have that mechanism to update. This is true not only for your app, but for every app.
It does not matter how it was signed or even the increment of your app's version.
Upgrade is only possible when you actually follow the installation procedure from Android Market. Else, it would just be a replace.

What makes an Android app re-installable?

Through Eclipse I can easily re-install (without having to uninstall the app first), a small app I am currently developing, any change any number of times.
When I export that app ("release mode") and place it on a website, it downloads and installs without any problem. (I have to check "Unknown sources" for allowing installation of non-Market apps first, of course).
If I uninstall this app, then download it again and install it again, it installs without any problem.
However, if I try to re-install this app without uninstalling it first, then Android notifies that the installation failed.
My question is why? What makes an Android app re-installable? (i.e. without having to uninstall it first, thus losing its existing settings)
You cannot replace a signed application with an unsigned one.
You fail to install it because it has the same app version. If you recompile it and then download it, it will update, because the version will have changed.

Categories

Resources