Building my app "Noob Alert!"

I have been trying the whole day to build this app using ionic build android

I don’t find an APK file in my app folder. In face there’s no build folder in platforms\android

Kindly assist! :frowning:
results:

C:\Apps\app10>ionic build android
[WARN] ionic build is for building web assets and takes no arguments. See ionic build --help.

       Ignoring argument android. Perhaps you meant ionic cordova build android?


Running app-scripts build:
[23:51:44]  build dev started ...
[23:51:45]  clean started ...
[23:51:45]  clean finished in less than 1 ms
[23:51:45]  copy started ...
[23:51:45]  copy finished in 159 ms
[23:51:45]  deeplinks started ...
[23:51:45]  deeplinks finished in 38 ms
[23:51:45]  transpile started ...
[23:51:52]  transpile finished in 6.97 s
[23:51:52]  preprocess started ...
[23:51:52]  preprocess finished in 1 ms
[23:51:52]  webpack started ...
[23:52:00]  webpack finished in 8.46 s
[23:52:00]  sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[23:52:02]  sass finished in 1.47 s
[23:52:02]  postprocess started ...
[23:52:02]  postprocess finished in 10 ms
[23:52:02]  lint started ...
[23:52:02]  build dev finished in 17.23 s
ionic cordova prepare --no-build
cordova prepare
Android Studio project detected


[23:52:06]  lint finished in 3.94 s

C:\Apps\app10>

ionic cordova requirements
Results:

C:\Apps\app10>ionic cordova requirements
 > cordova requirements
Android Studio project detected


Requirements check results for android:

Java JDK: installed 1.8.0
Android SDK: installed true
Android target: not installed
Please install Android target / API level: "android-26".

Hint: Open the SDK manager by running: "C:\Users\Username\AppData\Local\Android\Sdk\tools\android.bat"
You will require:
1. "SDK Platform" for API level android-26
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)
Gradle: installed C:\Program Files\Android\Android Studio\gradle\gradle-4.1\bin\gradle
(node:9008) UnhandledPromiseRejectionWarning: CordovaError: Some of requirements check failed
    at C:\Users\Username\AppData\Roaming\npm\node_modules\cordova\src\cli.js:414:27
    at _fulfilled (C:\Users\Username\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:787:54)
    at self.promiseDispatch.done (C:\Users\Username\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:816:30)
    at Promise.promise.promiseDispatch (C:\Users\Username\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:749:13)
    at C:\Users\Username\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:557:44
    at flush (C:\Users\Username\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:108:17)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
(node:9008) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:9008) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


C:\Apps\app10>

ionic info
results:

C:\Apps\app10>ionic info

cli packages: (C:\Users\Username\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 7.0.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    Node              : v8.10.0
    npm               : 5.6.0
    OS                : Windows 8.1

Environment Variables:

    ANDROID_HOME : C:\Users\Username\AppData\Local\Android\Sdk

Misc:

    backend : pro


C:\Apps\app10>

What am i doing wrong?

This message here is important. ionic build is for PWA/web building. The command you want is what the message says, ionic cordova build android

Try ionic doctor check to verify if your project is ok.
Then, you need to add platform to project, using ionic cordova add platform android (or ios).
Then build it, using ionic cordova build android

Thank you @SigmundFroyd this was real progress for me. but now i get this error

BUILD FAILED in 1m 49s
(node:8760) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Script 'C:\Apps\app10\platforms\android\CordovaLib\cordova.gradle' line: 68

* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> No installed build tools found. Install the Android build tools version 19.1.0 or higher.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 49s
    at ChildProcess.whenDone (C:\Apps\app10\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:8760) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8760) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


C:\Apps\app10>

I didn’t understand this

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

run what with ‘–stacktrace’ or am I looking at it wrongly? I apologies for my Noobiness

This looks like the source of your issues. Have you installed the Android SDK & build tools 'n wot?

Thank you for your response @DanielAccorsi, i did the ‘ionic doctor check’ and it returned this:

       An update is available for Ionic Native (4.5.3 => 4.6.0). To fix, the following step(s) need to be taken:

            1) Run: npm i --save -E @ionic-native/core@4.6.0
            2) Run: npm i --save -E @ionic-native/splash-screen@4.6.0
            3) Run: npm i --save -E @ionic-native/status-bar@4.6.0


? Fix automatically? Yes
> npm i --save -E @ionic-native/core@4.6.0
√ Running command - done!
> npm i --save -E @ionic-native/splash-screen@4.6.0
√ Running command - done!
> npm i --save -E @ionic-native/status-bar@4.6.0
√ Running command - done!
[WARN] Bundle ID unchanged in config.xml.

       The "bundle identifier" is a unique ID (usually written in reverse DNS notation, such as com.mycompany.MyApp)
       that Cordova uses when compiling the native build of your app. When your app is submitted to the App Store or
       Play Store, the bundle ID can't be changed. This issue was detected because this app's bundle ID is
       "io.ionic.starter", which is the default bundle ID provided after running ionic start. To fix, take the following
       step(s):

            1) Change the id attribute of <widget> (root element) to something other than "io.ionic.starter"

       Ignore this issue with: ionic doctor ignore default-cordova-bundle-id-used

Fixed 1 issue!
2 issues need to be fixed manually.

Then i tried this:

C:\Apps\app10>ionic doctor ignore git-not-used
[OK] Ignored issue git-not-used

C:\Apps\app10>

@SigmundFroyd I did, didn’t I?

Remember that you need to change the default id to your own, ok? This is not an error, but a warning.

YES ! it worked.
I just went to Android Studio, then to SDK Manager then ticked Show Package Details then added 27.0.3 under Android SDK Build-Tools 28-rc1. then Installed it.

Then I ran ‘ionic cordova build android’
Process went on, till APK was created at the end :slight_smile:
Thank you @SigmundFroyd and @DanielAccorsi!! Really appreciate it!

2 Likes