user17130948
user17130948

Reputation: 41

Error:Plugin with id 'kotlin-android' not found. on android studio

I get this error when I add this to Android Studio

"Error:Plugin with id 'kotlin-android' not found.".

I am trying to install opencv on my android, but it will not work. I made a new project in my Android that is empty but works

My build gradle

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

def openCVersionName = "4.5.4"
def openCVersionCode = ((4 * 100 + 5) * 100 + 4) * 10 + 0

println "OpenCV: " +openCVersionName + " " + project.buildscript.sourceFile

android {
compileSdkVersion 26

defaultConfig {
    minSdkVersion 21
    targetSdkVersion 26

    versionCode openCVersionCode
    versionName openCVersionName

    externalNativeBuild {
        cmake {
            arguments "-DANDROID_STL=c++_shared"
            targets "opencv_jni_shared"
        }
    }
}

buildTypes {
    debug {
        packagingOptions {
            doNotStrip '**/*.so'  // controlled by OpenCV CMake scripts
        }
    }
    release {
        packagingOptions {
            doNotStrip '**/*.so'  // controlled by OpenCV CMake scripts
        }
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}

sourceSets {
    main {
        jniLibs.srcDirs = ['native/libs']
        java.srcDirs = ['java/src']
        aidl.srcDirs = ['java/src']
        res.srcDirs = ['java/res']
        manifest.srcFile 'java/AndroidManifest.xml'
    }
}

externalNativeBuild {
    cmake {
        path (project.projectDir.toString() + '/libcxx_helper/CMakeLists.txt')
    }
}
}

dependencies {
}

Upvotes: 4

Views: 8367

Answers (1)

phoster.de
phoster.de

Reputation: 109

I ran into the same error with Android Studio 2020.3.1 and fixed the error by adding this on top of the skd's build gradle (above 'apply plugin...'):

buildscript {
    ext {
        kotlinVersion = "1.4.0"
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    }
    repositories {
        mavenCentral()
    }
}

Upvotes: 10

Related Questions