简体   繁体   中英

Cordova add Android platform

I'm trying to create a prgetto Cordova. The problem is when I go to add the Android platform. After this command:

cordova add Android platform

I have an answer from the shell this message:

Creating Android project ...

    /home/francesco/.cordova/lib/android/cordova/3.6.4/bin/node_modules/q/q.js:126
                        throw e;
                              ^
    Error: ANDROID_HOME is not set and "Android" command not in your PATH. You must Fulfill at least one of These conditions.
        at /home/francesco/.cordova/lib/android/cordova/3.6.4/bin/lib/check_reqs.js:159:19
        at _fulfilled (/home/francesco/.cordova/lib/android/cordova/3.6.4/bin/node_modules/q/q.js:798:54)
        at self.promiseDispatch.done (/home/francesco/.cordova/lib/android/cordova/3.6.4/bin/node_modules/q/q.js:827:30)
        at Promise.promise.promiseDispatch (/home/francesco/.cordova/lib/android/cordova/3.6.4/bin/node_modules/q/q.js:760:13)
        at /home/francesco/.cordova/lib/android/cordova/3.6.4/bin/node_modules/q/q.js:821:14
        at flush (/home/francesco/.cordova/lib/android/cordova/3.6.4/bin/node_modules/q/q.js:108:17)
        at process._tickCallback (node.js: 415: 13)
        at Function.Module.runMain (module.js: 499: 11)
        at startup (node.js: 119: 16)
        at node.js: 902: 3
    Error: /home/francesco/.cordova/lib/android/cordova/3.6.4/bin/create: Command failed with exit code 8
        at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
        at ChildProcess.EventEmitter.emit (events.js: 98: 17)
        at maybeClose (child_process.js: 743: 16)
        at Process.ChildProcess._handle.onexit (child_process.js: 810: 5)

I looked around but I could not solve. Can someone help me? There rinngrazio in advance.

You are using the wrong command. Use
cordova platform add android

Set the ANDROID_HOME environment variable to point to your Android SDK installation.

Then run this command:

cordova platform add android

You should follow the official guide .

  1. You need to install the Android SDK
  2. You have to add android tools to your PATH environment variable

You can do it by adding (and adapting) this to your /home/francesco/.bashrc:

PATH = $PATH:/home/francesco/android-sdk/platform-tools:/home/francesco/android-sdk/tools

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM