Instruction on how to create an ionic project with a unique project name and with a unique Java package name

As of ionic v1.0.0-beta.12, you can create a project with a unique project name as well as a unique package name.

Follow the steps below:

Step 1. First, update your ionic CLI.

  $ npm update -g ionic

Step 2. On the ionic command line, provide an app name (Project Name) and an id (Package Name) as command line parameters.

 Example:

$ ionic start HelloWorld  tabs   --appname "Hello World" --id  'com.mycompany.helloworld'

(NOTE: For the --appname, use " " (double quotes) to be able to use a space between words.)



========== The article below is obsolete as of ionic v1.0.0-beta.12 =======

The beta 1.0.0-beta.9 ionic creates a new project with a default project name ā€˜HelloCordovaā€™ and a default Java package name ā€˜com.ionicframework.starterā€™.

Here is a step-by-step instruction on how to replace the default project name with your own project name and your own package name on Windows.

It also shows you how to import the newly created ionic project into Eclipse, so you can further work on the ionic project using Eclipse.

STEP 1. Start Git-Bash command window.

STEP 2. In Git-Bash command window:

(1) Go to the Eclipse-workspace root directory.
(ex) $cd /c/Eclipse-workspace-PhoneGap
$ pwd
$/c/Eclipse-workspace-PhoneGap

STEP 3. Create an ionic project on the Eclipse workspace root directory

Format: $ionic start projectName [template]
Examples
$ionic start NewBlankApp blank (for no template)
$ionic start TestTabs tabs (for tabs template)
$ionic start TestSideMenu sidemenu (for sidemenu template)

STEP 3.1 ------------ Possible errors I can get at this step ------------------------------
(1) Problem Description

When I create a new ionic project,
I can get the following error message.

Fetching plugin ā€œhttps://github.com/driftyco/ionic-plugins-keyboardā€ via git clone
^^^^^^^^^^^^^^^^
Error: Command failed: fatal: could not create work tree dir ā€˜C:\Users\Home\AppData\Local\Temp\plugman\git\1405247576143ā€™.: No such file or directory
at ChildProcess.exithandler (child_process.js:647:15)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:755:16)
at Socket. (child_process.js:968:11)
at Socket.emit (events.js:95:17)
at Pipe.close (net.js:465:12)

ERROR: Unable to add plugins. Perhaps your version of Cordova is too old.
^^^^^^^^^^^^^^^^^^^
Try updating (npm install -g cordova), removing this project folder, and trying again.

(2) SOLUTION

The error message says there is no directory ā€˜C:\Users\Home\AppData\Local\Temp\plugman\git\1405247576143ā€™.

All I need to do is to create ā€˜plugmanā€™ and ā€˜gitā€™ sub-folders under ā€˜C:\Users\Home\AppData\Local\Tempā€™ manually and make sure they are not read-only.


STEP 4. cd ./projectName

Example:
$cd ./MyProject

STEP 5. Make a project name and a Java package name unique.

Change the project name and package name in the ~/MyProject/config.xml file:

(1) Change the project name from the default ā€œHelloCordovaā€ to a unique project name such as ā€œMyProjectā€

(2) In ~/MyProject/config.xml file,
Change the default Java package name to a unique Java package name as shown below:

 "<widget id="com.ionicframework.starter" " -> <widget id="com.unique.package-name"

(3) If I want to change the app version number, in ~/MyProject/config.xml file,

change version=ā€œ0.0.1ā€ -> to version=ā€œ0.0.2ā€ (in tag)

STEP 6. Now, in the project directory (such as"~/MyProject")
add a platform (Android or iOS) to the project.

in ~/projectName/ (such as ~/MyProject/) directory, execute the following command:

$ ionic platform android
(or $cordova platform add android)

NOTE: This command now will create an Android project using the unique names given in STEP 5 above.)

STEP 7. To work on the project using Eclipse, import the project into Eclipse
(CAUTION)
When you import an ionic project into Eclipse, make sure you do not check the ā€˜copy project into workspaceā€™ checkbox on the Eclipse import projects window. Otherwise, you will not be able to build and deploy your ionic app using Eclipse ā€˜Runā€™ button.

And, Eclipse ā€˜import Projectsā€™ window will list two project names to import. You should check both project names to be imported and import both of them as follows:

