Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

I've bought a used HTC Magic with CyanogenMod 5 on it. It has Google Market. The market version is 1.713 - which is nowhere near the latest IIRC. In-app billing, for one thing, is not supported.

Isn't Google Market supposed to upgrade itself when a new version comes out? Why doesn't mine do so? Probably some kind of CyanogenMod interference. Any good way around that, please?

EDIT: debugged the situation a little bit. I happen to know that market updating happens out of the main Market process - the Market (com.android.vending) downloads the update, then fires a broadcast intent UPDATE_MARKET to a receiver in another app (com.android.vending.updater), which in turn installs the package. Here's what I got in the LogCat:

02-01 02:34:16.155: W/ActivityManager(121): Permission Denial: broadcasting Intent { act=com.android.vending.UPDATE_MARKET dat=content://downloads/download/31 } from com.android.vending (pid=1762, uid=10006) requires com.android.vending.permission.UPDATE_MARKET due to receiver com.android.vending.updater/com.android.vending.updater.UpdateMarketReceiver

So it looks as if the Market app lacks a permission to invoke the updater. The manifest file of Vending.apk, however, does have a

<uses-permission android:name="com.android.vending.permission.UPDATE_MARKET" /> 

line. How is it possible for an app to have a <uses-permission>, but receive a permission denial message?

EDIT2: the permission com.android.vending.permission.UPDATE_MARKET is marked as "signature" in the MarketUpdater manifest. Meaning only apps signed by the same certificate as MarketUpdater are granted that permission. That could be the reason Market is not granted the permission - could be signed by a different certificate.

EDIT3: that's exactly the case. The public key is different. The one on Vending.apk seems to match that on various versions of Vending.apk that are floating around the 'Net.

share|improve this question
    
CyanogenMod 5 is also very old. The newest version of the Market may not even run properly on it, so I wouldn't be surprised if it doesn't upgrade itself because your Android version is unsupported. –  eldarerathis Jan 31 '12 at 22:19
    
I'm not that worried about getting the very latest; as long as in-app billing works. Officially in-app billing is supported on Android 2.1 (all the way down to 1.6), and I hope Google will detect the running OS version and offer up something relevant. Now about that permission thing... –  Seva Alekseyev Feb 1 '12 at 15:28
add comment

3 Answers 3

It probably has nothing to do with CM; the Market is just really, really bad at updating itself. Sometimes clearing the data for it will help, but sometimes you'll additionally need to install a newer version manually before it will start updating itself again.

I've installed the 3.4.4 Market from Android Police a few times, if you're looking for a safe file. Just put it on your SD card or internal storage (make sure it has the .apk extension) and install it via a file manager. Settings -> Applications -> Unknown sources needs to be checked for this.

share|improve this answer
    
The version of the market that you've uploaded requres SDK level 10 (Android 2.3.3). CMv5 is level 7 (2.1). –  Seva Alekseyev Feb 1 '12 at 17:27
    
@SevaAlekseyev I totally missed that it was CM5, my bad. It can't require 2.3.3 though, since I use it on 2.2 with no issues. CM6.1 is 2.2 and available for the Magic, I would recommend upgrading. The permissions issue is intriguing, though. –  Matthew Read Feb 1 '12 at 17:34
add comment
up vote 3 down vote accepted

So the problem was: Market and Market Updater were not signed by the same key, no idea why. As a result, the Market wasn't able to send an intent to a receiver in the Market Updater that was protected by a signature-level permission. Here's what I've done.

I took MarketUpdater.apk from the device. I took it apart with apktool:

apktool d -s MarketUpdater.apk mu

I then opened the AndroidManifest.xml. I changed the package attribute under <manifest> to

package="com.android.vending.updateralt"

That was to avoid a name clash with the vanilla Market Updater app. Changed the <receiver> element's header to this:

<receiver android:name="com.android.vending.updater.UpdateMarketReceiver">

See - no permission attribute. No longer requiring that the intent sender is signed by the same certificate. Spelling out the Java package name in android:name was necessary, since the APK package name no longer matched the Java package name of the class.

I then packaged the APK back:

apktool b mu MarketUpdaterAlt.apk

I signed the APK, using the jarsigner tool, with an arbitrary key that I had from another project:

"C:\Program Files\Java\jdk1.7.0_02\bin\jarsigner.exe" -verbose -digestalg SHA1 -sigalg MD5withRSA  -keystore c:\Path\MyKeys.ks MarketUpdaterAlt.apk MyKey

Uploaded the APK to /system/app, registered with pm:

adb push MarketUpdaterAlt.apk /system/app
adb shell pm install -r /system/app/MarketUpdaterAlt.apk

And forced a Market self-update. Removed the preferences file:

adb shell rm /data/data/com.android.vending/shared_prefs/*

Then restarted the Market, waited for five minutes, and closed the Market. The update went through like a charm. Now I have Market 2.3.6, in-app billing and all.

Good thing the permission-based coupling between the Market and Market Updater was not two-way...

EDIT: the alternative updater APK is available for all at http://www.jishop.com/temp/MarketUpdaterAlt.apk

share|improve this answer
add comment

The solution of creating a new MarketUpdater did not work for me. I'm a newbie at rooted Android devices so maybe there's something that would be evident to someone who has more experience with it. I ran into an INSTALL_PACKAGE permission issue, and yes I did put MarketUpdaterAlt into /system/app/ and it was signed with my key, but that did not do the trick. The whole permission thing seems a bit finicky (see for instance this discussion).

At any rate, I've found an alternate way of getting the upgrade:

  1. Grab a relatively recent version of the Market app. (I used an apk titled Market-3.4.4.apk. It needs to be reasonably new but having the very latest does not matter since it will upgrade itself after a bit anyway. I have 3.10.9 now running.) Verify that the package is signed by Google.

  2. Clear Market data. (That's what I did back then but now I think pm uninstall, without the -k option, will accomplish the same thing.)

  3. adb shell mount -o remount,rw /system

  4. adb shell rm /system/app/Vending.apk

  5. adb shell pm uninstall com.android.vending

  6. adb push [Path to your new apk] /system/app/Vending.apk

  7. adb shell pm install /system/app/Vending.apk

  8. adb shell mount -o remount,ro /system

If you got an older version than the latest, any necessary upgrade will occur after a while. It may take a bit before the web interface to Google Play gets is view synchronized with what the local app says.

That's how I got the latest version of Google Play up and running on an old rooted myTouch 3g running CM 6.1. Someone with more foresight than I have could presumably integrate a newish version among the Google Apps when they do their initial flashing.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.