Android 无法解析项目:CordovaLib

Android 无法解析项目:CordovaLib,android,cordova,android-studio,Android,Cordova,Android Studio,我正在学习如何使用cordova构建应用程序,目前我能够通过谷歌chrome浏览器模拟手机屏幕。我正试图在android平台上测试它,这需要使用android studio(下载了3.0稳定版)。导入项目后,Gradle项目同步失败,解决CordovaLib的某些依赖关系时似乎出现问题。见下图 我已经在这里读了好几篇文章,但仍然没有找到解决方案,或者考虑到这是我第一次用它学习,我可能没有抓住要点。下面是的设置 gradle(模块:CordovaLib) 和build.gradle(模块:an

我正在学习如何使用cordova构建应用程序,目前我能够通过谷歌chrome浏览器模拟手机屏幕。我正试图在android平台上测试它,这需要使用android studio(下载了3.0稳定版)。导入项目后,Gradle项目同步失败,解决CordovaLib的某些依赖关系时似乎出现问题。见下图

我已经在这里读了好几篇文章,但仍然没有找到解决方案,或者考虑到这是我第一次用它学习,我可能没有抓住要点。下面是的设置

gradle(模块:CordovaLib)

和build.gradle(模块:android)

请说明如何解决此问题并在模拟器中运行我的应用程序?

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

您应该按照以下方式配置依赖项:


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

// 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'
}

阅读用户指南中的建议,并首先对build.gradle文件和一个文件进行更改,然后再次尝试同步项目,但失败。然后对两者都做了更改并重试,但仍然失败。这是我现在遇到的错误
error:Project with path':library'在根项目“android”中找不到。
当仅相应地编辑Cordova模块构建文件时,错误是
error:Project with path':library'在根项目“Cordova”中找不到。
您是否放置了
实现项目(':library'))
?看起来您没有链接删除的行是的,我做了
实现项目(':library')debugImplementation'com.example.android:app magic:12.3'
,我还在settings.gradle文件中包含了:library。出现了另一个错误
无法为参数[project]:library']找到方法实现()…
我现在查看这里的答案,寻找解决方案要使用实现(),您需要使用gradle 4而不是3。升级,请接受我的回答。每个问题都是针对堆栈溢出中的一个特定回答。Continuos stacktrace错误是我们工作的一部分:)我目前正在使用Gradle 4.1,并且没有为android插件版本字段设置任何值。
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'
}