react-native-camera-kit icon indicating copy to clipboard operation
react-native-camera-kit copied to clipboard

compileSdkVersion is not specified

Open fynally opened this issue 2 years ago • 2 comments

Describe the bug Task failed with an exception.

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

com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle

Additional context I created a brand new project and it was running fine in both emulator and real device but then I installed react-native-camera-kit and I started getting this error

fynally avatar Jul 15 '22 06:07 fynally

It's been a while since you asked and I hope you found the solution in the meantime. For everyone else, this might help:

  1. Open <your_react_native_root_folder>/android/build.gradle
  2. Find buildscript
  3. Find ext within "buildscript"
  4. Add compileSdkVersion = 33 near targetSdkVersion = 33
  5. Save your file and rebuild

Cordobo avatar Sep 06 '22 17:09 Cordobo

Just for other people who may run into the issue as I have: Even if you have the compileSdkVersion in your buildscript.ext config, you may still get this (in this case misleading) error if you have not properly set up Kotlin yet.

DysphoricUnicorn avatar Oct 10 '22 14:10 DysphoricUnicorn

@DysphoricUnicorn can you describe what you mean about not properly set up Kotlin?

gabrieljoelc avatar Oct 24 '22 17:10 gabrieljoelc

I figured it out. I finally noticed this in the build error:

> Plugin with id 'kotlin-android' not found.

add these lines to set up kotlin (i used this guide):

// android/build.gradle

buildscript {
    ext {
        // other stuff
        kotlin_version = "1.6.21" // add this

        // other stuff
    }
    // other stuff
    dependencies {
        // other stuff
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

and then:

// android/app/build.gradle
apply plugin: "com.android.application"
apply plugin: "kotlin-android" // add this to the top

gabrieljoelc avatar Oct 24 '22 17:10 gabrieljoelc

For react-native version 0.71.2 I also needed to change minSdkVersion:

// android/build.gradle
buildscript {
   ext {
        // ...
        // required to be at least 23 by react-native-camera-kit
        minSdkVersion = 23
    }
}

latobibor avatar Apr 14 '23 20:04 latobibor

Both compileSdkVersion (31) and minSdkVersion (23) are defined already. Closing for now unless someone can reproduce on a more recent v14 beta build.

scarlac avatar Aug 14 '23 23:08 scarlac