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

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

问题描述

不久前,我使用过 Eclipse 和 Phonegap,并成功部署了一些 Android 应用程序.所以现在我正在尝试在 Android Studio 中启动并运行新的 Phonegap/Cordova 应用程序,但到目前为止还没有任何运气.这是我尝试过的:

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

好的,这个工作

2) 然后我启动 Android Studio 并导入生成的应用程序,然后会出现一条消息此项目的 Gradle 设置尚未配置",然后按 OK.

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 version 1.10 is required. current version is 2.2.1",经过一些谷歌搜索我发现 这里有一个提示,我将 Gradle 中的一行从 'com.android.tools.build:gradle:0.10.+' 更改为: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.

但现在我遇到了错误Module android is not backed by 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'
顺便说一句,我知道错误消息说 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 文件并将 buildToolsVersion "19.0.0" 更改为 buildToolsVersion "19.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.

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

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天全站免登陆