Update Gradle to 7.0.2 As at January 2022 This is the version and settings that work
We now recommend using Gradle 7.0.2 with Capacitor projects.
In Android Studio, open the File menu, then click Project Structure. In the Project section, change Gradle Version to 7.0.2 and Android Gradle Plugin Version to 4.2.0. Then, click OK.
Inside the file android/build.gradle
repositories {
maven { url “https://maven.google.com” }
google()
mavenCentral()
}
dependencies {
classpath ‘com.android.tools.build:gradle:7.0.3’
classpath ‘com.google.gms:google-services:4.3.5’
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
***************** and in the section
allprojects {
repositories {
maven { url “https://maven.google.com” }
google()
mavenCentral()
}
}
You may want to evaluate suggested updates to Android packages in the Suggestions section of the Project Structure dialog.
In android/variables.gradle
you can update the following variables:
ext {
minSdkVersion = 22
compileSdkVersion = 30
targetSdkVersion = 30
androidxActivityVersion = ‘1.2.0’
androidxAppCompatVersion = ‘1.3.1’
androidxCoordinatorLayoutVersion = ‘1.1.0’
androidxCoreVersion = ‘1.3.2’
androidxFragmentVersion = ‘1.3.0’
junitVersion = ‘4.13.2’
androidxJunitVersion = ‘1.1.3’
androidxEspressoCoreVersion = ‘3.4.0’
cordovaAndroidVersion = ‘10.1.1’
}
Also update the gradle.wrapper.properties file to
/services.gradle.org/distributions/gradle-7.0.2-bin.zip
Also inside the file of android/capacitor-cordova-android-plugins/build.gradle
Update the file with this:
buildscript {
repositories {
maven { url “https://maven.google.com” }
google()
mavenCentral()
}
dependencies {
classpath ‘com.android.tools.build:gradle:7.0.3’
}
}
Also inside the file app/build.gradle add
multiDexEnabled true into
defaultConfig { ***
versionName “1.0”
testInstrumentationRunner “androidx.test.runner.AndroidJUnitRunner”
multiDexEnabled true