Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin with id 'kotlin-android' not found - fixed #1407

Closed
Bardiamist opened this issue May 27, 2020 · 30 comments · Fixed by #1412
Closed

Plugin with id 'kotlin-android' not found - fixed #1407

Bardiamist opened this issue May 27, 2020 · 30 comments · Fixed by #1412

Comments

@Bardiamist
Copy link

Bardiamist commented May 27, 2020

FIXED in 10.1.1

Thanks all for the report, sorry again 😢

Original report follows:

Bug description:
Cant build project by Android Studio with next error:

A problem occurred evaluating project ':react-native-webview'.
> Plugin with id 'kotlin-android' not found.

To Reproduce:
I just updated react-native-webview from 9.4.0 to 10.1.0.

Expected behavior:
Build project successfully.

Environment:

  • OS: macOS
  • OS version: 10.15.4
  • react-native version: 0.62.2
  • react-native-webview version: 10.1.0
@EhteshamAnwar
Copy link

came here to add this issue.

@EhteshamAnwar
Copy link

To Reproduce:
I just installed react-native-webview ( using npm i react-native-webview)
then tried to build my project got this error

1: Task failed with an exception.

  • Where:
    Build file 'C:\Users\Dell\Documents\apps\audiomessage\node_modules\react-native-webview\android\build.gradle' line: 27

  • What went wrong:
    A problem occurred evaluating project ':react-native-webview'.

Plugin with id 'kotlin-android' not found.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    ==============================================================================

2: Task failed with an exception.

  • What went wrong:
    A problem occurred configuring project ':react-native-webview'.

compileSdkVersion is not specified.

@Bardiamist
Copy link
Author

Bardiamist commented May 27, 2020

I added in android/build.gradle

buildscript {
    ext {
        ...
        kotlinVersion = "1.3.72"
    }
    dependencies {
        ...
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    }
}

That helped but I waiting guide from maintainers.

EDIT FROM MAINTAINER: this won't be required in versions > 10.1.0, you might want to remove it if you don't wanna risk importing 2 different versions for no reason.
BTW this was a good workaround, thanks 😄

@FalconIA
Copy link

Same issue.

@egiesem
Copy link

egiesem commented May 27, 2020

Same issue

@arnriu
Copy link

arnriu commented May 27, 2020

Same issue, no luck with @Bardiamist comment.

@mars-lan
Copy link

Most likely broken by #1230

@Benzer1406
Copy link

Same issue

@mikehardy
Copy link
Contributor

Yes, effectively reverting #1230 by replacing node_modules/react-native-webview/android/build.gradle with the file before the change (https://raw.githubusercontent.com/react-native-community/react-native-webview/e6241cbb6aba6e98b2e0a82011ec0aabaca854b3/android/build.gradle) fixes things

You can use the ever-impressive / always-useful patch-package (https://github.com/ds300/patch-package) to persist the change after you've reverted locally in order to move forward

@Titozzz / @SaeedZhiany -> #1230 needs a revert 🙏

@Titozzz Titozzz self-assigned this May 28, 2020
@Titozzz
Copy link
Collaborator

Titozzz commented May 28, 2020

Thanks for the report, it's 2AM here, but I'll look into it first thing tomorrow, until then please use V9

@mikehardy
Copy link
Contributor

Here's a patch-package patch in case anyone wants to stick on v10.x - seems fine otherwise

I tried this exact transform myself (for this module) to conditional gradle inclusion after working on it with @SaeedZhiany in some of the related issues and in the modules I maintain - it's a standard thing that works 100% of the time...except for kotlin and I couldn't figure out why. Until someone does this will be the one module where it doesn't work I suppose but I'm not anti-kotlin - it's just an interoperability thing to figure out. Cheers

react-native-webview+10.1.0.patch.txt

@mikehardy mikehardy changed the title Plugin with id 'kotlin-android' not found Plugin with id 'kotlin-android' not found (has workaround) May 28, 2020
@SaeedZhiany
Copy link
Contributor

I guess the problem is your root projects do not use kotlin Gradle plugin and so the plugin does not loaded on building time and cause error. I can't test it my self right now but I have two solutions in my mind.

  1. Users can add the kotlin Gradle plugin to their root project Gradle file, so it guarantees the plugin always be downloaded once and available for build the modules need the plugin, just like the way we try fix AGP problems. (This is my recommended approach, if it works)

  2. We can apply the condition only on AGP within dependency section to make sure the kotlin gralde plugin always downloaded and loaded on building time.

However, reverting the PR changes completely is not best solution, we all know what is the side effects.
This is the first module that has problem with the change and it because it has additional dependency on buildscript section.

@Titozzz
Copy link
Collaborator

Titozzz commented May 28, 2020

@SaeedZhiany For now I'm gonna make sure we download kotlin for all users, so that's it's not breaking nor requiring changes on their codebases, but I agree we can prob find a better solution so that if you already have kotlin it does not import it. This will come later as this is pretty urgent

@Titozzz Titozzz changed the title Plugin with id 'kotlin-android' not found (has workaround) Plugin with id 'kotlin-android' not found - fixed May 28, 2020
@react-native-community-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 10.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@SaeedZhiany
Copy link
Contributor

@SaeedZhiany For now I'm gonna make sure we download kotlin for all users, so that's it's not breaking nor requiring changes on their codebases, but I agree we can prob find a better solution so that if you already have kotlin it does not import it. This will come later as this is pretty urgent

@Titozzz
The library has been upgraded to version 10.x.x (as a major version), so people should expect to break changes. can you please try the solution 1 from this comment (without the patch you already released)? if it's work, we can change the Readme.md and Changelog files to inform users to add the kotlin gradle plugin in their root project. (I have no access to my laptop right now to test it myself).

@Titozzz
Copy link
Collaborator

Titozzz commented May 28, 2020

@SaeedZhiany We don't want users to have any native step to perform when installing the library

@mikehardy
Copy link
Contributor

The correct solution is to push a patch upstream in react-native @SaeedZhiany that gets kotlin into people's root projects, then webview can do it, IMHO

@SaeedZhiany
Copy link
Contributor

@mikehardy

I agree with your suggestion, but there are a few RN modules using kotlin in their library, so maybe it's hard right now to convince RN maintainers to put that config in the RN template. (I couldn't convince them yet about putting androidx packages' version in root project if you remember about that)

@Titozzz
Copy link
Collaborator

Titozzz commented May 28, 2020

Do it impact users not using Kotlin if we add the dep?

@mikehardy
Copy link
Contributor

@SaeedZhiany hard nevertheless the correct step. Until then @Titozzz I think waiting to merge the currently-reverted PR is the correct action as it removes all user onboarding kotlin work from the module. This is just my opinion but it's tilted heavily towards preserving limited maintainer time from support requests and developer time from needing to do work for an upgrade or initial module integration, both things I'm passionate about.

Upstream went with Swift for 0.62, Maybe it's time for Kotlin in 0.64. If you raise a PR there and tag me I will voice my support and cross-reference this with brief explanation to substantiate

@mikehardy
Copy link
Contributor

@Titozzz yes - if people are not using kotlin directly in their project, and if this is their only kotlin-using module, then with the dep in this module's build.gradle it brings in kotlin where otherwise it wouldn't. But that's android development. Kotlin is a first class citizen, bringing it in is the same as when a cocoapod is using Swift or Flipper uses Swift (that's iOS development, it should be handled)

