I have a problem when I write:
ionic cordova prepare androidŲ
Knowing that this is happening with every new project I create.
Please help.
The problem is caused by required builders that are missing from the angular.json file. To install those builders, run:
ng add #ionic/cordova-builders
You should get an output similar to this:
After that, go ahead and run your build.
Ionic CLI v6.19.0 has been released with this fix:
npm install -g #ionic/cli#latest
bug report on GitHub:
https://github.com/ionic-team/ionic-framework/issues/24940#issuecomment-1068016921
When building my Android app with Android-Studio in debug, it works, but when building in release mode, I get the following error at the :app:bundleReleaseClasses step:
Zip file app/build/intermediates/app_classes/release/classes.jar' already contains entry 'META-INF/MANIFEST.MF', cannot overwrite
Building in CLI with ./gradlew assembleDebug (or even ./gradlew bundleReleaseClasses) works.
What could be the reason for this error in Android-Studio, knowing that it works in gradle CLI? I tried excluding this file in packagingOptions {}, but it does not seem to have any effect.
I tried this, this, this, this and a few other related questions, but did not find an answer.
Note that it fails with AGP 7.0.0, 7.0.1, 7.0.2, 7.0.3 and 7.0.4. Not sure if I should try going further back.
Just Update your Gradle plugin version version
I had the same error in Android Studio Chipmunk| 2021.2.1 and Gradle version 7.1.2
and after updating Gradle plugin version to 7.2.0 this problem is resolved.
I am trying to build the android apk. I am facing the below error.
Tried with flutter clean, updated pub get, and I am using flutter 2.2.3
The build failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetifier to solve the incompatibility.
Building plugin cloud_firestore...
Running Gradle task 'assembleAarRelease'...
Do these steps : 1. Try adding this line In your Project folder > android > app > build.gradle, add the following Line in
multiDexEnabled true
inside defaultConfig
2.Then upgrade gradle dependency in the android/build.gradle file: classpath 'com.android.tools.build:gradle:3.3.1' (previously on version 3.2.1)
3.Run flutter clean and rebuild your project
Based on your other feedback, the basic troubleshooting is
(1) flutter doctor and
(2) to try to build the apk for the sample app. See https://docs.flutter.dev/get-started/test-drive?tab=terminal
If the build works with the sample app, then you know your environment is good but something is up with your app.
(3) if you think your gradle might be corrupted, you might copy your lib/ and pubspec.yaml to a blank project to start.
You mentioned a cloud_firestore issue. There are several things that need to be setup to get cluod_firestore working, including the google-services.json that are easy to mess up.
You might also have version incompatabilities with firebase. There are some breaking changes in the last couple of years.
I always try to run the sample/example code first to see if my tooling is correct. So, try that with flutter fire: https://firebase.flutter.dev/docs/overview
I updated android studio from 3.3 to 3.4 version and after install and do ./gradlew lint I am getting the next error:
Deprecated Gradle features were used in this build, making it
incompatible with Gradle 6.0.
Then I use the next command to get more details:
./gradlwe build --warning-mode=all
And I get the next message:
Failed to apply plugin [id 'com.android.application']
Minimum supported Gradle version is 5.1.1. Current version is 4.4.1. If using the gradle wrapper, try editing the distributionUrl in .gradle/daemon/4.4.1/gradle/wrapper/gradle-wrapper.properties
to gradle-5.1.1-all.zip
And when I edited my gradle-wrapper.properties, I see that the changes were already done, I.E. the version of the distributionUrl already was gradle-5.1.1.-all.zip
Any idea that how can resolve this?
You could just edit YOUR_APPLICATION_FOLDER/gradle/wrapper/gradle-wrapper.properties and change the last line to:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
Android Studio will download necessary library.
This was my solution.
My_project
/gradle
/wrapper
/gradle-wrapper.properties
Modify this line with the Gradle 5.1.1
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
Finally, I was able to solve this dropping the folders of the oldest version in ~/.gradle/wrapper/dists and leave only the gradle-5.1.1-all
In my case, gradle failed to download the version I specified though I tried all previous solutions.
Apparently, I was opening my project by selecting "MyProject/App" directory. Gradle successfully updated when I opened the same project by selecting the "MyProject" folder.
Check your full project and find all "Gradle-wrapper.properties" files. If your project has multiple modules then there are chances of having multiple. and set -
distributionUrl=https://services.gradle.org/distributions/gradle-5.1.1-all.zip
Gradle sync
If not done then invalidate the cache and restart the project.
Still not working then go to your root directory on Linux and find .gradle folder. Delete it and restart the android studio.
If you use Ubuntu and all above answers didn't solve your problem try to upgrade gradle on your Ubuntu with this commands from this answer https://askubuntu.com/a/975018/714791
sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update
sudo apt upgrade gradle
It will help I hope
I resolved by two below steps.
delete gradle folder
check your classpath 'com.android.tools.build:gradle:{$gradleVersion}
My gradleVersion is 3.5.3.
I solved this by changing the distributionUrl in gradle-wrapper.properties in gradle/wrapper, not gradle.properties
Maybe it's your gradle environment variable.
execute 'gradle -v'
Check that the gradle version of the project matches the gradle environment variable version
those who are still facing issue with Cordova/Ionic, this is due to CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL which is being checked at platforms/android/cordova/lib/builders/GradleBuilder.js
set CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL to desired distributional
for MacOs
export CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL = https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
I think it's very important to mention which IDE you're using and what are the configurations.
What made me upset was, I had a setting in gradle-wrapper.properties file which was "ignored" to my mind.
I've found the settings in the IDEA application settings, there:
and then selecting:
and everything works as expected.
Deleting 'all other' locally cached versions can never be the right solution ;)
Good luck!
My app is using Cordova v9.0.0
distributionUrl is set at platforms\android\cordova\lib\builders\ProjectBuilder.js
You can set distributionUrl from the command line with
set CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL="https://services.gradle.org/distributions/gradle-[version]-all.zip"
Replace [version] with your preference
it solved for me
get the flutter SDK directory
this is my flutter Sdk
C:\flutter\.pub-cache\hosted\pub.dartlang.org\connectivity_macos-0.1.0+2\android\gradle\wrapper
change gradle-wrapper.properties
Modify this line with the Gradle 5.1.1
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
I had the same error: Error "Minimum supported Gradle version is 6.1.1. Current version is 5.1.1" but when I opened the gradle.properties and I found this "distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip" which was correct but wasn't working. To solve this, I deleted the ".gradle" file in the explorer, reopened the app and found out the distributionUrl had change to 5.2.2-all.zip in gradle.properties; I then edited to 6.1.1-all.zip and sync and everything worked like a charm. I hope this can help someone else.
Try to download manually Gradle-5.1.1 from https://gradle.org/releases then go to file/project structure/project and put the new version in gradle version. (You can also use this link - jenv.io/candidate/gradle)
I was having the same problem after migrating from android.support library to androidx where junit library start with androidTestImplementation and not
testImplementation.
So i changed
testImplementation "junit:junit:$rootProject.junitVersion"
to
androidTestImplementation androidx.test.ext:junit:1.0.0-beta01
or
androidTestImplementation "junit:junit:$rootProject.junitVersion"
Remember to append android before testImplementation
also, try removing all older/unwanted versions of gradle using:
cd usr/local/Cellar/gradle/
Don't forget to run the gradle wrapper in your project: https://docs.gradle.org/6.4.1/userguide/gradle_wrapper.html#sec:adding_wrapper
Delete gradle folder from your project directory as well as from the app directory.
restart Adroid studio and resync gradle.
it will solve your problem. If not you might be opened the project yourproject/app. close Android studio and import your project after selecting yourproject. Then resync gradle. This will solve your problem.
For Windows 10:
Go to C:\Users\<user-name>\.gradle\wrapper\dists and delete everything there. Android studio will download the appropriate version afterwards.
If anyone is still searching for a solution after trying literally everything, here's what worked for me.
In the .gitlab-ci.yml file, my image: key was outdated and was writing in the script that Gradle was set to 5.1.1 even though everything in my Android Studio was 7.0.2. After talking to the guy who wrote the image script, I just had to increment the version of that.
https://forum.gitlab.com/t/set-specific-version-of-gradle-for-ci-build/41716/4
This error was solved by restarting Android Studio.
I am unable to build a gradle project, even if I edit the gradle property, I get the following error:
Error:(22, 1) A problem occurred evaluating root project 'android'.
> Failed to apply plugin [id 'android']
> Gradle version 2.10 is required. Current version is 2.2.1. If using the gradle wrapper, try editing the distributionUrl in C:\Users\salangar\angular-cordova-tickrv0.1\platforms\android\gradle\wrapper\gradle-wrapper.properties to gradle-2.10-all.zip
How do I resolve this?
I was also getting the same error and modifying the
$(your app path)/platform/android/gradle/wrapper/gradle-wrapper.properties to
distributionUrl=http\://services.gradle.org/distributions/gradle-2.10-all.zip
didn't help as it was getting overridden every time i ran cordova build android to 2.2.1
I finally changed the gradleBuilder.js file under $(your app path)/platforms/android/cordova/lib/builders folder.
Search for distributionUrl and change it 2.10.
This triggered download of gradle-2.10 and compilation went through. At least it worked for me.
Instead of manipulating build.js file, the easiet approach would be as follows:
1) Download required gradle version and save it local folder.
2) In command prompt execute the following command:
export CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL=file:///local/path/to/folder/where/gradle/zip/is/saved/gradle-2.2.1-all.zip
3) Execute the following command: cordova run android
I discovered the issue here. Android Studio asks to upgrade gradle. Don't do that ! I've made a bug report. The version has to keep being updated in Android Studio after each rebuild on the command line.
File -> Project Structure -> Project. Need to keep changing it to 2.10. There is not one fix for this yet that I've seen.
it will always generate same file every times you run build, so the way to handle it find the generator .. in my case App Location> platform > android> cordova >lib> builders> Gradlebuilder.js and find this ..
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\: '
after edit it, every time code generate will create new distribution url you make.
Edit $(your app path)/platform/android/gradle/wrapper/gradle-wrapper.properties:
find:
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
Change to:
distributionUrl=http\://services.gradle.org/distributions/gradle-2.10-all.zip
I use sencha touch 2.4.2 and cordova 5.4.1.
I had the same error because the Sencha-Cmd:
sencha app build native always rewrite the file: $(your app path)/cordova/platform/android/gradle/wrapper/gradle-wrapper.properties
And reset the variable distributionUrl to the old bad value: distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
To solve that, i have changed the variable distributionUrl, directly in the file: $(your app path)/cordova/platforms/android/cordova/lib/build.js
at line 346 change build.js:
// New good value
var distributionUrl = 'distributionUrl=http\\://services.gradle.org/distributions/gradle-2.10-all.zip';
// Old bad value
// var distributionUrl = 'distributionUrl=http\\://services.gradle.org/distributions/gradle-2.2.1-all.zip';
And that permanently solve the problem and i can now have a successful native build for Android ;)