Could not resolve project: CordovaLib
Asked Answered
R

2

13

I'm learning how to build app using cordova and I'm currently able to emulate a mobile screen via google chrome browser. I'm attempting to test it on android platform which requires using Android studio (downloaded the 3.0 stable version). After importing the project, Gradle project sync failed and there seems to be issues resolving some dependencies for CordovaLib. See image below

enter image description here

I have gone through several post here and still haven't been able to find a solution or maybe I'm missing the point considering that this is my first time learning with it. Below are the settings for

build.gradle(Module: CordovaLib)

enter image description here

and build.gradle(Module: android)

enter image description here

Please how do i fix the issue and run my app in an emulator?

Remaremain answered 13/11, 2017 at 11:50 Comment(0)
P
11

Is a typical error of migration, please read the paragraph 'Migrate dependency configurations for local modules':

You should instead configure your dependencies as follows:

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'
}
Pupiparous answered 13/11, 2017 at 12:21 Comment(10)
Read the user guide as adviced and made the changes to both build.gradle files first and one file and try to sync project again but it failed. Then made changes to both and tried again and still it failed. This is the error I'm getting now Error:Project with path ':library' could not be found in root project 'android'. When only the Cordova module build file is edited accordingly the error is Error:Project with path ':library' could not be found in root project 'Cordova'.Remaremain
did you put implementation project(':library')? it looks as you did not link the rows you eliminatedPupiparous
Yes I did that implementation project(':library') debugImplementation 'com.example.android:app-magic:12.3' and I also included :library in the settings.gradle file. Got a different error Could not find method implementation() for arguments [project ':library'] ... and I'm looking at the answers here now for a solutionRemaremain
to use implementation() you need to use gradle 4 not 3. Upgrade, and please accept my answer. Every question is for one specific reply in stack overflow. Continuos stacktrace errors is part of our job:)Pupiparous
I'm currently using Gradle 4.1 and no value is set for android plugin version field.Remaremain
in the screenshot you sent is written classpath 'com.android.tools.gradle:3.0.0' not 4Pupiparous
Let us continue this discussion in chat.Remaremain
@Mena, have you tried this implementation(project(path: "CordovaLib"))? It works for meLore
hello, if I need to use debug configuration in the releaseImplementation can you tell me how to use it ? ex : releaseImplementation project(path: ':androidLibrary',configuration: 'debug') to ?Rogelioroger
not really sorry, anyway I suggest you first of all to open the link posted and also to start a new post, in SO every question should have a post apartPupiparous
F
4

The solution from trocchietto is correct. Remember you're using "CordovaLib" no "Library" you just have to change like this.

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

However, the app-magic for me isn't necessary and I comment it.

My dependencies

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'
}
Foreandaft answered 22/2, 2018 at 15:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.