Android build error: Could not resolve project :CordovaLib


#1

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


#2

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


#3

+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.


#4

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.


#5

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


#6

I tried but the file is being rewritten too…

Did you find a solution ?


#7

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’.

#8

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


#9

Did you find any solution?


#10

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


#11

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


#12

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!