@Titozzz
Copy link
Collaborator

Titozzz commented May 28, 2020

@mikehardy thanks for the confirmation.

@rnmontufar
Copy link

I added in android/build.gradle

buildscript {
    ext {
        ...
        kotlinVersion = "1.3.72"
    }
    dependencies {
        ...
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    }
}

That helped but I waiting guide from maintainers.

EDIT FROM MAINTAINER: this won't be required in versions > 10.1.0, you might want to remove it if you don't wanna risk importing 2 different versions for no reason.
BTW this was a good workaround, thanks 😄

I used that:

buildscript {
ext {
...
kotlinVersion = "1.3.72"
}
dependencies {
...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}

and
react-native install react-native-webview@10.1.0

Thanks a lot @Bardiamist

@malvnewt
Copy link

I added in android/build.gradle

buildscript {
    ext {
        ...
        kotlinVersion = "1.3.72"
    }
    dependencies {
        ...
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    }
}

That helped but I waiting guide from maintainers.
EDIT FROM MAINTAINER: this won't be required in versions > 10.1.0, you might want to remove it if you don't wanna risk importing 2 different versions for no reason.
BTW this was a good workaround, thanks 😄

I used that:

buildscript {
ext {
...
kotlinVersion = "1.3.72"
}
dependencies {
...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}

and
react-native install react-native-webview@10.1.0

Thanks a lot @Bardiamist

I am currently learning flutter and the run command comes up with the exact same problem.flutter doctor suggests that all depencies are up to date and no issues.was wondering to go about solving this one.

@ItxAltaf
Copy link

ItxAltaf commented Nov 26, 2021

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"

  • What went wrong:
    A problem occurred evaluating project ':react-native-camera-kit'.

Could not get unknown property 'kotlin_version' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

facing this after above changes

@Vincetroid
Copy link

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"

  • What went wrong:
    A problem occurred evaluating project ':react-native-camera-kit'.

Could not get unknown property 'kotlin_version' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

facing this after above changes

Same here with react-native-camera-kit

@Vincetroid
Copy link

Vincetroid commented May 17, 2022

I had to follow these steps:

Change kotlinVersion to kotlin_version

Change minSdkVersion 21 to 23 because of the error:
Manifest merger failed : uses-sdk:minSdkVersion 21 cannot be smaller than version 23 declared in library [:react-native-camera-kit]

Also to:

 compileSdkVersion = 31
 targetSdkVersion = 31

Then:
teslamotors/react-native-camera-kit#434

@AqibCybery
Copy link

buildscript {
ext {
buildToolsVersion = "29.0.3"

  • // Note: Below change is necessary for pause / resume audio feature. Not for Kotlin.
    
  • minSdkVersion = 24
    compileSdkVersion = 29
    targetSdkVersion = 29
    
  • kotlinVersion = '1.5.0'
    
    ndkVersion = "20.1.5948944"
    
    }
    repositories {
    google()
    jcenter()
    }
    dependencies {
    classpath("com.android.tools.build:gradle:4.1.0")
  • classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    
    }

@Raymond205
Copy link

nawa o

@AlperenMertU
Copy link

same issues... I'm getting an error just react-native-vision-camera and react-native-camera-kit libraries. ı'm try tried adding this kotlin_Version = "1.3.72" but doesn't work. Help me pls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet