Android Studio和PhoneGap,模块android不支持gradle [英] Android Studio and PhoneGap, Module android is not backed by gradle

查看:941
本文介绍了Android Studio和PhoneGap,模块android不支持gradle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一开始我一直使用Eclipse和Phonegap,我已经成功部署了一些Android应用程序。所以现在我想让新的Phonegap / Cordova应用程序在Android Studio中运行,但迄今为止没有运气。这是我试过的:

A while back I've worked with Eclipse and Phonegap and I've successfully deployed a few Android apps. So now I'm trying to get the new Phonegap/Cordova app up and running in Android Studio but so far without any luck. Here's what I've tried:

1)我生成了一个cordova应用程序,并添加Android作为平台。

1) I've generated a cordova app and added android as platform.

cordova create hello com.example.hello HelloWorld
cd hello
cordova platform add android
cordova -version

OK这个工作

2)然后我启动Android Studio并导入生成的应用程序,并出现消息Gradle设置为这个项目尚未配置,我按确定。

2) Then I start Android Studio and import the generated app and a message "Gradle settings for this project are not configured yet" appears and I press OK.

3 )然后我得到一个错误Gradle版本1.10是必需的,当前版本是2.2.1和一些googling后,我发现这里有一个提示,我在'com.android.tools.build:gradle:0.10改变了Gradle中的一行。+':0.14。+',现在顶部的RUN图标已启用,因此似乎至少固定了一些东西。虽然版本nr对我没有意义,但从我可以收集的版本是非常具体的。

3) Then I get an error "Gradle version 1.10 is required. current version is 2.2.1" and after some googling I found a hint here and I changed a line in Gradle from 'com.android.tools.build:gradle:0.10.+' to :0.14.+' and now the RUN icon at the top is enabled so it seems to have fixed at least something. Although the version nr doesn't make sense to me but from what I can gather the versions are very specific.

但现在我被困在错误模块android不支持gradle,我不知道该怎么办。

But now I'm stuck on the error "Module android is not backed by gradle" and I don't know what to do.

任何帮助将非常感激。

推荐答案

好吧,我想出来,所以我只是回答自己的问题。希望它也会有利于别人试图做同样的事情。

Okay I've figured it out so I'll just answer my own question. Hopefully it will also benefit someone else trying to do the same thing.

实际上有两个build.gradle文件,一个在主项目和一个在CordovaLib文件夹中。我想CordovaLib是主项目中的一个子项目。因此,生成Cordova项目并将其导入Android Studio后,会出现错误

There are actually two build.gradle files, one in the main project and one in the CordovaLib folder. I guess CordovaLib is a subproject within the main project. So after generating the Cordova project and importing it into Android Studio an error appears

Error:Gradle version 1.10 is required. Current version is 2.2.1.

编辑build.gradle文件,并在这两个文件中进行以下更改:

更改 classpath'com.android.tools.build:gradle:0.10。+'

到此: classpath'com .android.tools.build:gradle:1.0.0'

Btw我知道错误消息说v1.10,但将其更改为给出另一个错误找不到。 。和1.0.0似乎工作,所以是去图...

Edit the build.gradle files and make the following change in both files:
change classpath 'com.android.tools.build:gradle:0.10.+'
to this : classpath 'com.android.tools.build:gradle:1.0.0'
Btw I know the error message said v1.10 but changing it to that gives another error "Could not find.." and "1.0.0" seems to work, so yeah go figure...

然后我从菜单中选择Build - > Rebuild Project,

Then I select Build -> Rebuild Project from the menu and it gives another error

Error:The SDK Build Tools revision (19.0.0) is too low for project 'android'.
Minimum required is 19.1.0

单击无效的错误消息不起作用,再次编辑build.gradle文件,并将 buildToolsVersion19.0.0更改为 buildToolsVersion19.1.0文件。要总结更改,请参阅下面的屏幕截图:

Clicking on the error message unhelpfully does nothing, but I again edit the build.gradle files and change buildToolsVersion "19.0.0" to buildToolsVersion "19.1.0" in both files. To sum up the changes see screenshot below:

然后再次选择 Build - >重建项目,它会在Gradle控制台中显示错误

Then again select Build -> Rebuild Project from the menu, and it will give an error in the Gradle Console

Error: Task '' not found in root project 'android'.

只需忽略它,然后执行 Build - >重新生成项目,然后它会给出一个信息对话框语言级别的更改将在项目重新加载生效。你想现在重新加载项目android吗?并按是。

Just ignore it, and do Build -> Rebuild Project again and then it will give an info dialog "Language level changes will take effect on project reload. Would you like to reload project "android" now?" and press Yes.

项目将重新加载,现在可以在设备或模拟器上运行。 :) phew ..

The project will reload and is now ready to run on a device or in the emulator. :) phew..

这篇关于Android Studio和PhoneGap,模块android不支持gradle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