Import Cordova project in Android Studio

前端 未结 4 1824
盖世英雄少女心
盖世英雄少女心 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条回答
  • 2020-12-05 14:00

    We have some troubles on importing Ionic project to android studio because we have add android platform with SUDO command, and because of it, android studio dont have access privileges to read files. In my case just do sudo chmod -Rf 777 ionicFolder android studio can import project successful. I hope this help some one with this problem.

    0 讨论(0)
  • 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).

    0 讨论(0)
  • 2020-12-05 14:20

    Unfortunately the accepted answer is a bit out of date. Using Cordova v5.3.3 (it probably works on all versions > 5) it is much the same process a building and then entering XCode for an iOS application now - the build system has moved to gradle.

    Before opening in Android Studio

    cordova build android
    

    Then just open up the project using File > Open and pointing to the (yourProjectDir)/Platforms/Android directory.

    If you are using an older version of the cordova android platform you might need to run

    cordova platform android update
    

    To get moved to the gradle build system which is compatible with the current version of Android Studio

    0 讨论(0)
  • 2020-12-05 14:20

    All the answers above seem to refer to the cli. However, to actually have your project in android studio so that you can harness the power of the android studio, this is what I would suggest you do:

    Please see my most relevant answer here...

    Building Ionic framework in android studio

    0 讨论(0)
提交回复
热议问题