Elad Benda
Elad Benda

Reputation: 36654

what's my application package name in android?

I'm writing an android application.

It has some packages under src.

how can I figure out which of them is my application package?

I want to add C@DM permissions:

<permission android:name="YOUR_PACKAGE_NAME.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="YOUR_PACKAGE_NAME.permission.C2D_MESSAGE" />

how will my YOUR_PACKAGE_NAME change if I create a custom MyApplication extends Application class?

Upvotes: 8

Views: 34741

Answers (6)

Junaid Bashir
Junaid Bashir

Reputation: 172

If you are trying to access it programmatically and use the gradle-android-plugin to build your app, then you can use

BuildConfig.APPLICATION_ID

to retrieve the package name from any scope, incl. a static one.

If you are looking in android studio, The above answers are also correct but you can also build your project and search for BuildConfig file and there you can something similar

ublic static final String APPLICATION_ID = "com.android.yourpackagename";

Upvotes: 0

Akshay Salunkhe
Akshay Salunkhe

Reputation: 1

inside android/build.gradle folder applicationId

SS

Upvotes: -2

Abhishek Kumar
Abhishek Kumar

Reputation: 1015

You can find it in MainActivity.kt and ManinApplication.kt file at the starting line of the code with other imports.

Upvotes: 0

rayzinnz
rayzinnz

Reputation: 1948

Newer Android Studio using Gradle do not have "package name" nor is it mentioned in "AndroidManifest.xml".

Please find instead the "applicationId" inside the "build.gradle.kts" file, at module level not project level.

I.e.:

android {
    defaultConfig {
        applicationId = "com.example.myapp"

Reference: https://developer.android.com/build/configure-app-module

Quote:

the applicationId is automatically assigned the package name you chose during setup.

Upvotes: 5

Rishab Singh
Rishab Singh

Reputation: 21

enter image description here

  1. First click on project option
  2. Go to android
  3. Click on app option under android after that click on java option
  4. after that application package name will appear

enter image description here

Upvotes: 2

skoperst
skoperst

Reputation: 2309

Your application name is actually defined in the AndroidManifest.xml, in its first lines. Ex:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.yourcompany.appname"
    android:versionCode="66"
    android:versionName="0.57" >

note the package="com.yourcompany.appname" - this is your package definition.

Other places which contain your package name can be resources, class paths, packages and much more. But all of them should be aligned according to the manifest because that what the package manager reads.

Upvotes: 28

Related Questions