Someguy
Someguy

Reputation: 85

change application's package name in manifest

I know this question has been asked many times, but I didn't find exact solutions which I would understand.

I have made a little game with android studio and I would like to publish it. But then I find out that I can't use package name "com.example". How do I change this to "com.MYNAME"?

Here is my manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.MYNAME.APPNAME" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:label="@string/achievements"
            android:name=".Achievements"
            android:parentActivityName=".MainActivity" />
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.MYNAME.APPNAME.MainActivity" />
    </application>

</manifest>

If I change package="com.example.MYNAME.APPNAME"topackage="com.MYNAME.APPNAME", there will be errors in android:name=".MainActivity", android:name=".Achievements", android:parentActivityName=".MainActivity" and android:value="com.MYNAME.APPNAME.MainActivity".

Thank you for help!

Upvotes: 4

Views: 10549

Answers (4)

Subhasish Nath
Subhasish Nath

Reputation: 133

You don't have to do anything manually, Just right click on the package name > refactor > rename. Everywhere in your project the project name will be changed :)

Upvotes: 0

user5010376
user5010376

Reputation: 40

Please check this out and change com to org and then you can publish your app

https://youtu.be/A-rITYZQj0A

Upvotes: 1

Salah Nour ElDin
Salah Nour ElDin

Reputation: 508

please do the following to change your package name to the new one

  1. Right click on your project
  2. Choose Android Tools
  3. Choose Rename Application Package
  4. Enter your new package name then click ok

Upvotes: 1

Danial Hussain
Danial Hussain

Reputation: 2530

You need to change .java file package name also. Then clean the project and build again. Because .MainActivity is still in package name "com.example.MYNAME.APPNAME"

Upvotes: 2

Related Questions