Import Cordova project in Android Studio

前端 未结 4 1876
盖世英雄少女心
盖世英雄少女心 2020-12-05 13:49

I am trying to create a Cordova project. After creating the project cordova create myProject I would like to open it in Android Studio. The problem is ... it do

4条回答
  •  旧时难觅i
    2020-12-05 14:01

    Make sure you import the "platform/android" directory underneath your cordova project (and you want to Import Project, not Open Project).

    You will at least need to run

    cordova prepare android
    

    before doing the import

    cordova build android 
    

    will also work, but it will create some ant directories which will not be used by Android Studio and you will have to actively ignore the files when importing otherwise you will get extra libraries in your project). Although I haven't imported a Cordova app into android studio recently, it definitely works in the Community edition of Intellij which Android Studio is based on (I did it yesterday with a project built from scratch with Cordova 3.5). I can't think of any of the additional features in Android Studio that would be useful that aren't in Intellij, as most of the additions which haven't been backported to Intellij are in the preview space which isn't going to work with Cordova anyway (all it is going to preview is a blank webkit view).

提交回复
热议问题