Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android NDK Integration: Error:Unable to load class BuildType$Impl

I am trying to integrate NDK into my project. I am using Gradle wrapper 2.9 and classpath:gradle-experimental:0.6.0-alpha3.

Project level gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle-experimental:0.6.0-alpha6'
      }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

App level gradle:

apply plugin: 'com.android.model.application'

model {
    android {
        compileSdkVersion = 23
        buildToolsVersion = "23.0.2"

        defaultConfig.with {
            applicationId = "com.ms.knowursensor.android"
            minSdkVersion.apiLevel = 11
            targetSdkVersion.apiLevel = 23
        }
    }

    compileOptions.with {
        sourceCompatibility=JavaVersion.VERSION_1_7
        targetCompatibility=JavaVersion.VERSION_1_7
    }

    android.ndk {
        moduleName = "sensorgraph"
    }
    android.buildTypes {
        release {
            minifyEnabled = false
            proguardFiles  += file('proguard-rules.txt')
        }
    }
    android.productFlavors {
        create("arm") {
            ndk.abiFilters += "armeabi"
        }
        create("arm7") {
            ndk.abiFilters += "armeabi-v7a"
        }
        create("arm8") {
            ndk.abiFilters += "arm64-v8a"
        }
        create("x86") {
            ndk.abiFilters += "x86"
        }
        create("x86-64") {
            ndk.abiFilters += "x86_64"
        }
        create("mips") {
            ndk.abiFilters += "mips"
        }
        create("mips-64") {
            ndk.abiFilters += "mips64"
        }
        create("all")
    }

     dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:23.1.1'
        compile 'com.android.support:support-v4:23.1.1'
        compile 'com.android.support:design:23.1.1'
        compile 'com.android.support:cardview-v7:23.1.1'
        compile 'com.android.support:recyclerview-v7:23.1.1'
    }
}

On building app, i receive this error:

Error:Unable to load class 'com.android.build.gradle.managed.BuildType$Impl'. Possible causes for this unexpected error include:

  • Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)
  • The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)
  • Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

After modifying description of proguard and product flavor i am receiving this error:

Error:A problem occurred configuring project ':app'.
> The following model rules could not be applied due to unbound inputs and/or subjects:
    compileOptions.with { ... } @ app\build.gradle line 15, column 5
      subject:
        - compileOptions.with Object [*]
    dependencies { ... } @ app\build.gradle line 68, column 6
      subject:
        - dependencies Object [*]
  [*] - indicates that a model item could not be found for the path or type.
like image 760
Malwinder Singh Avatar asked Jan 22 '16 18:01

Malwinder Singh


1 Answers

I had exactly the same problem, and the solution was putting 'dependencies' outside the model {}.

like image 157
takao Avatar answered Oct 03 '22 03:10

takao