When i compile an .apk with cordova build android and install it, i get "device is ready" in green, nothing more :-(


When i compile an .apk with cordova build android and install it, i get “device is ready” in green, nothing more :frowning:

i don’t understand this because the app works well in my VS code, why if i compile with cordova doesn’t run in any device?. I try phones and tablets. Always get “device is ready”.

Thank you.

What command are you running?
Where do you get that green output? Copy/paste it and format it as code here.
What is your ionic info output?

Command to compile: cordova build android.
Green output (“device is ready”) in all devices.
Copy/paste it and format it as code here: my apk is a little test than run ok if i do ionic serve --lab. After Corova’s compilation, the apk in my devices is a logo with a flashing green text “device is ready”. I don’t know wich code you want i put.
Well, the apk in the device i can’t do nothing with it, but the index.html in www thatn cordova creates is:

        Customize this policy to fit your own app's needs. For more guidance, see:
        Some notes:
            * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
            * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
            * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
                * Enable inline JS: add 'unsafe-inline' to default-src
        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
        <link rel="stylesheet" type="text/css" href="css/index.css">
        <title>Hello World</title>
        <div class="app">
            <h1>Apache Cordova</h1>
            <div id="deviceready" class="blink">
                <p class="event listening">Connecting to Device</p>
                <p class="event received">**Device is Ready**</p>
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="js/index.js"></script>

ionic info:

cli packages:

@ionic/cli-plugin-ionic-angular : 1.4.0 (C:\PROGRAMACION\Ionic 2\Prueba2\node_modules\@ionic\cli-plugin-ionic-angular)
@ionic/cli-utils                : 1.6.0 (C:\Users\JaVi\AppData\Roaming\npm\node_modules\ionic\node_modules\@ionic\cli-utils)
ionic (Ionic CLI)               : 3.6.0 (C:\Users\JaVi\AppData\Roaming\npm\node_modules\ionic)

local packages:

@ionic/app-scripts : 2.0.2
Ionic Framework    : ionic-angular 3.5.3


Node : v6.11.1
OS   : Windows 10
npm  : 3.10.10

Well, this dont seem to be an Ionic app.
Make sure you create Ionic app by the command:
ionic start app-name template-name

Your code seems to be of Phonegap app.

It’s a ionic app. And it was created with ionic start app-name blank.
That index.html is from the Cordova folder.
All i use is ionic 3. And when the app is running ok with ionic serve --lab, then i compile to .apk with cordova build android. The apk is generated but doesn’t run in any device.
It is like all tutorials say.

try using ionic cordova build android instead

sometimes cordova build android does not add changes to the build.

As @arnoldparge says this is a default Phonegap/Cordova app, not really an Ionic app. Run the ionic cordova command he suggested instead of directly the cordova one. This makes sure your Ionic app is built first and copied over to the Ionic folders before Cordova builds the native app.

1 Like

i’m new in ionic, cordova and all this.
But i don’t know why is so difficult to compile something.

I do:

ionic start APPname blank
Now i have a ionic 3 app that runs ok with ionic serve --lab

cd xxxx\APPname\www
Now i create folder “app” in that www
in that folder:

cd app

cordova create AppName com.name.app MyAppName

cd AppName


cordova platform add android


cordova build Android

That is all, like all tutorials say.

I can not write “ionioc cordova build android”, first it install cordova-cli and then it says that is not an instruction:

C:\PROGRAMACION\Ionic 2\Prueba2\www\app>ionic cordova create AppAnimales4 com.animales.app MiAppAnimales
? The plugin @ionic/cli-plugin-cordova is not installed. Would you like to install it and continue? Yes

npm install --save-dev --save-exact @ionic/cli-plugin-cordova@latest
√ Running command - done!
[ERROR] Unable to find command: cordova create AppAnimales4 com.animales.app MiAppAnimales


build .................... Build (prepare + compile) an Ionic project for a given platform
compile .................. Compile native platform code
emulate .................. Emulate an Ionic project on a simulator or emulator
platform ................. Manage Cordova platform targets
plugin ................... Manage Cordova plugins
prepare .................. Copies assets to Cordova platforms, preparing them for native builds
resources ................ Automatically create icon and splash screen resources
run ...................... Run an Ionic project on a connected device

It’s not, you are making it a lot more complicated than it actually is.

Then you are clearly reading the wrong tutorials.

This is the correct order of commands:

ionic start blank blank
cd blank
ionic cordova platform add android
ionic cordova build android

You don’t need to do this.

1 Like

You really don’t want to do that too.
When you generate your ionic3 project, all your dev take place in src folder. don’t do anything in www, its content is generated automatically.

I just do it like you say me:

New project created, then:

C:\PROGRAMACION\Ionic 2\PruebaBlanca>ionic cordova platform add android

cordova platform add android --save
√ Running command - done!
Using cordova-fetch for cordova-android@^6.2.3
Adding android project…
Creating Cordova project for the Android platform:
Path: platforms\android
Package: io.ionic.starter
Name: MyApp
Activity: MainActivity
Android target: android-25
Subproject Path: CordovaLib
Android project created with cordova-android@6.2.3
Installing “cordova-plugin-console” for android
Installing “cordova-plugin-device” for android
Installing “cordova-plugin-splashscreen” for android
Installing “cordova-plugin-statusbar” for android
Installing “cordova-plugin-whitelist” for android

           This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.

Installing “ionic-plugin-keyboard” for android
–save flag or autosave detected
Saving android@~6.2.3 into config.xml file …
√ Copying default image resources into ./resources/android - done!

And then

C:\PROGRAMACION\Ionic 2\PruebaBlanca>ionic cordova build Android

cordova platform add --save Android
× Running command - failed!
[ERROR] An error occurred while running cordova platform add --save Android (exit code 1):

    Using cordova-fetch for Android
    Error: Failed to fetch platform Android
    Probably this is either a connection problem, or platform spec is incorrect.
    Check your connection and platform name/version/URL.
    Error: cmd: Command failed with exit code 1 Error output:
    npm ERR! Windows_NT 10.0.15063
    npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program
    Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "Android" "--save"
    npm ERR! node v6.11.1
    npm ERR! npm  v3.10.10
    npm ERR! code E404

    npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/Android
    npm ERR! 404
    npm ERR! 404  'Android' is not in the npm registry.
    npm ERR! 404 Your package name is not valid, because
    npm ERR! 404  1. name can no longer contain capital letters
    npm ERR! 404
    npm ERR! 404 Note that you can also install from a
    npm ERR! 404 tarball, folder, http url, or git url.

    npm ERR! Please include the following file with any support request:
    npm ERR!     C:\PROGRAMACION\Ionic 2\PruebaBlanca\node_modules\npm-debug.log


It’s incredible. It is due to put “Android” (uppercase). If i put “android” all is well.

would you mind to say exactly what were wrong, what were you typing wrong?

It’s the capital letters.
If i write ionic cordova build Android —> fail
If i write ionic cordova build android —> goes well

ionic doesn’t accept uppercase letters:

“npm ERR! 404 1. name can no longer contain capital letters”

ooow hehehehe, that happens a lot, thanks for sharing the solution :slight_smile:

Now the apk runs in the devices.

Thank you very much!.

1 Like