Deepak
Deepak

Reputation: 177

How to update an Android app programmatically

I have developed an app for Android. When I installed it for first time, the app works. But when I do some changes in source code, we cant install it without deleting it from phone. I want that app should be updated wen I install it for second time. Any solutions?

Note: My app consists of database which I don't want to delete so want to update new app on existing one

Upvotes: 3

Views: 1285

Answers (6)

thedsz
thedsz

Reputation: 105

I have had similar problems trying to install my apps on occasion. To solve the problem I went to the app management screen and told the program to stop running then my update installed properly. I think it has something to do with the way android handles the program lifespan. When you exit a program it doesn't always stop running. If there is an error in something then android can have a problem closing the program before it can update it.

Upvotes: 0

Govind
Govind

Reputation: 143

But if you change version code then you will be prompted with this error. So Try looking for keystore Re-installation failed due to different application signatures. ExpenseTracker] You must perform a full uninstall of the application.

WARNING: This will remove the application data! ExpenseTracker] Please execute 'adb uninstall com.spundhan.expensetracker' in a shell.

Upvotes: 0

Tooroop
Tooroop

Reputation: 1884

The problem is probably because of your keystore with that you export your application. If you export your app with the default Android keystore, and then if you change the app on another PC and export it again with the default keystore on that other PC and install it on the same device, the Android will see that you have 2 same apps but with different keystores. That's why you need to first unistall the app and install it again.

It doesnt matter if you use the defualt Android keystore on both PC-s. They still aren't the same keystore.

One solution is that you create a keystore eg. ProjectKeystore and you create a folder keystore in your project. Put the keystore in that folder, and maybe put a file with the keystore username and pass. With that you can use the same keystore when you export your app on any PC.

Upvotes: 0

Ravi
Ravi

Reputation: 2367

How you are installing the application if by connecting usb you are trying so the new application will install and you can uninstall the first application and install the updated one so the new application will run perfectly.

Upvotes: 1

brunofitas
brunofitas

Reputation: 3083

Well, if you have compiled your second version you want to replace the old one... I don't know what are you using to program for android, but if you use eclipse sdk that is done automatically..

Upvotes: 0

Vrashabh Irde
Vrashabh Irde

Reputation: 14367

Change your VersionCode in your Android Manifest to subsequent versions

android:versionCode

android:versionCode — An integer value that represents the version of the application code, relative to other versions. The value is an integer so that other applications can programmatically evaluate it, for example to check an upgrade or downgrade relationship. You can set the value to any integer you want, however you should make sure that each successive release of your application uses a greater value. The system does not enforce this behavior, but increasing the value with successive releases is normative. Typically, you would release the first version of your application with versionCode set to 1, then monotonically increase the value with each release, regardless whether the release constitutes a major or minor release. This means that the android:versionCode value does not necessarily have a strong resemblance to the application release version that is visible to the user (see android:versionName, below). Applications and publishing services should not display this version value to users.

See this http://developer.android.com/tools/publishing/versioning.html

Upvotes: 1

Related Questions