-->

Change default package from com.example for Eclips

2020-08-10 19:16发布

问题:

I am using Eclipse 4.2 with Android SDK.

I am wondering if it is possible to change the default package ID com.example that shows in the "New Android Application" wizard as you type the application name?

I would like it to default to my own package ID so that I don't need to correct the Package Name field each time.

Is this possible to do? Please explain how.

回答1:

No, you cannot change the default; it's hardcoded in the plugin sources.

(For the curious, it's in com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectPage#SAMPLE_PACKAGE_PREFIX in the ADT code base). We should consider persisting the most recently set package prefix and inserting the parent package next time. Feel free to file an issue for that at http://b.android.com category Component-Tools.

-- Tor



回答2:

With Android Studio not running, edit the file: C:\Users\MyAccount\.AndroidStudio\config\options\options.xml (replace C: with the installation drive and MyAccount with your account name).

Within the xml file look for "property name="SAVED_COMPANY_DOMAIN" value=" and change the value to what you want.



回答3:

Following user2232952's guidance, for new versions of Android Studio change the value of:

<property name = "SAVED_ANDROID_PACKAGE" value = "com.example" />


回答4:

If you've already created your project, you could go to your AndroidManifest.xml file and update the attribute in the Manifest (root) tag

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="your.package.name"
    android:versionCode="1"
    android:versionName="1.0" >

Just make sure the rest of your code also reflects this change.



回答5:

Click the package name and hit Alt+Shift+R and Rename, it will update everything!