无法使用Android Studio向CordovaLib for Cordova项目添加模块依赖项 [英] Can't add module dependency to CordovaLib for Cordova project using Android Studio

查看:184
本文介绍了无法使用Android Studio向CordovaLib for Cordova项目添加模块依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法锻炼如何在Android Studio中将 CordovaLib 目录添加为模块依赖项。

I can't workout how to add the CordovaLib directory as a module dependency in Android Studio.

(注意:这是我第一次使用Android Studio,所以可能我只是不知道自己在做什么)

我正在使用:


  • OSX Yosemite

  • Android Studio 1.1.0

  • 科尔多瓦4.3

这是我已采取的步骤:


  1. 创建新的cordova项目

  2. 添加android平台和一些cordova插件

  3. 导入生成的项目进入Android Studio(注意:当它询问gradle包装器时,我说不,只是指向安装了gradle的位置- /usr/local/Cellar/gradle/2.2.1/libexec

  4. 尝试构建-此时,它会抱怨一些找不到符号类CordovaPlugin的Cordova插件

  1. Create new cordova project
  2. Add android platform and some cordova plugins
  3. Import the generated project into Android Studio (NOTE: when it asks about the gradle wrapper, I say no and just point it to where I have gradle installed - /usr/local/Cellar/gradle/2.2.1/libexec)
  4. Try to build - at this point it will complain for several of the Cordova plugins that cannot find symbol class CordovaPlugin

显然不是了解 CordovaLib 子项目。 这就是我要解决的问题。

Obviously it doesn't know about the CordovaLib subproject. This is what I'm trying to fix.

我不知道如何告诉Android Studio CordovaLib 是模块依赖项。

I can't work out how to tell the Android Studio that CordovaLib is a module dependency.

我已经进入 Project Structure 窗口,但是不能看到任何链接到CordovaLib的方法。

I've gone to the Project Structure window, but can't see any way to link to CordovaLib.

点击 +按钮不会执行任何操作。如果我做错了什么,或者导入项目时Android Studio中有错误,我就无法解决。

Clicking the "+" buttons does not do anything. I can't work out if I'm doing something wrong, or there are bugs in Android Studio when importing the project...

有人可以确认吗?如果我做错了什么?

或者请确认他们是否能够使用将Cordova生成的项目导入Android Studio。 Cordova 4.3 Android Studio 1.1.0

Or please confirm if they are able to import Cordova generated projects into Android Studio, using Cordova 4.3 and Android Studio 1.1.0.

谢谢!

推荐答案

我遇到了同样的问题,是因为加载模块CordovaLib时出错。您必须执行以下两个步骤:

I had the same problem, is because there are error to load the module CordovaLib. You have to make this two steps:

1.-在根文件(Android)中,添加一个名为 settings.gradle的文件,其内容为:

1.- In root file (Android) add a file named "settings.gradle" with the content:

include ':CordovaLib'
project(':CordovaLib').projectDir = new File('CordovaLib')

2。-转到文件 build.gradle并找到此部分:

2.- Go to file "build.gradle" and find this part:

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    // SUB-PROJECT DEPENDENCIES END
}

并将其更改为:

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':CordovaLib')
    // SUB-PROJECT DEPENDENCIES START
    // SUB-PROJECT DEPENDENCIES END
}

现在您只需要运行项目。

Now you just have to Run the project.

这篇关于无法使用Android Studio向CordovaLib for Cordova项目添加模块依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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