I am trying to import 'https://code.google.com/p/android-serialport-api/'into Android Studio. Since this project involves ndk, I followed the instructions to build NDK from the following link: http://tools.android.com/tech-docs/new-build-system/gradle-experimental
But after building, I get this error:
Gradle Project refresh Failed
Error:Cause: org.gradle.api.internal.ExtensibleDynamicObject
EDIT: I have 2.5 gradle version installed Here's my build.gradle
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig.with {
applicationId = "android_serialport_api.sample"
minSdkVersion.apiLevel = 17
targetSdkVersion.apiLevel = 22
android.ndk {
moduleName = "serial_port"
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
}
android.productFlavors {
create("all")
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
}
Can you try change
compileSdkVersion 22
buildToolsVersion "22.0.1"
to
compileSdkVersion = 22
buildToolsVersion = "22.0.1"
and
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
to
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
I've got the same error and this works for me.
Unfortunately the NDK preview implementation to support native code development in Android Studio is a moving target. Even if you use an older, developers.android.com stated, "supported" combination of the experimental Android Gradle plugin (from tools.android.com) and Gradle version (from gradle.org), good luck in getting the build to work. Instead, always use the latest released combination with the latest indicated module build.gradle language syntax, according to developers.android.com.
In your case, your mixing the use of assignment operators, "=" and "+=". Depending on the supported combo of gradle plugin and gradle version you're using, it's either use the assignment operators everywhere in module build.gradle file or nowhere - you have to be consistent, all or nothing. For "+=" use the method ".add(...)" instead.
And remember, the gradle scripting language is compiled to the Java runtime so when you see a build error that looks like a Java error, it's the gradle scripting that is likely the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With