Android: Updating an apk file programatically - android

I want to update an apk file already installed in the device programmatically to a new version from a url. Is there any way to do this other than installing the file again using application/vnd.android.package-archive (Since I'd prefer to do this silently without user actions)

Not unless you have system privileges. If that were possible, any app would be able to install anything on your device (including malware).

save your current version and url in remote db.and when application starts in device check application version stored in db and installed app version is same or not. if different then download file from url.if not then run current version.
but you have to do these these things manually in code.
and for this you will need internet connection in device also.

I have done the same. I have my new apk in the FTP server and a version number of the new APk. I am comparing the version numbers and downloading the APK and installing it. but before that I am checking for the checksum of the downloaded apk with the checksum in the FTP server to make sure that the APK is downloaded properly.
Automatic installation without the users consent, i don't think it is possible. Let me know if you have found a solution for that.

Related

Android Studio: How to access the device is rooted to implement auto install the local APK file?

I have written code to download and open the installation screen where if user can allow to install it will get installed, but I required auto installation of app. So if someone have any trick to implement auto installation of local APK file using Android Studio. Please share.
What you are asking is a security risk and wont be allowed by the operating system.
I'm sure there's malware out there that can do it, but those often use exploits that are 'quickly'/eventually patched.

how to create a service from my app for uninstalling my app and installing new app(upgrade)?

I have an android app that I put update ability for it. In it,the app download new version .apk file from server if new version is available, and install the new. But the issue is : an existing package by the same name with a confilcting signature is already installed, while installing. Now I want create a service from my app that in it ,service remove current app, and install new version downloaded.How can I do this?
First, Why not just auto update through the store?
Second, if you want to self update you're gonna have to be a system app and have the install permission.
Make sure you signed the apk with the same creds as you did the apk waiting to be download in the server
Then, the best way i can think of is to use reflection to invoke the PackageManager's installPackage method with a Uri to your apk

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.

Upgrade apk downloaded from own web server

I need help in upgrading apk file. I have apk file developed for android 2.2 and I donot wish to publish my apk on android market. I published apk in our own webserver. And i could download it to my android mobile. Now the issue is that how can i upgrade apk file by publishing in our webserver.
My questions are:
How android market does apk upgrading?
How to upgrade a binary in android mobile with new version of which old version is already installed?
I used android built in view using intent which actually Re-installs apk not upgrading.But i don't want prompts asking "Do u want to install application?".
I want the apk to be upgraded once user click upgrade button without showing prompt to user, like doing in android market.
Is there any method to upgrade apk in android?
Are there any restrictions doing that?
Are there any specific permissions i need or i need to set in manifest file.
Once you've downloaded the APK, Android itself decides if the program is installed and needs to be upgraded, or if it is a new installation. Users can decide for themselves whether to upgrade or not.
Besides how to find out when there is an update available, it's not possible to upgrade it without prompting the user with the "Do you want to install". Android doesn't allow third apps to install apps unless the phone is rooted and your app has root access, but I think that this isn't your target group.
I have no experience with that but what you could try is loading classes manually from your server and then store it in the assets folder.
http://android-developers.blogspot.com/2011/07/custom-class-loading-in-dalvik.html
This is one approach, I don't think that it's very handy and easy but it would work.
Hope it helps!
PS:
And just because I'm wondering, is there a reason why don't you wanna publish it on the Android Market?
When you are publishing an App on your private web server, you need to create a process through which you can check for new version .There is No in built method for doing this .
I have created one as well.

Android - Issue with .apk file

I do understand that a .apk file is created in the bin folder of an android project, when the project is run.
I have a question about this: is it possible that there would be any difference in the functionality of an app installed via eclipse (as in connecting the phone to the computer and uploading and installing the app on the phone) versus installing the app by downloading a .apk placed on a secure server?
The reason I ask this question is that I usually put up the .apk file on a secure server and the testing team downloads and installs the app for testing purposes. The testing team has started to report app crashes when accessing this app. However, I don't seem to be seeing the any such problems (even while replicating the same scenarios) with the app when I install it on the phone via a cable connected to the computer.
You might be falling into a caching issue. Make sure you get the QA team a new filename of the apk on the server to ensure that they never get a cached apk when downloading it. Also maybe create a md5 sum of the apk locally and run md5 on the apk on the server after upload to ensure it is the same.
e.g. use
md5 yourapk.apk > yourapk.md5
on your machine and the server..
Most likely you QA team has found issues that are specific to the device or Android platform version they test with. Try with your apk with the same hardware in your dev environment.
I don't see how that would possible. The Eclipse ADT plugin just calls the executables in the specified Android SDK location on your hard drive and the .apk gets generated only once when you use Eclipse to install the application to your plugged phone.
Unless you're packaging the two versions in a different way, that shouldn't be possible. My guess is that your testing team has just found bugs specific to the runtime environment (the phone). Maybe a different version of Android, conflicting custom ROM, etc.
No, there is no difference , if the apk on the secure server is as latest as you have on your computer.
I would recommend you to clean your project before uploading the apk to the server.
Regarding the crashes, i guess there are some location based problems.
Also check if you are uploading the apk from your workspace. or some other older version which is located in different place that you are not using anymore.

Categories

Resources