I install an apk and its package name is com.qihoo.appstore. Why in the /data/app directory its name is com.qihoo.appstore-2.apk. My question is what is the meaning of "-2" in the last?
Basically, any file you download which has the same name as one already available will get a number behind the name it has, which explains why you have that number there.
It can be confusing if you got different versions for each apk and you can't remember which one is the one you want to use.
For fixing it, you either have to delete the older ones that have no number and/or a lower number in the file name, or make a list of what version you gotten for each numbered and non-numbered file.
Related
Background
I want to check if 2 APK files are identical (or have a very high chance of being identical) in the minimal work on the device.
The reason for this, is that I have an app (here) that allows to install apps using APK files, so I want to check if the installed app is already the same as the APK file. This includes using root privilege for background install. So far, what I did was to check the package name and the version code, but I want to know if there is a little better way to perform this check.
The problem
By "minimal work", I mean minimal reads of the APK file itself. This means that going through all of the bytes of each of the APK files is the most correct way to check if files are identical, but if there is a signature for the APK, that identifies it relatively uniquely, that would be much better.
For example, I know you can do MD5 check on both files, and if it's the same for both, it's a really good chance both are the same, but such an algorithm, along with other similar algorithms (sha1 etc...), go over the entire file, so this is about the same as what I wrote before. It could take a while for large APK files.
What I've found
What I do know is that comparing the package name and the version number gives a clue about whether the APK files are of the same app and version, but I think that Android-Studio knows more about the APK files, because sometimes it asks if we want to uninstall the installed app even though they have the same version, and it doesn't seem like it takes it a lot of time to ask this.
I could add a file size check too, which should be relatively as fast as the package name and the version number, but maybe there is more ...
Here's a sample code of what I did:
public static boolean areApksMostProbablyIdentical(PackageInfo packageInfo, PackageInfo packageInfo2) {
if (packageInfo == null || packageInfo2 == null)
return packageInfo == packageInfo2;
if (!packageInfo.packageName.equals(packageInfo2.packageName))
return false;
if (packageInfo.versionCode != packageInfo2.versionCode)
return false;
final File file = new File(packageInfo.applicationInfo.publicSourceDir);
final File file2 = new File(packageInfo2.applicationInfo.publicSourceDir);
if (file.exists() && file2.exists())
return file.length() == file2.length();
return true;
}
The question
My question is:
Is it possible to perform a "good-enough" check on both files, avoiding comparing all bytes, to see if 2 APK files are the same?
What I do know is that comparing the package name and the version number gives a clue about whether the APK files are of the same app and version,
No it does not. All it tells that both packages used the same values. Anything but that is just pure assumption.
but I think that Android-Studio knows more about the APK files, because sometimes it asks if we want to uninstall the installed app even though they have the same version, and it doesn't seem like it takes it a lot of time to ask this.
Wow :) All AS knows about APK is in APK. There's no magic. Yet, not sure how you managed to reach your 50K (mostly android based) reputation score and still act like you never heard about the APK signing and all the certificate system used on Android. What usually triggers such uninstallation request dialog to popup is ordinary certificate mismatch, usually release vs debug one.
Is it possible to perform a "good-enough" check on both files, avoiding comparing all bytes, to see if 2 APK files are the same?
Once you define what good-enough and the same really means for you in this then perhaps, but by using common means of phrases I'd say no.
EDIT
The reason for this, is that I have an app (here) that allows to install apps using APK files, so I want to check if the installed app is already the same as the APK file
Then all you need to check if your installed app and the APK files are signed using the same certificate and are using the same packageId. If not, this is different app. If this matches, then I'd compare versionCode - if the same -> this is the same app. If higler/lower it's downgrade/upgrade. Sure, one can still release different APKs with the same versionCode and try to sideload it but I'd say it's not your problem to solve (that's the reason Google Play Store enforects versionCode bump on each update). Optionally, if you really got too much spare time you could compare APK file sizes.
I'm updating my app and I just wanted to know if the apk needs to be named the same as the original one that I uploaded. I'm pretty sure the answer is 'No', but just wanted to check as I can't find an explicit answer anywhere.
The only things that must match the original app are the package name and the signing keystore. Other than that, you can change anything you want, including the name of the apk file (Google Play will rename it on its servers anyways).
You will also need to increment the version code (the version name may stay the same)
As far as I know the key and the package name in your manifest should be same for each update , apk name should not matter.
Bit of an odd question but..
I am currently building an app, it will essentailly be a hotel listings directory with a few frills.
Having never made an app like this before I have suddenly found my self with the following question but cannot find the answer...
Is the there a limit the number of file you can package the app with, ie submit to itunes...
The reason I ask is potentially I will want to submit my app with a minimum 700+ images each in their own directory resulting in 1400+ files (assuming a directory is a file). I can get the size of the images to fit the 'over the air' max app download size.. but cannot find if there is a limit ot the number of files you can submit...
There is no as such limit for the number of files to be uploaded. However, as you mentioned it would be better to download your files from the app after installation.
This would help you reduce the binary size.
This is for iOS.
Your app usually comes in one .apk file. Your resources included. Link: https://en.wikipedia.org/wiki/APK_%28file_format%29 So its size is what matters.
You may want to double check the architecture of your app, it sounds like you want a webservice.
There is an application (already published to the Play Store) that has package name, that doesn't fully conform to the Java naming convention (like CompanyName.ApplicationName).
Today, I was unable to publish updated version to the Play Store because the Developer Console complains about bad package name of the uploaded APK. Existing package name only contains letters and does contain a dot, so the only reason for rejecting it that I can think of is package name starting with the upper-case letter. It does match the previously used package name.
Can it be the case? Are there are some recently implemented restrictions for package name?
edit
The error I'm getting is
The package name of your apk (CompanyName.ApplicationName) is invalid. Package
names must start with a character and can only contain characters,
numbers, underscores and dots. They must have at least one dot, cannot
end with a dot, and cannot contain any runs of more than one
consecutive dot.
I had same problem. Upload your apk in the new Developer Console.
You need 3 parts like org.meredrica.demo in your classpath to be compatible with android guidelines.
also you want to make it all lowercase, since they are case sensitive and capital names like that indicate classes (at least by convention, i'm not sure if its technically enforced)
So if i see something like CompanyName.ApplicationName I expect a class called CompanyName that contains a subclass ApplicationName.
You also might want to run android lint on your project.
I had the same problem while updating the apk file for an app with a package name of the form Aaa.Bbb.Ccc.Ddd, and Leon's solution worked. Though I did not understand it when I first read it.
What he meant is, in Google Play Android Developer Console, click the "Try the new design" button at the top right (which points to play.google.com/apps/publish/v2) to switch the web interface to a new layout. Uploading the apk in the new web UI works for me.
I'm new to publishing Android apps. Our app's name and the string that users should search for to find it on the Market is Eksjö
When I first uploaded it, the upload form suggested the name Eksjo (the name of the project, since Eclipse/Android SDK disallows deviant characters in the project name). Sadly, I accepted this and noticed it could be found (since the word is unique and is in the description, presumably), but that the Market name was Eksjo.
I edited the upload form, only changing the App name to Eksjö, but this did not change the Market name. Perhaps I was impatient, and an hour or so later it would have changed?
Anyway, I went back to Eclipse to change the :label (which I've since learned has nothing to do with the Market name), but it was already set correctly.
The best thread I've found on the subject is this: http://groups.google.com/group/android-developers/browse_thread/thread/b1a6ad78ce584a40#
I've come up with 3 ideas so far:
It says that the app Title can only be set from the Developer Console, but I can't type anything in the Console tab containing the console messages. (Am I barking up the wrong tree? Intuitively, I would think that typing setTitle('Eksjö') would only change the title of the current or possibly the main view of the app at runtime?)
The other alternative would be to upload an upgrade, where basically nothing has changed but where I can hopefully type a new Market name in the upload form. The question is whether this changes anything at all.
The third alternative would be to upload a completely new identical app, but with the correct Market name. But to do that, I'd have to change the package names (and sub-names, ie. com.whatever.common, com.whatever.viewname1, etc.) Can I do that with a refactor or do I have to manually rename all the views and includes?
Which one is the ticket, 1, 2, or 3?
I think 1 is your answer. and this can occour by changing the default string appName in your strings.xml file to the one you want. Also changing the market name and icon takes some time so just wait for the data to populate.