react-native-webview: Plugin with id 'kotlin-android' not found - fixed

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

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 24
  • Comments: 30 (8 by maintainers)

Most upvoted comments

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 😄

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.

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

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

nawa o

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"
    
    }

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: https://github.com/teslamotors/react-native-camera-kit/issues/434

@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)

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 🙏