Reputation: 1372
I was making some tests on a cordova app and everythings worked fine... unintentionally I closed the terminal (windows), and when I re-open it and try to make cordova run android (something that was working fine), it throws this error:
EDIT VERBOSE
Generating config.xml from defaults for platform "android"
Calling plugman.prepare for platform "android"
Preparing android project
Processing configuration changes for plugins.
Iterating over installed plugins: [ 'com.phonegap.plugins.PushPlugin',
'com.simonmacdonald.telephonenumber',
'cordova-plugin-whitelist',
'nl.x-services.plugins.socialsharing',
'org.apache.cordova.contacts',
'org.apache.cordova.device',
'org.apache.cordova.file',
'org.apache.cordova.geolocation',
'org.apache.cordova.media' ]
Writing out cordova_plugins.js...
Wrote out Android application name to "Nostro"
This app does not have launcher icons defined
Wrote out Android package name to "com.eatec.nostro"
Running command: cmd "/s /c "C:\Users\Eloy\Desktop\NOSTR\nostroApp\platforms\android\cordova\run.bat""
ANDROID_HOME=C:\Users\Eloy\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_45
WARNING : No target specified, deploying to device 'ZH80002TZ5'.
Running: C:\Users\Eloy\Desktop\NOSTR\nostroApp\platforms\android\gradlew cdvBuil dDebug -b C:\Users\Eloy\Desktop\NOSTR\nostroApp\platforms\android\build.gradle -PcdvBuildArch=arm -Dorg.gradle.daemon=true
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\Eloy\Desktop\NOSTR\nostroApp\platforms\android\build.gradle' line: 22
* What went wrong:
A problem occurred evaluating root project 'android'.
> Failed to apply plugin [id 'android']
> Plugin with id 'android' not found.
* 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.729 secs
C:\Users\Eloy\Desktop\NOSTR\nostroApp\platforms\android\cordova\node_module\q\q.js:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "C:\Users\Eloy\Desktop\NOSTR\nostroApp\platforms\android\gradlew cdvBuildDebug -b C:\Users\Eloy\Desktop\NOSTR\nostroApp\platforms\android\build.gradle -PcdvBuildArch=arm -Dorg.gradle.daemon=true"
Command finished with error code 1: cmd /s /c "C:\Users\Eloy\Desktop\NOSTR\nostroApp\platforms\android\cordova\run.bat"
ERROR running one or more of the platforms: Error: cmd: Command failed with exit code 1
You may not have the required environment or OS to run this project
I think, that JAVA_HOME and ANDROID_HOME are good configured, these are their values (shown by the cordova compilation proccess):
ANDROID_HOME=C:\Users\Eloy\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_45
Other possible important variables:
JDK_HOME: %JAVA_HOME%\bin
JRE_HOME: %JAVA_HOME%/jre
PATH: %SSL_HOME%;%NODE_HOME%;%MONGO_HOME%;%JDK_HOME%;%JRE_HOME%/bin;%ANT_HOME%/bin
Thank you very much.
EDIT
I tried with a fresh project, and it doesn't work. The steps I followed were:
cordova create aux
cd aux
cordova platform add android
cordova run android
EDIT
I just tried to compile an app on Android Studio, and it works fine. What could be cordova doing wrong???
EDIT
mmmm!! curious!!! I try to compile the same project with my room PC, but before I make a fresh project with cordova, and how it was foreseeable, it works fine, so I was ready to run the main project, I typed comand, and after a few lines, it started to download http://services.gradle.org/distributions/gradle-2.2.1-all.zip, and it download a lot of things, and finally it built succesfully, and install on my device.
Other thing that I discover is the that there are many differences on the contents of the folder project/platform/android between the main project (created on the laptop) and the test project (created on the pc). These are the main differences:
Contents on the TestProject: (folders) ant-build, ant-gen, (files) build.xml, custom_rules.xml, local.properties
Contents on the MainProject: (folders) gradle, (files) gradlew.bat, settings.gradle
The other files and folders are commons.
Upvotes: 0
Views: 1335
Reputation: 1461
check minsdk, maxsdk and target sdk versions - target sdk must be between min and max. i fixed issue buy setting
<preference name="android-minSdkVersion" value="14" />
<preference name="android-maxSdkVersion" value="23" />
<preference name="android-targetSdkVersion" value="16" />
Upvotes: 0
Reputation: 1372
Hi @GuillemVicens and @jcesarmobile, finally it is working... @jcesarmobile told me about upgrade node and the first step to do that is:
npm cache clean
Once made that, and before upgrade, I try to compile and it thrown a new fail... but it was a problem with easy solution: open the console with admin privileges. I try to compile (cordova run android) again and IT WORKS :D
EDIT I update too a lot of components of the Android SDK, but I think it wasn´t important, because I updated it yesterday, and make the first test today morning and it didn´t work, and after clean cache it does... so I think it was the key.
Muchas gracias Cesar. Moltes gracies Guillem.
Upvotes: 1