Android NDK集成:错误:无法加载类BuildType $ Impl

Mal*_*ngh 5 android android-ndk android-build android-gradle-plugin

我正在尝试将NDK集成到我的项目中.我正在使用Gradle包装器2.9和类路径:gradle-experimental:0.6.0-alpha3.

项目级别:

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
}
Run Code Online (Sandbox Code Playgroud)

应用级别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'
    }
}
Run Code Online (Sandbox Code Playgroud)

在构建应用程序时,我收到此错误:

错误:无法加载类'com.android.build.gradle.managed.BuildType $ Impl'.此意外错误的可能原因包括:

  • Gradle的依赖缓存可能已损坏(这有时会在网络连接超时后发生.)重新下载依赖项并同步项目(需要网络)
  • Gradle构建过程(守护程序)的状态可能已损坏.停止所有Gradle守护进程可以解决此问题.停止Gradle构建过程(需要重启)
  • 您的项目可能正在使用第三方插件,该插件与项目中的其他插件或项目请求的Gradle版本不兼容.
在损坏的Gradle进程的情况下,您还可以尝试关闭IDE,然后终止所有Java进程.

修改proguard和产品风味的描述后,我收到此错误:

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.
Run Code Online (Sandbox Code Playgroud)

小智 8

我有完全相同的问题,解决方案是将'依赖关系'放在模型{}之外.