Change default package from com.example for Eclipse Android projects

佐手、 提交于 2019-12-06 18:40:27

问题


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!



来源:https://stackoverflow.com/questions/13484833/change-default-package-from-com-example-for-eclipse-android-projects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!