android开发里跳过的坑-AS导入NDK工程提示错误 No such property: sdkHandler for class: com.android.build.gradle.Librar
冲天香阵透长安,满城尽带黄金甲。这篇文章主要讲述android开发里跳过的坑-AS导入NDK工程提示错误 No such property: sdkHandler for class: com.android.build.gradle.Librar相关的知识,希望能为你提供帮助。
接到一个NDK工程需要调试,导入后发现总是提示错误
Error:(37, 1) A problem occurred evaluating project ‘:libuvccamera‘.
>
No such property: sdkHandler for class: com.android.build.gradle.LibraryPlugin
百度上各种说法,有说要降低gadle版本,有说要在环境变量里配置ANDROID_NDK的路径,试验了都不行,最后参考别人NDK gradle文件修改如下:
未修改之前:
task ndkBuild(type: Exec, description: ‘Compile JNI source via NDK‘) {
【android开发里跳过的坑-AS导入NDK工程提示错误 No such property: sdkHandler for class: com.android.build.gradle.Librar】
println(‘executing ndkBuild‘)
def ndkBuildingDir = project.plugins.findPlugin(‘com.android.library‘).sdkHandler.getNdkFolder().absolutePath
def ndkBuildPath = ndkBuildingDir
if (Os.isFamily(Os.FAMILY_WINDOWS)){
ndkBuildPath = ndkBuildingDir + ‘/ndk-build.cmd‘
} else {
ndkBuildPath = ndkBuildingDir + ‘/ndk-build‘
}
commandLine ndkBuildPath, ‘-j8‘, ‘-C‘, file(‘src/main‘).absolutePath
}
可修改为
task ndkBuild(type: Exec, description: ‘Compile JNI source via NDK‘) {
println(‘executing ndkBuild‘)
def ndkBuildingDir = android.ndkDirectory
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
ndkBuildingDir = "$ndkBuildingDir/ndk-build.cmd"
} else {
ndkBuildingDir = "$ndkBuildingDir/ndk-build"
}
commandLine ndkBuildingDir, ‘-j8‘, ‘-C‘, file(‘src/main‘).absolutePath
}
或者修改为
task ndkBuild(type: Exec, description: ‘Compile JNI source via NDK‘) {
println(‘executing ndkBuild‘)
//def ndkBuildingDir = project.plugins.findPlugin(‘com.android.library‘).sdkHandler.getNdkFolder().absolutePath
//def ndkBuildPath = ndkBuildingDir
def ndkBuildPath = android.ndkDirectory
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine "$ndkBuildPath/ndk-build.cmd",
‘-C‘, file(‘src/main‘).absolutePath, // Change src/main/jni the relative path to your jni source
‘-j‘, Runtime.runtime.availableProcessors(),
‘all‘,
‘NDK_DEBUG=1‘
} else {
commandLine "$ndkBuildPath/ndk-build",
‘-C‘, file(‘src/main‘).absolutePath, // Change src/main/jni the relative path to your jni source
‘-j‘, Runtime.runtime.availableProcessors(),
‘all‘,
‘NDK_DEBUG=1‘
}
}
推荐阅读
- Android Studio下载地址
- Android的View和ViewGroup分析
- OpenCV On Android环境配置最新&最全指南(Android Studio篇)
- EMCPure和NetApp推新品,NAS闪存场景在哪里
- Java EntityMapper
- Apple Cached Service 导致 iPhone app store无法下载程序
- UVA - 10591Happy Number
- ADT(Android Developer Tools)中配置SVN
- 如何优雅的设计APP页面()