问题
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:
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
- 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.
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.
回答1:
I had exactly the same problem, and the solution was putting 'dependencies' outside the model {}.
回答2:
I don't know if this will solve your problem but it may have created complications that led up to it.
Try: proguardFiles.add(file("proguard-rules.txt")) ndk.abiFilters.add("armeabi")
Instead of the += operators. Support around the list aggregation methods has been chunky and I've found the .add() method is the one best supported.
回答3:
Try killing the daemon and rerunning the build
gradle --stop && gradle clean build
来源:https://stackoverflow.com/questions/34953368/android-ndk-integration-errorunable-to-load-class-buildtypeimpl