Cordova fails with output code 2

综合技术 2018-05-18 阅读原文

I am building an ionic/angularjs/phonegap app. I am new to front end development. I have a package.json and a bowser.json. In package.json, after installing packages, I run "bower install" to install all the bower dependencies. I am able to run a python server in www and see the app in chrome. I am however not able to run in the android emulator. Can someone please guide me?

EDIT

I realized after posting this question that ionic already ships with angular and I should just use that. Also don't need bootstrap as ionic is a framework I need. Just need underscore. I will clean it up. But I don't think any of this is related to the error.

Here is the error after running " cordova build
":

BUILD FAILED
k:androidsdktoolsantbuild.xml:932: The following error occurred while execu
ting this line:
k:androidsdktoolsantbuild.xml:950: java.lang.ArrayIndexOutOfBoundsException
: 1
        at com.android.ant.DependencyGraph.parseDependencyFile(DependencyGraph.j
ava:180)
        at com.android.ant.DependencyGraph.(DependencyGraph.java:54)
        at com.android.ant.SingleDependencyTask.initDependencies(SingleDependenc
yTask.java:87)
        at com.android.ant.AaptExecTask.execute(AaptExecTask.java:509)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
        at com.android.ant.IfElseTask.execute(IfElseTask.java:124)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.jav
a:396)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:435)
        at org.apache.tools.ant.Target.performTasks(Target.java:456)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
cutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
        at org.apache.tools.ant.Main.runBuild(Main.java:851)
        at org.apache.tools.ant.Main.startAnt(Main.java:235)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Total time: 4 seconds
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,k:tmpangularToDop
latformsandroidbuild.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: cmd: Command failed with exit code 2
    at ChildProcess.whenDone (c:UsersIBM_ADMINAppDataRoamingnpmnode_module
scordovasrcsuperspawn.js:112: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)

Package.json

{
  "name": "ionic-project",
  "version": "1.0.0",
  "description": "An Ionic project",
  "dependencies": {
    "gulp": "^3.5.6",
    "gulp-sass": "^0.7.1",
    "gulp-concat": "^2.2.0",
    "gulp-minify-css": "^0.3.0",
    "gulp-rename": "^1.2.0",
    "karma": "~0.10",
    "protractor": "~0.17.0",
    "bower": "^1.3.1"
  },
  "scripts": {
    "postinstall": "bower install"
  }
}

Bower.json(I got it from angularjs seed project)

{
  "name": "angular-seed",
  "description": "A starter project for AngularJS",
  "version": "0.0.0",
  "homepage": "https://github.com/angular/angular-seed",
  "license": "MIT",
  "private": true,
  "dependencies": {
    "angular": "1.2.x",
    "angular-route": "1.2.x",
    "angular-loader": "1.2.x",
    "angular-mocks": "~1.2.15",
    "bootstrap" : "3.1.1",
    "underscore" : "1.6.0"
  }
}

@givanse - I answered my own question, so if you have platform dependencies(meaning code you do not want to loose in platform/android), so to do a clean build, I did:

rm -r platforms/android/ant-build
rm -r platforms/android/assets

all is good now. Thanks.

Hello, buddy!

责编内容by:Hello, buddy!阅读原文】。感谢您的支持!

您可能感兴趣的

Request data in Node.js from Angular without bodyP... In my app I need to use body parser to request params ( Node.js Angular based on angular-express-blog ). For example (angular contr...
Angular-google-maps vs. Angular-ui &... I'm new to angularJS and like to build an simple application, where an google map is displayed in order to load long/lat coordinates to display them i...
In bxslider I want to add a class on the current s... How do I add a class to the current li or image? I want to add a class on the current li or image, but I can not see any options...
This is how angular-cli/webpack delivers your CSS ... CSS loaderMost loaders and plugins come as separate packages so letâ€s install it: – npm install –save-dev css-loaderAfter weâ€ve got...
Using Ionic/Cordova app sources as PWA Many companies have now started to build PWAs instead of native apps , but sometimes you want/need both: PWA and native app. One main reason co...