接到一个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‘) {
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‘
} }
时间: 2024-10-05 16:46:20