Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to run Ionic app after update to Android Studio 3.0

Here's my Ionic Info

cli packages: (/Users/billb/dev/customer-mkt-app/node_modules)

@ionic/cli-utils  : 1.15.2 ionic (Ionic CLI) : 3.15.2 

global packages:

cordova (Cordova CLI) : 7.0.1 

local packages:

@ionic/app-scripts : 3.0.1 Cordova Platforms  : android 6.2.3 ios 4.4.0 Ionic Framework    : ionic-angular 3.3.0 

System:

Android SDK Tools : 26.1.1 ios-deploy        : 1.9.2 Node              : v6.11.5 npm               : 3.10.10 OS                : macOS Sierra Xcode             : Xcode 9.0.1 Build version 9A1004 

Environment Variables:

ANDROID_HOME : /Users/billb/Library/Android/sdk 

Misc:

backend : pro 

I can successfully build the app. When I try to open it in Android Studio, I get a handful of errors, mostly around a gradle sync failure. Here's the 5 errors in the Messages console.

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.


Unable to resolve dependency for ':@debugAndroidTest/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.


Unable to resolve dependency for ':@debugUnitTest/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.


Unable to resolve dependency for ':@release/compileClasspath': Could not resolve project :CordovaLib.

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

Project : declares a dependency from configuration 'releaseCompile' to configuration 'release' which is not declared in the descriptor for project :CordovaLib.


Unable to resolve dependency for ':@releaseUnitTest/compileClasspath': Could not resolve project :CordovaLib.

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

Project : declares a dependency from configuration 'releaseCompile' to configuration 'release' which is not declared in the descriptor for project :CordovaLib.

I really don't know what this means and Google hasn't turned up anything of any real help. What do I need to do here?

Note: discovered this after posting this. Relaying it here in case it will help someone else.

Don't upgrade to Android Studio 3

like image 905
Bill Avatar asked Oct 30 '17 19:10

Bill


People also ask

How do I run an ionic app on Android?

To run your app, all you have to do is enable USB debugging and Developer Mode on your Android device, then run ionic cordova run android --device from the command line. Enabling USB debugging and Developer Mode can vary between devices, but is easy to look up with a Google search.

Which is better ionic or Android studio?

When assessing the two solutions, reviewers found Ionic easier to use, set up, and administer. Reviewers also preferred doing business with Ionic overall. Reviewers felt that Android Studio meets the needs of their business better than Ionic.


2 Answers

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.

like image 170
Manmohan Pal Avatar answered Oct 12 '22 11:10

Manmohan Pal


If you are using Cordova build.gradle is automatically generated and when you next build the project the change in accepted answer above get overwritten back to the old that doesn't work.

So edit platforms/android/cordova/lib/builder/GradleBuiler.js Comment out lines 136-139 and add the next line

/*depsList += '    debugCompile(project(path: "' + libName + '", configuration: "debug"))'; insertExclude(p); depsList += '    releaseCompile(project(path: "' + libName + '", configuration: "release"))'; insertExclude(p);     */     depsList += "    compile project(':CordovaLib')";     insertExclude(p); 
like image 26
andymoyle Avatar answered Oct 12 '22 10:10

andymoyle