15

I have problem with running an android application from eclipse on real android device

when I click on Run it just show me this error: Installation error: INSTALL_FAILED_UID_CHANGED

Logcat:

[2012-09-09 14:38:26 - SearchApp] Android Launch!
[2012-09-09 14:38:26 - SearchApp] adb is running normally.
[2012-09-09 14:38:26 - SearchApp] Performing com.example.MainActivity activity launch
[2012-09-09 14:38:26 - SearchApp] Automatic Target Mode: using device 'cff192abd7f551f'
[2012-09-09 14:38:26 - SearchApp] Uploading SearchApp.apk onto device 'cff192abd7f551f'
[2012-09-09 14:38:27 - SearchApp] Installing SearchApp.apk...
[2012-09-09 14:38:28 - SearchApp] Installation error: INSTALL_FAILED_UID_CHANGED
[2012-09-09 14:38:28 - SearchApp] Please check logcat output for more details.
[2012-09-09 14:38:28 - SearchApp] Launch canceled!
einverne
  • 6,454
  • 6
  • 45
  • 91
Mohsen Navabi
  • 686
  • 1
  • 6
  • 15

11 Answers11

11

I EVENTUALLY FOUND THE SOLUTION FOR INSTALL_FAILED_DEXOPT and INSTALL_FAILED_UID_CHANGED ERROR

After lot of testing a vary of tricks in vain, I eventually found the main solution to solve this sticky problem forever!

I think the problem is caused by an Eclipse bug! , in fact eclipse can not copy and install built APK file just because of a string name(described further)

I should add that when you use tricks on internet such as delete package name folder in data/data you will face a new sticky error "INSTALL_FAILED_DEXOPT"

So lets see how to solve INSTALL_FAILED_DEXOPT and INSTALL_FAILED_UID_CHANGED

In my case, when i check the log cat i noticed below lines:

09-30 19:03:19.882: I/PackageManager(314): Running dexopt on: com.example.searchapp
09-30 19:03:19.921: E/dalvikvm(6129): Invalid name: 'search_‌country_name'
09-30 19:03:19.921: E/dalvikvm(6129): Trouble with item 226 @ offset 0x2094
09-30 19:03:19.921: E/dalvikvm(6129): Cross-item verify of section type 0004 failed
09-30 19:03:19.921: E/dalvikvm(6129): ERROR: Byte swap + verify failed
09-30 19:03:19.961: E/dalvikvm(6129): Optimization failed
09-30 19:03:19.961: W/installd(144): DexInv: --- END '/data/app/com.example.searchapp-1.apk' --- status=0xff00, process failed
09-30 19:03:19.961: E/installd(144): dexopt failed on '/data/dalvik-cache/data@app@com.example.searchapp-1.apk@classes.dex' res = 65280
09-30 19:03:19.961: W/PackageManager(314): Package couldn't be installed in /data/app/com.example.searchapp-1.apk

As you can see the second line is: Invalid name: 'search_‌country_name'

This is one of my string names in String.xml

So I delete this string and comment all referenced codes

Then I delete the package name folder in /data/data (if you are using a actual device you should have root access , if you are using emulator just wipe data before opening emulator or make a new AVD)

Now the problem is solved!

You can easily continue coding!

Mohsen Navabi
  • 686
  • 1
  • 6
  • 15
  • what's the safest way to get root access to the device? – davidtingsu Oct 24 '13 at 08:33
  • there are a few ways to root android devices that can easly be find on the net and there are no safety problem with them. you should be careful about installing unknown apps that need root access after you root the device , they may hurt your device – Mohsen Navabi Oct 24 '13 at 09:01
  • Well, not for me... I've an app with the given "corrupted" package name in GooglePlay store, and a non-rooted device (that I don't have permission to root). So, I can't neither root nor change ID/packagename. Also one more thing: IT IS NOT AN ECLIPSE BUG, because it also occurs in AndroidStudio, or even installig through adb command directly. – Marcelo Feb 02 '15 at 02:34
4

This solution finally worked for me with no root:

$ platform-tools/adb -d install /path/to/proj/bin/foo.apk
797 KB/s (4872885 bytes in 5.963s)
pkg: /data/local/tmp/foo.apk
Success
$ platform-tools/adb -d uninstall com.example.foo.bar
Success

I don't completely understand why this worked when installing from Eclipse did not work for the same APK, but I'm just happy to move on...

Chris Dolan
  • 8,905
  • 2
  • 35
  • 73
  • 1
    Eclipse/adt doesn't delete the old apk, it tries to do an upgrade/reinstall, which can fail in various cases (certificate mismatch, etc). In those cases you have to manually uninstall first. – Chris Stratton Nov 19 '13 at 19:07
  • @ChrisStratton - thanks, that makes perfect sense in retrospect. – Chris Dolan Nov 19 '13 at 22:25
4

I tried all this answers but no effect

uproperly uninstall.

solution: just reboot pad

djdance
  • 3,110
  • 27
  • 33
2

It may be possible that the application did not get uninstalled properly. There may be data folder left out. So try to remove data folder of the application manually and try installing the application again.

balaji
  • 53
  • 4
  • i have already done all of this works and also some other tricks found on net , but non of them helped! i eventually did rest of my work on that project on another operation system – Mohsen Navabi Sep 19 '12 at 14:52
0

Alternatively, delete the emulator and reconfigure it afresh.

Edward
  • 201
  • 3
  • 3
0

May be anybody help...

I have root device for debug. Sometimes I backup my application data from /data/data/my.package and later restore by adb shell. Before on restore I delete my.package folder, recreate and copy other subfolders and files. After this on next change and run project from eclipse, get INSTALL_FAILED_UID_CHANGED error.

My mistake: I should not have been removed my.package folder. I must remove only all in this folder, because on recreate folder I get new owner folder my.package.

Yura Shinkarev
  • 5,134
  • 7
  • 34
  • 57
0

There is a work around for it. If you do not have rooted device and you cannot access /data/data/ folder also, then simply reset your device. It will delete everything from data folder and you can install clean app again. Only drawback is everything will get erased from your phone.

SonalG
  • 1
0

I had this issue on the emulator. I removed the avd and created a new one. Problem went away.

Anna Billstrom
  • 2,482
  • 25
  • 33
0

There is already a data directory with the name of package you are trying to install with a different UID assigned. Get a root access and then try removing the already existed directory with the following command in cmd

  rm -r /data/data/com.your.package

Or try to rename your application package to run it on your device.

Najeebullah Shah
  • 4,164
  • 4
  • 35
  • 49
  • you should run in adb shell, but this is not a good solution, because it needs the device to be rooted – Marcelo Feb 02 '15 at 02:28
0

So if you come this down to find this.. nothing might have worked for you. There is however an easy fix for this. It is obviously because of improper uninstall (probably due to faulty cable connection).

SOLUTION Download SDMaid from play-store, and delete Corpse files (junk files). Re-run application. (But you need to have your device rooted)

asok Buzz
  • 1,876
  • 3
  • 24
  • 50
0

This solution worked for me:

  1. Put your APK to the device's storage/sd card

  2. adb shell pm install -l -r "/sdcard/<apk_filename>.apk"

gentra
  • 6,066
  • 3
  • 16
  • 18