How to deal with "Failed to apply plugin 'org.jetbrains.intellij'. Gradle IntelliJ Plugin requires Gradle X.X and higher" error - java

My plugin is based on official Jet Brains template, however Java one, not Kotlin.
When I opened my project, I got the error
An exception occurred applying plugin request [id:
'org.jetbrains.intellij', version: '1.12.0']
Failed to apply plugin 'org.jetbrains.intellij'.
Gradle IntelliJ Plugin requires Gradle 7.3 and higher
The dependencies in build.gradle.kts are
plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.7.10"
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
id("org.jetbrains.intellij") version "1.12.0"
// gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
id("org.jetbrains.changelog") version "1.3.0"
// detekt linter - read more: https://detekt.github.io/detekt/gradle.html
id("io.gitlab.arturbosch.detekt") version "1.17.1"
// ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle
id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
}
Would you please no teach me how to deal with this error? I understand that I need to update the Grade, however how to do it with IntelliJ IDEA for current project?
My Project configuration is:

An exception occurred applying plugin request [id: 'org.jetbrains.intellij', version: '1.12.0'] Failed to apply plugin 'org.jetbrains.intellij'. Gradle IntelliJ Plugin requires Gradle 7.3 and higher
Please open the gradle/wrapper/gradle-wrapper.properties, and check what version is there.
You could change the old Gradle version to any version new than 7.3 in that file's distributionUrl part to fix this problem and click the Gradle reload button to reload this project.
Or run something like gradle wrapper --gradle-version 8.0 from the command line to update the Gradle version.

Related

Execution failed for task ':#react-native-community_async-storage:compileDebugJavaWithJavac' [duplicate]

