3

When creating an Android application using Java, you place your classes into packages such as com.example.appName

However, in the Android XML manifest file, you also specify the package there.

It is my understanding that the Google Play Store, where Android apps are uploaded, uses the package name as a unique identifier for your app.

So, which package name actually identifies your app/APK file? And can the package names in your code be different to the package name in the manifest?

6 Answers 6

7

Only the package name in AndroidManifest.xml counts and must not change. The package you put your Java classes in can be anything.

Sign up to request clarification or add additional context in comments.

2 Comments

So the package names in code and the manifest are completely independent of each other? And the package names in code are basically ignored?
@LiamFlaherty They are not ignored. Your manifest must for example state the full (java) package name of your Activities. As long as they are the same you can write something short like ".MainActivity" and it will assume that you mean "[package name].MainActivity", if they are different you'll have to write down the full path. Java package name: to organize your code as you like. Manifest package name: Play Store App identifier.
2

The Play store picks up the package as the identifier from the manifest file.

It really doesn't matter if your source files go into the same package or something else.

So, you can manage/arrange your source files into any arbitrary packages you want.

Generally, it's easier to have your source files in the same package/sub-package as your manifest file, so that referencing them from the manifest file is easier, as you will not have to specify the fully qualified class names for your activities/services etc.

Comments

1
which package name actually identifies your app/APK file?

play store will take only Android manifest package. like package="com.example.appName"

 can the package names in your code be different to the package name in the manifest?

yes, you can use different package for your code but need to give the absolute package name when declaring in manifest.xml

android:name="org.demo.MyFile"

1 Comment

So the package name in the manifest can't be completely different to any package names in the code?
1

Android XML manifest file package is understanding by the Google Play Store because Google Play Store only read this file , when you upload android application in google play store.

so, if you src package and manifest is different then it do not make any problem.

Thanks

Comments

0

I just want to add couple more observation: * the field package from AndroidManifest is also used for package of generated classes (e.g. R class) * and something important if you are using google map v2 in your project pay attention of the package used in authorization because need to be the same. if you don't do that it will just not fetch the map but with no error message in logcat. (just hit this issue today and yesterday)

googlemap v2 version 8.1.1 google play services 4.4.52

Comments

0

The answers here seem a little out from my experience.

In Android Studio the applicationId in your Build.Gradle is the important attribute and should not change.

Our Manifest package name was different from our applicationId, I changed them to be the same and was able to upload the APK to Google Play without error.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.