【问题标题】:Could not resolve project: CordovaLib无法解析项目:CordovaLib
【发布时间】:2017-11-13 11:50:17
【问题描述】:

我正在学习如何使用 cordova 构建应用程序,并且我目前能够通过 google chrome 浏览器模拟移动屏幕。我正在尝试在需要使用 Android Studio(下载 3.0 稳定版)的 android 平台上对其进行测试。导入项目后,Gradle 项目同步失败,解决 CordovaLib 的一些依赖项似乎存在问题。见下图

我在这里浏览了几篇帖子,但仍然无法找到解决方案,或者考虑到这是我第一次学习它,我可能错过了重点。以下是

的设置

build.gradle(模块:CordovaLib)

和 build.gradle(Module: android)

请问我该如何解决这个问题并在模拟器中运行我的应用程序?

【问题讨论】:

    标签: android cordova android-studio


    【解决方案1】:

    migration的典型错误,请阅读“迁移本地模块的依赖配置”段落:

    您应该按如下方式配置您的依赖项:

    dependencies {
    // This is the old method and no longer works for local
    // library modules:
    // debugImplementation project(path: ':library', configuration: 'debug')
    // releaseImplementation project(path: ':library', configuration: 'release')
    
    // Instead, simply use the following to take advantage of
    // variant-aware dependency resolution. You can learn more about
    // the 'implementation' configuration in the section about
    // new dependency configurations.
    implementation project(':library')
    
    // You can, however, keep using variant-specific configurations when
    // targeting external dependencies. The following line adds 'app-magic'
    // as a dependency to only the "debug" version of your module.
    
    debugImplementation 'com.example.android:app-magic:12.3'
    }
    

    【讨论】:

    • 按照建议阅读用户指南,先对 build.gradle 文件和一个文件进行更改,然后尝试再次同步项目,但失败了。然后对两者进行了更改并再次尝试,但仍然失败。这是我现在遇到的错误Error:Project with path ':library' could not be found in root project 'android'. 当仅相应地编辑 Cordova 模块构建文件时,错误是 Error:Project with path ':library' could not be found in root project 'Cordova'.
    • 你输入implementation project(':library')了吗?看起来你没有链接你消除的行
    • 是的,我做到了implementation project(':library') debugImplementation 'com.example.android:app-magic:12.3',我还在 settings.gradle 文件中包含了 :library。遇到不同的错误Could not find method implementation() for arguments [project ':library'] ...,我现在在这里查看答案以寻求解决方案
    • 要使用 implementation() 你需要使用 gradle 4 而不是 3. 升级,请接受我的回答。每个问题都是针对堆栈溢出中的一个特定答复。 Continuos stacktrace 错误是我们工作的一部分:)
    • 我目前正在使用 Gradle 4.1,并且没有为 android 插件版本字段设置值。
    【解决方案2】:

    trocchietto 的解决方案是正确的。 请记住,您使用的是“CordovaLib”而不是“库”,您只需像这样进行更改。

    // Instead, simply use the following to take advantage of
    // variant-aware dependency resolution. You can learn more about
    // the 'implementation' configuration in the section about
    // new dependency configurations.
    implementation project(':CordovaLib')
    

    但是,对我来说,应用程序的魔法不是必需的,我对此发表了评论。

    我的依赖项

    dependencies {
    // This is the old method and no longer works for local
    // compile fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    // debugCompile(project(path: "CordovaLib", configuration: "debug"))
    //releaseCompile(project(path: "CordovaLib", configuration: "release"))
    // SUB-PROJECT DEPENDENCIES END
    
    // Instead, simply use the following to take advantage of
    // variant-aware dependency resolution. You can learn more about
    // the 'implementation' configuration in the section about
    // new dependency configurations.
    implementation project(':CordovaLib')
    
    // You can, however, keep using variant-specific configurations when
    // targeting external dependencies. The following line adds 'app-magic'
    // as a dependency to only the "debug" version of your module.
    
    //debugImplementation 'com.example.android:app-magic:12.3'
    }
    

    【讨论】:

      猜你喜欢
      • 2012-08-22
      • 1970-01-01
      • 2020-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-09-28
      • 1970-01-01
      • 2017-12-03
      相关资源
      最近更新 更多