Android build error: Could not resolve project :CordovaLib

Hi
I need to make an APK for my ionic project( not the release build). I used android studio 3.0 . After adding android platform, i imported the android project inside platform folder in android studio. It automatically starts building the project as soon project is imported. After some processing i got the folllowing errors

:

Unable to resolve dependency for ‘:@debug/compileClasspath’: Could not resolve project :CordovaLib.

Could not resolve project :CordovaLib.
Required by:
project :

Project : declares a dependency from configuration ‘debugCompile’ to configuration ‘debug’ which is not declared in the descriptor for project :CordovaLib

i m including the screenshots of errors

Please help me kknow the exact procedure to make the apk of an ionic 3 project.
My ionic info is as following:

cli packages: (C:\Users\nitin94\AppData\Roaming\npm\node_modules)

@ionic/cli-utils  : 1.13.1
ionic (Ionic CLI) : 3.13.2

global packages:

cordova (Cordova CLI) : 6.5.0

local packages:

@ionic/app-scripts : 2.1.4
Cordova Platforms  : android 6.1.2 browser 4.1.0
Ionic Framework    : ionic-angular 3.6.1

System:

Android SDK Tools : 26.1.1
Node              : v6.11.2
npm               : 3.10.10
OS                : Windows 10

Misc:

backend : legacy

Let me know if any further info is required…
Thanks in advance

1 Like

+1. I tried … and it run…
//debugCompile(project(path: “CordovaLib”, configuration: “debug”))
//releaseCompile(project(path: “CordovaLib”, configuration: “release”))
implementation project(’:CordovaLib’)

1 Like

+1 me too

Unable to resolve dependency for ‘:@debug/compileClasspath’: Could not resolve project :CordovaLib.

Could not resolve project :CordovaLib.
Required by:
project :

Project : declares a dependency from configuration ‘debugCompile’ to configuration ‘debug’ which is not declared in the descriptor for project :CordovaLib.

Here’s a fix from StackOverflow:

I commented the lines below in the build.gradle file:

//debugCompile project(path: 'CordovaLib', configuration: 'debug') 

//releaseCompile project(path: 'CordovaLib', configuration: 'release')

and added:

compile project(':CordovaLib')

This worked for me.

1 Like

this worked for me once. but if i ionic cordova run android --device it rewrites the build.gradle!

1 Like

I tried but the file is being rewritten too…

Did you find a solution ?

compile project(’:CordovaLib’)

implementation project(’:CordovaLib’)

I tried both the solutions but I am getting following error :

Error:More than one variant of project :CordovaLib matches the consumer attributes:

  • Configuration ‘:CordovaLib:debugApiElements’ variant android-aidl:
    • Found artifactType ‘android-aidl’ but wasn’t required.
    • Required com.android.build.api.attributes.BuildTypeAttr ‘debug’ and found compatible value ‘debug’.
    • Found com.android.build.api.attributes.VariantAttr ‘debug’ but wasn’t required.
    • Required com.android.build.gradle.internal.dependency.AndroidTypeAttr ‘Aar’ and found compatible value ‘Aar’.
    • Required org.gradle.usage ‘java-api’ and found compatible value ‘java-api’.
  • Configuration ‘:CordovaLib:debugApiElements’ variant android-classes:
    • Found artifactType ‘android-classes’ but wasn’t required.
    • Required com.android.build.api.attributes.BuildTypeAttr ‘debug’ and found compatible value ‘debug’.

It also happens to me, when I run the command ionic cordova run android --device it rewrites the build.gradle :frowning:

Did you find any solution?

I’m having the same problem! Is there a solution for that already?

I have same problem if any one solve this answer then post here. Needed.

Ok, i found a solution.

I was using cordova-android: 6.3.0. I updated the version to 7.1.0 and then changed this line in the config.xml

before was:

<preference name="android-minSdkVersion" value="16" />

Now i’m using:

<preference name="android-minSdkVersion" value="19" />

This way, ionic cordova run android is working again!

In my project I have this minSdkVersion and the error continue, same ideia to solve?

The related problem is described on this Github Issue on the Cordova-Android plugin entitled Cordova generates build.gradle with deprecated “compile” dependencies.

How to fix

  1. Open package.json on your ionic application’s root project folder
  2. Update your cordova-android to 8.0.0.
  3. run npm install to resolve the dependencies.

That should contain the patch to fix that problem.