I'm on Windows 10 and I've created a Ionic 5.0.7 app with Capacitor 2.0.0.
I use this command to build app:
ionic build
After, I use this command:
npx cap sync
And, to finish, I use this command to open Android Studio:
npx cap open android
The first problem come during building on Android Studio:
org.gradle.api.reflect.ObjectInstantiationException: Could not create an instance of type com.novoda.release.internal.compat.gradle5_3.AndroidSoftwareComponentCompat_Gradle_5_3.
Caused by: org.gradle.api.reflect.ObjectInstantiationException: Could not create an instance of type com.novoda.release.internal.compat.gradle5_3.AndroidSoftwareComponentCompat_Gradle_5_3.
And...
java.lang.NoClassDefFoundError: org/gradle/api/internal/java/usagecontext/LazyConfigurationUsageContext
Caused by: java.lang.NoClassDefFoundError: org/gradle/api/internal/java/usagecontext/LazyConfigurationUsageContext
I've other random errors... It's weird...
Check @Carl Pool 's answer They fixed it in the new capacitor Version, no need to downgrade anymore
To fix this downgrade Gradle and Gradle plugin in Android Studio.
File -> Project Structure -> Project
If you keep the plugin to 4.0.0 it will require a minimum Gradle version of 6 so put it back to a lower version like 3.6.3
Version 6 of Gradle does not support LazyConfigurationUsageContext as mentionened by @NishaBhat, so use 5.6.4 instead.
This issue currently has a ticket on Github: https://github.com/ionic-team/capacitor/issues/3003
This issue has been resolved in Capacitor version 2.1.2
.
https://github.com/ionic-team/capacitor/issues/3003
Please update the Capacitor dependencies in package.json to version 2.1.2
and then in Android Studio click the button to sync the project with Gradle.
"@capacitor/android": "^2.1.2",
"@capacitor/core": "2.1.2",
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With