简体   繁体   English

将ionic / cordova项目导入Android Studio时出错

[英]Error while importing ionic/cordova project to Android studio

I just started working on Ionic framework and created a project using CLI. 我刚刚开始研究Ionic框架,并使用CLI创建了一个项目。 I have added support for android platform generated an android project using the following command: 我添加了对使用以下命令生成的android项目的android平台的支持:

ionic platform add android  

This has been done successfully, Now i am importing tha android project to android studio but getting the following error related with gradle. 这已经成功完成,现在我将android项目导入android studio,但遇到了与gradle相关的以下错误。

FAILURE: Build failed with an exception.

* What went wrong:
Task '' not found in root project 'android'.

* Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.   

Following are the contents of build.gradle file available in cordovaLib folder 以下是cordovaLib文件夹中可用的build.gradle文件的内容
在此处输入图片说明

So if am i missing something while importing project or build.gradle needs to be updated? 因此,如果在导入项目或build.gradle时丢失了某些内容,是否需要更新?

I figured out the thing that was going wrong. 我发现出了问题。 I imported the ionic project that i created from CLI to Android studio. 我将我从CLI创建的离子项目导入了Android Studio。

There i got two seperate build.gradle files in ionic project. 在ionic项目中,我有两个单独的build.gradle文件。 One was in the root android project and other one was in CordovaLib project. 一个在root机器人项目中,另一个在CordovaLib项目中。 In both the gradle files buildToolVersion was being identified at the run time. 在两个gradle文件中,都在运行时标识了buildToolVersion。 So may be Android Studio was unable to resolve the build version. 因此,可能是Android Studio无法解析构建版本。

Setting hardcoded build version to "19.1" and SDK version to 21 fixed the issue. 将硬编码的构建版本设置为“ 19.1”,并将SDK版本设置为21可以解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM