A problem occurred evaluating root project 'android'


#1

ionic cordova build android
Running app-scripts build: --iscordovaserve --externalIpRequired --nobrowser

[10:23:34] build dev started …
[10:23:34] clean started …
[10:23:34] clean finished in 4 ms
[10:23:34] copy started …
[10:23:34] transpile started …
[10:23:36] transpile finished in 1.84 s
[10:23:36] preprocess started …
[10:23:36] deeplinks started …
[10:23:36] deeplinks finished in 13 ms
[10:23:36] preprocess finished in 14 ms
[10:23:36] webpack started …
[10:23:36] copy finished in 1.97 s
[10:23:43] webpack finished in 6.91 s
[10:23:43] sass started …
[10:23:43] sass finished in 740 ms
[10:23:43] postprocess started …
[10:23:43] postprocess finished in 6 ms
[10:23:43] lint started …
[10:23:43] build dev finished in 9.56 s
⠼ running command: cordova build android [10:23:45] lint finished in 1.75 s
:heavy_multiplication_x: running command: cordova build android - failed!

[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova build android (exit code 1):

ANDROID_HOME=/opt/android-sdk/
JAVA_HOME=/usr/lib/jvm/default-java
Subproject Path: CordovaLib

FAILURE: Build failed with an exception.

* Where:
Build file '/var/www/html/ionic/myApp/platforms/android/build.gradle' line: 20

* What went wrong:
A problem occurred evaluating root project 'android'.
> java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0

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

BUILD FAILED

Total time: 1.006 secs
Error: /var/www/html/ionic/myApp/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Build file '/var/www/html/ionic/myApp/platforms/android/build.gradle' line: 20

* What went wrong:
A problem occurred evaluating root project 'android'.
> java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0

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

#2

uninstall the android platform and reinstall it again.


#3

ionic cordova build android ok now
but ionic cordova run android is throwing the below error
UILD SUCCESSFUL

Total time: 1.323 secs
Built the following apk(s):
/var/www/html/ionic/myApp/platforms/android/build/outputs/apk/android-debug.apk

ANDROID_HOME=/opt/android-sdk/
JAVA_HOME=/usr/lib/jvm/java-8-oracle
No target specified and no devices found, deploying to emulator

Error: No emulator images (avds) found.

  1. Download desired System Image by running: /opt/android-sdk/tools/android sdk
  2. Create an AVD by running: /opt/android-sdk/tools/android avd
    HINT: For a faster emulator, use an Intel System Image and install the HAXM device driver

[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova run android (exit code 1).


#4

it means mobile is not attached with your computer to run the build. you can find that built apk in android platform…
or in mobile usb debugging is not enabled


#5

ok yes u r right will check with android studio thanks buddy
one more thing my code is like this
register() {
this.sqlite.create({
name: ‘data.db’,
location: ‘default’
})
.then((db: SQLiteObject) => {
db.executeSql(‘create table danceMoves(name VARCHAR(32))’, {})
.then(() => console.log(‘Executed SQL’))
.catch(e => console.log(“after then catch”+e));
})
.catch(e => console.log(“in catch”+e));
}

when I am calling register function its throwing this error
Angular is running in the development mode. Call enableProdMode() to enable the production mode.
Native: tried calling StatusBar.styleDefault, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
Native: tried calling SplashScreen.hide, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
Native: tried accessing the SQLite plugin but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
cordova_not_available
just want to know this also will get resolved by emulator or this is diffrerent


#6

are you trying it in browser if yes then it works only in device. bcs most of plugins are device dependent. about emulator i never tried


#7

ok thanks gautam will check now

this thing I am getting now

:heavy_multiplication_x: running command: cordova build android - failed!

[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova build android (exit code 1):

    ANDROID_HOME=/opt/android-sdk/
    JAVA_HOME=/usr/lib/jvm/java-8-oracle:/usr/lib/jvm/java-8-oracle
    Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.
    Looked here: /opt/android-sdk/tools/templates/gradle/wrapper

#8

Install a current version of cordova-android:


#9

getting this now

:heavy_multiplication_x: running command: cordova build android - failed!

[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova build android (exit code 1):

    ANDROID_HOME=/home/nikhil/android-sdk
    JAVA_HOME=/usr/lib/jvm/java-8-oracle
    
    FAILURE: Could not determine which tasks to execute.
    
    * What went wrong:
    Task 'wrapper' not found in root project 'android'.
    
    * Try:
    Run gradle tasks to get a list of available tasks.
    
    BUILD FAILED
    
    Total time: 3.826 secs
    Error: /usr/share/gradle/bin/gradle: Command failed with exit code 1

nikhil@nikhiltvisha:/var/www/html/ionic/myApp$ sudo cordova build android
ANDROID_HOME=/home/nikhil/android-sdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle

FAILURE: Could not determine which tasks to execute.

  • What went wrong:
    Task ‘wrapper’ not found in root project ‘android’.

  • Try:
    Run gradle tasks to get a list of available tasks.

BUILD FAILED

Total time: 2.063 secs
Error: /usr/share/gradle/bin/gradle: Command failed with exit code 1


#10

Can’t help, but:
Please use the </> button above the post input field to format your code or error message or wrap it in ``` (“code fences”) manually. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.


#11

I’m also having the same problem, When compiling or constructing using ionic cordova command.
This I get in console

✖ Running command - failed!

[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova build android (exit code 1):

        ANDROID_HOME=C:\Users\frankito\AppData\Local\Android\sdk
        JAVA_HOME=C:\Program Files\Java\jdk1.8.0_111
        Error: Cannot read property 'length' of undefined

Ionic versión: 3.3.0
Cordova versión: 7.0.1
Npm versión: 3.10.10


#12

Run the same command with --verbose at the end and post the output of ionic info.


#13

Run the command that says

ionic cordova build android --verbose

What came out was the following

Microsoft Windows [Versión 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. Reservados todos los derechos.

C:\Users\frankito\Documents\Ionic\ValorAgregado>ionic cordova build android --verbose
[DEBUG] Loading global plugin @ionic/cli-plugin-proxy
[DEBUG] Throwing PLUGIN_NOT_INSTALLED for global @ionic/cli-plugin-proxy
[DEBUG] Loading local plugin @ionic/cli-plugin-cordova
[DEBUG] Loading local plugin @ionic/cli-plugin-ionic-angular
Running app-scripts build: --iscordovaserve --externalIpRequired --nobrowser

[12:43:54]  build dev started ...
[12:43:54]  clean started ...
[12:43:54]  clean finished in 38 ms
[12:43:54]  copy started ...
[12:43:54]  transpile started ...
[12:44:03]  transpile finished in 8.94 s
[12:44:03]  preprocess started ...
[12:44:03]  deeplinks started ...
[12:44:03]  deeplinks finished in 230 ms
[12:44:03]  preprocess finished in 264 ms
[12:44:03]  webpack started ...
[12:44:04]  copy finished in 9.85 s
[12:44:29]  webpack finished in 25.52 s
[12:44:29]  sass started ...
[12:44:36]  sass finished in 7.42 s
[12:44:36]  postprocess started ...
[12:44:36]  postprocess finished in 39 ms
[12:44:36]  lint started ...
[12:44:37]  build dev finished in 42.56 s
> cordova build android
[12:44:54]  lint finished in 17.45 s
✖ Running command - failed!

[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.

[DEBUG] !!! ERROR ENCOUNTERED !!!
[ERROR] An error occurred while running cordova build android (exit code 1):

        ANDROID_HOME=C:\Users\frankito\AppData\Local\Android\sdk
        JAVA_HOME=C:\Program Files\Java\jdk1.8.0_111
        Error: Cannot read property 'length' of undefined

I sorry for my english, I speak spanish.


#14

No problemo, si tu comprendes que yo describe… and that’s it for my Spanish today :wink:

Try cordova build android --verbose directly, without the ionic in front. And also please run ionic info and post the output here.


#15

The same mistake

No scripts found for hook "before_build".
No scripts found for hook "before_prepare".
Checking config.xml and package.json for saved platforms that haven't been added to the project
Config.xml and package.json platforms are the same. No pkg.json modification.
Package.json and config.xml platforms are different. Updating config.xml with most current list of platforms.
PlatformApi successfully found for platform android
Checking config.xml for saved plugins that haven't been added to the project
Checking for any plugins added to the project that have not been installed in android platform
No differences found between plugins added to project and installed in android platform. Continuing...
Generating platform-specific config.xml from defaults for android at C:\Users\frankito\Documents\Ionic\ValorAgregado\platforms
\android\res\xml\config.xml
Merging project's config.xml into platform-specific android config.xml
Merging and updating files from [www, platforms\android\platform_www] to platforms\android\assets\www
Wrote out android application name "ValorAgregado" to C:\Users\frankito\Documents\Ionic\ValorAgregado\platforms\android\res\va
lues\strings.xml
android-versionCode not found in config.xml. Generating a code based on version in config.xml (0.0.1): 1
Wrote out Android package name "com.ionicframework.valoragregado971053" to C:\Users\frankito\Documents\Ionic\ValorAgregado\pla
tforms\android\src\com\ionicframework\valoragregado971053\MainActivity.java
Updating icons at platforms\android\res
Updating splash screens at platforms\android\res
This app does not have additional resource files defined
Prepared android project successfully
No scripts found for hook "after_prepare".
No scripts found for hook "before_compile".
ANDROID_HOME=C:\Users\frankito\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_111
Error: Cannot read property 'length' of undefined

Gracias , por tener paciencia para entenderme :slight_smile:


#16

Damn, that also didn’t give useful output :frowning:

Ok, then only thing left to do is for you to post your ionic info output you get when executing it in your project directory.


#17

I forgot to mention
I’ve created a new ionic application
and the same problem , when run the same command

Find out that another has the same problem:


#18

Your ionic info please…

How did you install Android SDK? Android Studio or manually?


#19

i installed with Android Studio.
In fact I recently updated my version of sdk
you mean this?

global packages:

    @ionic/cli-utils : 1.3.0
    Cordova CLI      : 7.0.1
    Ionic CLI        : 3.3.0

local packages:

    @ionic/app-scripts              : 1.3.7
    @ionic/cli-plugin-cordova       : 1.3.0
    @ionic/cli-plugin-ionic-angular : 1.3.0
    Cordova Platforms               : android 6.2.3
    Ionic Framework                 : ionic-angular 3.3.0

System:

    Node       : v6.10.1
    OS         : Windows 7
    Xcode      : not installed
    ios-deploy : not installed
    ios-sim    : not installed

#20

Yes, thank you. But didn’t really help, I have no idea what could cause this.