Note: Error may be different but if you are getting any error when taking android build without any changes in code for past two days
My Error - Failed to install the app. Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
error Failed to install the app. Make sure you have the Android development environment set up:
Error: Command failed: ./gradlew app:installDebug
-PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* Where: Build file '/Users/....../node_modules/react-native-month-year-picker/android/build.gradle' line: 115
* What went wrong: A problem occurred configuring project ':react-native-month-year-picker'.
> Could not resolve all files for configuration ':react-native-month-year-picker:implementation'.
> Could not resolve com.facebook.react:react-native:+.
Required by:
project :react-native-month-year-picker
> Cannot choose between the following variants of com.facebook.react:react-native:0.71.0-rc.0:
- debugVariantDefaultRuntimePublication
- releaseVariantDefaultRuntimePublication
All of them match the consumer attributes:
- Variant 'debugVariantDefaultRuntimePublication' capability com.facebook.react:react-native:0.71.0-rc.0:
The build failures for Android was due to the publish of the React Native version 0.71.0-rc0.
Note: Error may be different but this would be the solution if you are getting android build failures without any changes in code for past two days
before trying these methods please revert back every changes you have done : https://stackoverflow.com/a/74371195/10657559
Method 1
Add this fix to your android -> build.gradle file as follows:
buildscript {
// ...
}
allprojects {
repositories {
exclusiveContent {
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
// ...
}
}
What this fix will do is apply an exclusiveContent resolution rule that will force the resolution of React Native Android library, to use the one inside node_modules
Method 2
If your gradle doesn't support above, then add this to your android -> build.gradle file as follows:
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
buildscript {
// ...
}
allprojects {
configurations.all {
resolutionStrategy {
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
// ...
}
Ref: Fix and updates on Android build failures happening since Nov 4th 2022 #35210
Adding on to the voted answer to do some knowledge sharing.
To reiterate, as #Thanhal has posted, the solution and official explanation can be found here: Android build failures No matching variant of com.facebook.react:react-native:0.71.0-rc.0 was found.
The biggest question I needed answer following the error was:
After specifying my react-native version in package.json, why does my project still download another react-native version?
I even used npm install --save-exact to ensure I am getting the correct version
The error message I was given left me even more confused:
The class is loaded from ~/.gradle/caches/transforms-3/9a8c596b7e1788d5bad7c80991eefff1/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
e: .../node_modules/expo-modules-core/android/src/main/java/expo/modules/adapters/react/permissions/PermissionsService.kt: (351, 32): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.1.
Somehow Kotlin became an issue for me as well.
Who / What is asking for the latest react-native?
For my case, the issue here wasn't about the version of react-native my project is using. It was about what my libraries are using.
The react-native team had been shipping a Maven Repository inside the NPM package (node_modules/react-native/android/) up till 0.71.0-rc.0. Most of the libraries have their build.gradle configured to reference to this directory. This is done through declaring a custom repository in the libraries' build.gradle:
maven {
url "$rootDir/../node_modules/react-native/android"
}
But in the libraries' build.gradle files, more repositories are declared, which may look like this:
repositories {
maven {
url "$rootDir/../node_modules/react-native/android"
}
google()
mavenLocal()
mavenCentral()
}
Then, the dependency for the library is declared as so:
dependencies {
implementation 'com.facebook.react:react-native:+'
}
Because the "+" as version for the react-native dependency, Gradle will take the latest react-native version from the various declared repositories.
Since in the past react-native was shipped with npm package, the latest which Gradle will always take the react-native in node_modules. However, now that the react-native team is publishing the library to public repositories including MavenCentral, Gradle honours the "+" and take the version on MavenCentral instead.
Why did I get the Kotlin error?
My project uses an older version of react-native and as of version 0.68 react-native started using Kotlin version 1.6.10 (see the change history). So yes, the difference in react-native version would also result in Kotlin error.
Facebook has release bugfix versions for >=0.63. You can upgrade instead of apply the hotfix also.
https://github.com/facebook/react-native/issues/35210
This fix works:
Reason for Failures : The build failures for Android was due to the publish of the React Native version 0.71.0-rc0 to Maven and because of which when the gradle is syncing its picking this 0.71.0-rc0 version of react-native rather then your current version of react-native.
Made it work without upgrading react-native version and by adding this in build.gradle, this works (hermes enabled or not, along with flipper too)
exclusiveContent {
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
final snippet looks like this
allprojects {
repositories {
exclusiveContent {
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
gradle clean and rebuild after this fix. Then you can react native run android successfully.
What this fix will do is apply an exclusiveContent resolution rule that will force the resolution of React Native Android library, to use the one inside node_modules
Now,
There are some patch releases from react native for different versions, If you dont want to put this fix,
you can update your current react native version to the react native patch version as mentioned here
https://github.com/facebook/react-native/issues/35210

Error : Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin in react-native [duplicate]

Note: Error may be different but if you are getting any error when taking android build without any changes in code for past two days
My Error - Failed to install the app. Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
error Failed to install the app. Make sure you have the Android development environment set up:
Error: Command failed: ./gradlew app:installDebug
-PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* Where: Build file '/Users/....../node_modules/react-native-month-year-picker/android/build.gradle' line: 115
* What went wrong: A problem occurred configuring project ':react-native-month-year-picker'.
> Could not resolve all files for configuration ':react-native-month-year-picker:implementation'.
> Could not resolve com.facebook.react:react-native:+.
Required by:
project :react-native-month-year-picker
> Cannot choose between the following variants of com.facebook.react:react-native:0.71.0-rc.0:
- debugVariantDefaultRuntimePublication
- releaseVariantDefaultRuntimePublication
All of them match the consumer attributes:
- Variant 'debugVariantDefaultRuntimePublication' capability com.facebook.react:react-native:0.71.0-rc.0:
The build failures for Android was due to the publish of the React Native version 0.71.0-rc0.
Note: Error may be different but this would be the solution if you are getting android build failures without any changes in code for past two days
before trying these methods please revert back every changes you have done : https://stackoverflow.com/a/74371195/10657559
Method 1
Add this fix to your android -> build.gradle file as follows:
buildscript {
// ...
}
allprojects {
repositories {
exclusiveContent {
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
// ...
}
}
What this fix will do is apply an exclusiveContent resolution rule that will force the resolution of React Native Android library, to use the one inside node_modules
Method 2
If your gradle doesn't support above, then add this to your android -> build.gradle file as follows:
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
buildscript {
// ...
}
allprojects {
configurations.all {
resolutionStrategy {
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
// ...
}
Ref: Fix and updates on Android build failures happening since Nov 4th 2022 #35210
Adding on to the voted answer to do some knowledge sharing.
To reiterate, as #Thanhal has posted, the solution and official explanation can be found here: Android build failures No matching variant of com.facebook.react:react-native:0.71.0-rc.0 was found.
The biggest question I needed answer following the error was:
After specifying my react-native version in package.json, why does my project still download another react-native version?
I even used npm install --save-exact to ensure I am getting the correct version
The error message I was given left me even more confused:
The class is loaded from ~/.gradle/caches/transforms-3/9a8c596b7e1788d5bad7c80991eefff1/transformed/jetified-kotlin-stdlib-1.6.10.jar!/kotlin/Unit.class
e: .../node_modules/expo-modules-core/android/src/main/java/expo/modules/adapters/react/permissions/PermissionsService.kt: (351, 32): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.1.
Somehow Kotlin became an issue for me as well.
Who / What is asking for the latest react-native?
For my case, the issue here wasn't about the version of react-native my project is using. It was about what my libraries are using.
The react-native team had been shipping a Maven Repository inside the NPM package (node_modules/react-native/android/) up till 0.71.0-rc.0. Most of the libraries have their build.gradle configured to reference to this directory. This is done through declaring a custom repository in the libraries' build.gradle:
maven {
url "$rootDir/../node_modules/react-native/android"
}
But in the libraries' build.gradle files, more repositories are declared, which may look like this:
repositories {
maven {
url "$rootDir/../node_modules/react-native/android"
}
google()
mavenLocal()
mavenCentral()
}
Then, the dependency for the library is declared as so:
dependencies {
implementation 'com.facebook.react:react-native:+'
}
Because the "+" as version for the react-native dependency, Gradle will take the latest react-native version from the various declared repositories.
Since in the past react-native was shipped with npm package, the latest which Gradle will always take the react-native in node_modules. However, now that the react-native team is publishing the library to public repositories including MavenCentral, Gradle honours the "+" and take the version on MavenCentral instead.
Why did I get the Kotlin error?
My project uses an older version of react-native and as of version 0.68 react-native started using Kotlin version 1.6.10 (see the change history). So yes, the difference in react-native version would also result in Kotlin error.
Facebook has release bugfix versions for >=0.63. You can upgrade instead of apply the hotfix also.
https://github.com/facebook/react-native/issues/35210
This fix works:
Reason for Failures : The build failures for Android was due to the publish of the React Native version 0.71.0-rc0 to Maven and because of which when the gradle is syncing its picking this 0.71.0-rc0 version of react-native rather then your current version of react-native.
Made it work without upgrading react-native version and by adding this in build.gradle, this works (hermes enabled or not, along with flipper too)
exclusiveContent {
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
final snippet looks like this
allprojects {
repositories {
exclusiveContent {
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
gradle clean and rebuild after this fix. Then you can react native run android successfully.
What this fix will do is apply an exclusiveContent resolution rule that will force the resolution of React Native Android library, to use the one inside node_modules
Now,
There are some patch releases from react native for different versions, If you dont want to put this fix,
you can update your current react native version to the react native patch version as mentioned here
https://github.com/facebook/react-native/issues/35210

I can't apply the gradle 6.x plugin

It says I'm supposed to write:
plugins {
id "com.gradle.enterprise" version "3.5"
}
gradleEnterprise {
server = "https://gradle-enterprise.mycompany.com"
}
On the settings.gradle file according to:
https://docs.gradle.com/enterprise/gradle-plugin/
But then I get an error saying:
2: Only Project build scripts can contain plugins {} blocks
So I seem to have this working.
Please ensure plugins and and gradleEnterprise blocks are the first and second lines in the file respectively or you will get an error:
settings.gradle:
plugins {
id 'com.gradle.enterprise' version '3.5'
}
gradleEnterprise {
// configuration
}
include ':app'
rootProject.name = "My Application"
My Current Gradle plugin versions are as follows (File→Project Structure):
And it all builds fine.
PS: I was getting an error: This version of the Android Support plugin for IntelliJ IDEA (or Android Studio) cannot open this project, please retry with version 4.1 or newer. I had to update my android studios to the latest as well (4.1.1) and all worked a charm.

Gradle - Class not loaded : org.docx4j.jaxb.Context

I had a maven project with old docx4j dependencies, and I wanted to update to java 9. During the update I changed my project from maven to gradle.
So now I have a gradle project in IntelliJ with this dependencies:
dependencies {
implementation('commons-io:commons-io:2.6')
implementation('javax.xml.bind:jaxb-api:2.4.0-b180725.047')
implementation('org.docx4j:docx4j:6.0.1')
implementation('org.docx4j:docx4j-ImportXHTML:6.0.1')
implementation('org.docx4j:docx4j-export-fo:6.0.1')
testImplementation('junit:junit:4.12')
}
The build is working, but if I want to open a .docx file, with Docx4J.load(...) or WordprocessingMLPackage.load(...) it throws a RuntimeException.
In debug mode I can see this message: Class not loaded : org.docx4j.jaxb.Context
This Context.java file has a static code block like this:
static {
...
}
I think it's gradle specific error, because I created a new maven project with the same code and dependencies as the gradle project, and it works.
Is there any solution for this, or should I use maven in the future too?
There is a Gradle-specific answer at https://stackoverflow.com/a/51235096/1031689
Or to "add module" instead, see for example:
https://www.concretepage.com/questions/531
https://github.com/IntershopCommunicationsAG/jaxb-gradle-plugin/issues/11
Or mac java 9 gradle ClassNotFoundException: javax.xml.bind.JAXBElement when building

Twitter bootstrap version 3.0.0 not working in grails

I am currently using twitter bootstrap 2.3.0 in my grails project. I want to switch to the newly released version 3.0. I have added this line to the dependencies in buildconfig file.
compile ":twitter-bootstrap:3.0.0"
But when I synchronize the project then the following error occurs.
I have also tried installing from command line but failed. the error log is as following.
: problems summary ::
:::: ERRORS
grailsCentral: bad organisation found in http://grails.org/plugins/grails-twitter-bootstrap/tags/RELEASE_3_0_0/twitter-bootstrap-3.0.0.pom: expected='' found='org.grails.plugins'
what should I do now ? Thanks in advance.
I've solved the issue by adding "org.grails.plugins" as the groupId for the dependency and the plugin:
Dependency:
compile "org.grails.plugins:twitter-bootstrap:3.0.3"
Plugin:
runtime "org.grails.plugins:twitter-bootstrap:3.0.3"
Hope it will help
Dependencies are funny sometime. Often I have to delete my ~/.grails folder (or at least the project folder from within there)

Categories

Resources