I am trying to use react-native-selectable-text in my react native project. but when I build the project on android emulator it fails and this message appears
FAILURE: Build failed with an exception.
* What went wrong: Could not determine the dependencies of task ':react-native-selectable-text:bundleLibCompileToJarDebug'. > Could not create task ':react-native-selectable-text:compileDebugJavaWithJavac'. > In order to compile Java 9+ source, please set compileSdkVersion to 30 or above
Can any body tell me how can I solve this problem please?
I did the steps of adding package according to the instructions in documantation but as I using kotlin instead of java When adding RNSelectableTextPackage()
to the list returned by getPackages
function in MainActivity.kt
I couldn't find the getPackages
function so I added this lines to the 'MainActivity' class
override fun getPackages(): List<ReactPackage> = PackageList(this).packages.apply { new RNSelectableTextPackage() }
I tried this by both "add" and "new", but none of them worked.
I found the solution at this answer
by adding the code below to buildscripts section in build.gradle file:
subprojects { subproject ->
afterEvaluate{
if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
}
}
}
}