Change default package from com.example for Eclips

2020-08-10 19:40发布

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.

5条回答
老娘就宠你
2楼-- · 2020-08-10 19:44

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楼-- · 2020-08-10 19:45

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

查看更多
我命由我不由天
4楼-- · 2020-08-10 19:50

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.

查看更多
一纸荒年 Trace。
5楼-- · 2020-08-10 20:00

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

<property name = "SAVED_ANDROID_PACKAGE" value = "com.example" />
查看更多
Anthone
6楼-- · 2020-08-10 20:07

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

查看更多
登录 后发表回答