For example, if your unique project name is ā€˜TestProjā€™, when you import it to Eclipse, Eclipse ā€˜Import Projectsā€™ window will list the following two projects names to be imported on the ā€˜New Project Nameā€™ column:
(1) TestProj
(2) TestProj-CordovaLib

You have to check both project names to be imported and import both of them.

After importing is completed, you will see two project folders on Eclipse ā€˜Package Explorerā€™ as follows:
(1) TestProj
(2) TestProj-CordovaLib

You work on the ā€˜TestProjā€™.
Go to ā€˜TestProj/assets/wwwā€™ folder. That is your ionic app.
Do not touch the ā€˜TestProj-CordovaLibā€™ project. It just needs to be there, otherwise ā€˜TestProjā€™ wonā€™t work.

STEP 8. After importing the project into Eclipse,

To show "~MyProject/assets/www/" directory within Eclipse,
 click the following Eclipse menu items
Project -> Properties -> Resource -> Resource Filters

and delete the exclusion filter.

CONCLUSION:
Now, you can work on your app within Eclipse with a unique ionic project name.
When you install the new app on your device (such as Android phones),
the new app will be installed with a unique app name, a Project Name you gave, not as ā€˜HelloCordovaā€™.

1 Like

Hey,

Thanks for your help got it to import into eclipse but alot of problems trying to ā€œbuildā€ using eclipse android plugin

see Using Ionic with Eclipse

building via eclipse terminal works with ionic run android though.

Any thoughts?

The reason you import an ionic project into Eclipse is to use Android SDK and ADT (Android Developer Tools) to build and deploy your app to a target device or an emulator, without using the command line command such as ā€˜ionic run androidā€™.

You have to have a complete working Android ADT environment within Eclipse before you import an ionic project. This mean you should be able to deploy a ā€˜Hello Worldā€™ app to your target device using your Eclipse with ADT (by clicking ā€˜Run as Android Appā€™ on Eclipse) independently from an ionic project.

Once you can do it, you import an ionic project as described above. Once it is imported, you consider it as a native android app. This means you build and deploy an app just same as a native android app.
And, click on ā€˜Run as Android Appā€™ on Eclipse. Do not use the command line command.

Well I want to believe I have a good working copy. Iā€™m using the latest Eclipse and plugins from google. Even updated the AVD and ADT. Iā€™ll have a look at again but as of nowā€¦using the eclipse terminal to do my compiling and debugging so far has been ok for now.

Thanks alot

Iā€™d like to check one thing with you.

When you imported an ionic project into Eclipse, did you check the ā€˜Copy project into workspaceā€™ checkbox on the Eclipse import projects window? If you did, that is the problem.
When you import an ionic project into Eclipse, you should not ā€˜copy project into workspaceā€™. Then, you will be able to build and deploy your ionic app using Eclipse ā€˜Runā€™ button.

OOOOOOooooooooohhhhhh ok I did thatā€¦I tried it and it didnā€™t work still.

During the import the dialog shows you two paths when you select the folder in question

the paths reference two folders

/platforms/android and /platforms/android/CordovaLib

Do I check both folders as well?

my ā€œProblems Logā€ for the workspaces indicates the following

Description Resource Path Location Type
The container ā€˜Android Dependenciesā€™ references non existing library ā€˜E:\SERVER\Mobile\AATTApp\platforms\android\CordovaLib\bin\aattapp-cordovalib.jarā€™ AATTApp Build path Build Path Problem

and

Description Resource Path Location Type
The project cannot be built until build path errors are resolved AATTApp Unknown Java Problem

I have NO idea what these problems are really no file(s) indicates such

After googling some of my issues I got this solution to work for me

Yes, you have to check both folders.

For example, if your unique project name is ā€˜TestProjā€™, when you import it to Eclipse, Eclipse ā€˜Import Projectsā€™ window will list the following two projects names to be imported on the ā€˜New Project Nameā€™ column:
(1) TestProj
(2) TestProj-CordovaLib

You have to check both project names to be imported and import both of them.

After importing is completed, you will see two project folders on Eclipse ā€˜Package Explorerā€™ as follows:
(1) TestProj
(2) TestProj-CordovaLib

Do not touch the ā€˜TestProj-CordovaLibā€™ project.
You work on the ā€˜TestProjā€™.
Go to ā€˜TestProj/assets/wwwā€™ folder. That is your ionic app.