How to configure gradle when use jni and kotlin in project


#1

I want to wirte c/c++ code in android project,so use com.android.tools.build:gradle-experimental instead of com.android.tools.build:gradle, When configure kotlin in project then get an error message。
Error:(2, 0) Extension with name ‘android’ does not exist. Currently registered extension names: [ext, defaultArtifacts, reporting, buildTypes, flavors, toolChains]
Open File


#2

The gradle-experimental plugin is not supported at this time. You’re welcome to file a feature request for its support.


#3

Try to use com.android.tools.build:gradle:2.2.0

I have used it for external build with cmake

defaultConfig {

externalNativeBuild {
cmake {
abiFilters ‘x86’, ‘x86_64’, ‘armeabi’, ‘armeabi-v7a’, ‘arm64-v8a’
}
}

}

externalNativeBuild {
    cmake {
        path "src/main/cpp/CMakeLists.txt"
    }
}

#4

By the way, how are you loading native library? I’ve found only one working approach - to create
class NativeSample {
init {
System.loadLibrary(“native-lib-my”)
}
external fun stringLogcat(logThis: String)
}
But this forces me to set a strange name of the jni function:
Java_(package)_(activity)_00024NativeSample_stringLogcat(...)
the strange part is additional 00024 digits…