0
votes

I have an ionic mobile app, i have been building it for IOS and android fine. But i had to remove android studio from my pc, and then i re-installed it. And now, I'm not able to build android! I got this error:

What went wrong: A problem occurred evaluating root project 'android'.

Failed to apply plugin [id 'com.android.application'] Minimum supported Gradle version is 4.1. Current version is 3.3. If using the gradle wrapper, try editing the distributionUrl in /Users/lamatatwany/Downloads/wesalApp/gradle/wrapper/gradle-wrapper.properties to gradle-4.1-all.zip

I tried to change the gradle version to the latest and got another error...

Can someone please help me with this.

Cordova requirements output:

Requirements check results for android: Java JDK: installed 1.8.0 Android SDK: installed true Android target: installed android-27,android-26,android-24,android-23 Gradle: installed /Applications/Android Studio.app/Contents/gradle/gradle-4.4/bin/gradle

Requirements check results for ios: Apple OS X: installed darwin Xcode: installed 9.2 ios-deploy: not installed ios-deploy was not found. Please download, build and install version 1.9.0 or greater from https://github.com/phonegap/ios-deploy into your path, or do 'npm install -g ios-deploy' CocoaPods: installed (node:39026) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CordovaError: Some of requirements check failed (node:39026) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

When i update this line in GradleBuilder.js:

var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\://services.gradle.org/distributions/gradle-3.3-all.zip';

to gradle-4.4-all.zip, igot the following error:

BUILD FAILED in 1m 13s (node:39180) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: /Users/lamatatwany/downloads/wesalapp/platforms/android/gradlew: Command failed with exit code 1 Error output: FAILURE: Build failed with an exception.

  • What went wrong: Could not determine the dependencies of task ':compileDebugJavaWithJavac'.

    Could not resolve all task dependencies for configuration ':debugCompileClasspath'. 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.

Addin android version 7:

Installing "cordova-plugin-file-transfer" for android Plugin dependency "[email protected]" already fetched, using that version. Dependent plugin "cordova-plugin-file" already installed on android. Installing "cordova-plugin-filepath" for android Installing "cordova-plugin-image-picker" for android Installing "cordova-plugin-iroot" for android Failed to install 'cordova-plugin-iroot': Error: ENOENT: no such file or directory, open '/Users/lamatatwany/Downloads/wesalapp/platforms/android/AndroidManifest.xml' at Object.fs.openSync (fs.js:646:18) at Object.fs.readFileSync (fs.js:551:33) at Object.parseElementtreeSync (/Users/lamatatwany/Downloads/wesalapp/platforms/android/cordova/node_modules/cordova-common/src/util/xml-helpers.js:180:27) at new AndroidManifest (/Users/lamatatwany/Downloads/wesalapp/platforms/android/cordova/lib/AndroidManifest.js:29:20) at AndroidProject.getPackageName (/Users/lamatatwany/Downloads/wesalapp/platforms/android/cordova/lib/AndroidProject.js:99:12) at Api.addPlugin (/Users/lamatatwany/Downloads/wesalapp/platforms/android/cordova/Api.js:223:57) at handleInstall (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:594:10) at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:357:28 at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/q/q.js:787:54) at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/q/q.js:816:30)

2
can you show the output for cordova requirements in your project folder? - Suraj Rao
"and got another error..." which is..... ? - ToYonos
@SurajRao just posted it - Lama
hmm.. says gradle version is 4.4 .. how is it picking 3.3? and what is the other error you get? - Suraj Rao
@ToYonos just posted it - Lama

2 Answers

0
votes

You cordova-android version is quite old. The current version is 7.0.0. This has undergone a number of changes to handle changes in android project structure as well as gradle.

Try:

ionic cordova platform update android

Else remove the platform and then add:

ionic cordova platform add android@latest

or

ionic cordova platform add [email protected]
0
votes

When I first built my ionic project in VSC with ionic Cordova build android, everything worked. But after generating a signed app bundle with Android Studio, I tried to modify my project, make a new build but got that error :

Failed to apply plugin [id 'com.android.application'] Minimum supported Gradle version is xxx. Current version is xxx. If using the Gradle wrapper, try editing the distributionUrl in /Users/lamatatwany/Downloads/wesalApp/gradle/wrapper /gradle->wrapper.properties to Gradle-xx.x-all.zip

No answers found to fix it, so I had to rebuild my project from start (with a lot of copy/paste form old project ofc). Now before generating an app bundle with Android Studio, I have to make a backup that I will reuse for futures modifications.