ionic platform add android- Package name must look

2019-01-18 09:45发布

Im getting started in developing ionic app, I followed the guide in http://ionicframework.com/docs/guide/installation.html

just in case: the command "ionic platform add ios" works and i have android sdk installed.

when typing the command "ionic platform add android" i get this error:

Adding android project...

/Users/LihaiMac/.cordova/lib/npm_cache/cordova-android/3.7.1/package/bin/node_modules/q/q.js:126
                throw e;
                      ^
Package name must look like: com.company.Name
Error: /Users/LihaiMac/.cordova/lib/npm_cache/cordova-android/3.7.1/package/bin/create: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1008:16)
at Process.ChildProcess._handle.onexit (child_process.js:1080:5)

I tried searching an answer in other related posts, but not successful.. I'll appreciate any help in solving my problem..

标签: ionic
6条回答
何必那么认真
2楼-- · 2019-01-18 10:07

"Package name must look like: com.company.Name" that error is very helpful. You have package name that is invalid, probably starts with number.

Android package rules:

  • The first character after a period must not be a number
  • The first character must be a letter or underscore
  • Usually the app id is your company's reserved Internet domain name.
  • The app id must consist of letters, numbers, and underscores.
查看更多
Lonely孤独者°
3楼-- · 2019-01-18 10:07

ID should be without dashes, just words separated with dots: word.word.word

查看更多
可以哭但决不认输i
4楼-- · 2019-01-18 10:17

In your config.xml give the package name according to your project package name Give widget id in your config.xml as com.test.testapp

查看更多
老娘就宠你
5楼-- · 2019-01-18 10:19

What mladen5 said is correct. You need to go to the config.xml of your Cordova/Phonegap project and edit the id to meet the package name expectations.

The name can be found in the ID property and is "com.mydomainhere.appnamehere" in the example config below:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.mydomainhere.appnamehere" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Awesome app</name>
    <description>
        The worlds most awesome app
    </description>
    <author email="your@email.com" href="http://www.anurlhere.com">
        Author name
    </author>
    <content src="index.html" />
    <access origin="*" />
</widget>
查看更多
疯言疯语
6楼-- · 2019-01-18 10:21

I had the same problem with Ionic a few weeks ago. The problem can be fixed by editing config.xml.

Find the line that starts with

The syntax inside id="" must be com.company.(company name)

查看更多
冷血范
7楼-- · 2019-01-18 10:24

The best way to do it is when you're creating a new app. The Ionic command line interface(CLI) supports two options to do that the right way:

You can also app and package name define using command line interface(CLI) creation you project time like this bellow.

ionic start MyNewApp blank --appname MyNewApp --id com.ionicbyrequest.mynewapp

MyNewApp is my project app name.

Simple, no ? Now when you deploy to stores your id will be unique.

查看更多
登录 后发表回答