简体   繁体   中英

Error: Cause: compileSdkVersion is not specified

I have problem with project in github https://github.com/joaopedronardari/OpenCV-AndroidSamples I clone in my android studio, and error. I don't know that's project maybe expired or what. but it is uploaded 3 years ago. please help with my problem, and I appreciate to everyone that responds to my question (answer and fix my word) this is the gradle

Build gradle (app):

apply plugin: 'com.android.application'

model {

android {
    compileSdkVersion = 22
    buildToolsVersion = "23.0.0"

    defaultConfig.with {
        applicationId = "com.jnardari.opencv_androidsamples"
        minSdkVersion.apiLevel = 10
        targetSdkVersion.apiLevel = 22
        versionCode = 1
        versionName = "1.0"
    }
}

android.buildTypes {
    release {
        minifyEnabled = false
        proguardFiles += file('proguard-rules.pro')
    }
}

/*
 * native build settings
 */
android.ndk {
    moduleName = "ndklibrarysample"
    cppFlags += ["-std=c++11", "-fexceptions", "-frtti"]
    cppFlags  += "-I${file("C:/Users/jnardari/Desktop/OpenCV-android-sdk/sdk/native/jni/include")}".toString()
    ldLibs += ["android", "EGL", "GLESv2", "dl", "log", "z"]
    stl = "gnustl_static"
}

android.productFlavors {
    create("arm") {
        ndk.with {
            abiFilters += "armeabi"

            File curDir = file('./')
            curDir = file(curDir.absolutePath)
            String libsDir = curDir.absolutePath + "\\src\\main\\jniLibs\\armeabi\\"

            ldLibs += libsDir + "libopencv_java3.so"
        }
    }
    create("armv7") {
        ndk.with {
            abiFilters += "armeabi-v7a"

            File curDir = file('./')
            curDir = file(curDir.absolutePath)
            String libsDir = curDir.absolutePath + "\\src\\main\\jniLibs\\armeabi-v7a\\"

            ldLibs += libsDir + "libopencv_java3.so"
        }
    }
    create("x86") {
        ndk.with {
            abiFilters += "x86"

            File curDir = file('./')
            curDir = file(curDir.absolutePath)
            String libsDir = curDir.absolutePath + "\\src\\main\\jniLibs\\x86\\"

            ldLibs += libsDir + "libopencv_java3.so"
        }
    }
    create("mips") {
        ndk.with {
            abiFilters += "mips"

            File curDir = file('./')
            curDir = file(curDir.absolutePath)
            String libsDir = curDir.absolutePath + "\\src\\main\\jniLibs\\mips\\"

            ldLibs += libsDir + "libopencv_java3.so"
        }
    }
    create("fat") {

    }
}
}

dependencies {

    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile project(':libraries:opencv')
}

Build gradle (project):

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
    jcenter()
    mavenCentral()
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.3'
}

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}


allprojects {
repositories {
    jcenter()
}
}

And this is gradle-wrapper:

#Sun Jul 22 04:30:58 ICT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

Make following changes in code:

compileSdkVersion 27
minSdkVersion 19
targetSdkVersion 27
implementation 'com.android.support:appcompat-v7:27.1.1'

And One more thing your are trying to open project in Android Studio 3.0 where as it was developed in Android Studio 2.0. Instead of opening project. Try to import project. I am not sure about migration of android studio but it will definitely create a problem.I didn't any relevant article but try to find out some.

Hmmm... This project seems outdated, either ask the maintainer to update the project, or find a different project. I'm not an expert on gradle, but I know that you will waste your time trying to fix the gradle files.

EDIT: I tried @Mbuodile Obiosio 's solution, but it didn't work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM