我尝试构建时出现 Oculus Mobile SDK 示例项目错误:compileReleaseNdk:
Oculus Mobile SDK sample project error when I try to build :compileReleaseNdk:
我在尝试构建oculus mobile sdk的示例项目时遇到了以下错误。
错误:失败:构建失败,出现异常。
其中:
构建文件 '~/oculus_sdk/ovr_sdk_mobile_1.0.0.1/VrSamples/Native/CinemaSDK/Projects/Android/build.gradle' 行:28
出了什么问题:
配置项目“:VrSamples:Native:CinemaSDK:Projects:Android”时出现问题。
Could not get unknown property 'compileReleaseNdk' for project ':VrSamples:Native:CinemaSDK:Projects:Android' of type org.gradle.api.Project.
尝试:
运行 使用 --stacktrace 选项获取堆栈跟踪。 运行 使用 --info 或 --debug 选项以获得更多日志输出。
有人可以解决这个问题吗?
我的开发环境如下。
- Android 工作室 2.2
- Android NDK : android-ndk-r12b
- Oculus 移动 SDK:1.0.0.1
- OSX 10.11.6
而gradle调试信息中提到的文件内容是这样的...
apply plugin: 'com.android.application'
dependencies {
compile name: 'VrAppFramework', ext: 'aar'
compile project(':VrAppSupport:SystemUtils:Projects:AndroidPrebuilt')
compile project(':VrAppSupport:VrGUI:Projects:AndroidPrebuilt')
compile project(':VrAppSupport:VrLocale:Projects:AndroidPrebuilt')
compile project(':VrAppSupport:VrSound:Projects:AndroidPrebuilt')
}
android {
compileSdkVersion 19
buildToolsVersion '24.0.1'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
jniLibs.srcDir 'libs'
res.srcDirs = ['res']
assets.srcDirs = ['../../assets']
}
}
}
project.afterEvaluate {
compileDebugNdk.dependsOn 'NDKBuildDebug'
compileReleaseNdk.dependsOn 'NDKBuildRelease'
clean.dependsOn 'NDKBuildClean'
}
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def alignedOutputFile = output.outputFile
def unalignedOutputFile = output.packageApplication.outputFile
def buildTypeName = variant.buildType.name
def finalFileName = rootProject.name + "-" + buildTypeName + ".apk"
def unAlignedFileName = rootProject.name + "-" + buildTypeName + "-unsigned" + ".apk"
output.packageApplication.outputFile =
new File(unalignedOutputFile.parent, unAlignedFileName)
if (output.zipAlign) {
output.outputFile =
new File(alignedOutputFile.parent, finalFileName)
}
}
}
我已经在类似问题上找到了很好的答案:
execution failed for task ':app:compileDebugNdk' failed to run this command ndk-build.cmd
Error:Execution failed for task ':app:compileDebugNdk'.
means that the gradle android plugin is trying to call ndk-build
itself to compile your sources. You should get more details than the
error code in your log window.
Anyway, currently it does this using an auto-generated Makefile and
ignores yours, which can't work since you need to integrate ffmpeg.
To overcome this, you should disable the plugin's automatic ndk
integration and make it use the standard libs location to get your
.so files:
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] //disable automatic ndk-build call
}
from there you can call ndk-build yourself, or make gradle call it
for you:
import org.apache.tools.ant.taskdefs.condition.Os
// call regular ndk-build(.cmd) script from app directory
task ndkBuild(type: Exec) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'ndk-build.cmd', '-C', file('src/main').absolutePath
} else {
commandLine 'ndk-build', '-C', file('src/main').absolutePath
}
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
For more information on why all this, you can check this gist and
my blog post.
您需要做的就是 通过在 build.gradle 文件中添加以下 属性 来禁用 ndk-build。
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] //disable automatic ndk-build call
}
或删除第二行:jni.srcDirs = [...]
希望对您有所帮助
我在尝试构建oculus mobile sdk的示例项目时遇到了以下错误。
错误:失败:构建失败,出现异常。
其中: 构建文件 '~/oculus_sdk/ovr_sdk_mobile_1.0.0.1/VrSamples/Native/CinemaSDK/Projects/Android/build.gradle' 行:28
出了什么问题: 配置项目“:VrSamples:Native:CinemaSDK:Projects:Android”时出现问题。
Could not get unknown property 'compileReleaseNdk' for project ':VrSamples:Native:CinemaSDK:Projects:Android' of type org.gradle.api.Project.
尝试: 运行 使用 --stacktrace 选项获取堆栈跟踪。 运行 使用 --info 或 --debug 选项以获得更多日志输出。
有人可以解决这个问题吗?
我的开发环境如下。
- Android 工作室 2.2
- Android NDK : android-ndk-r12b
- Oculus 移动 SDK:1.0.0.1
- OSX 10.11.6
而gradle调试信息中提到的文件内容是这样的...
apply plugin: 'com.android.application'
dependencies {
compile name: 'VrAppFramework', ext: 'aar'
compile project(':VrAppSupport:SystemUtils:Projects:AndroidPrebuilt')
compile project(':VrAppSupport:VrGUI:Projects:AndroidPrebuilt')
compile project(':VrAppSupport:VrLocale:Projects:AndroidPrebuilt')
compile project(':VrAppSupport:VrSound:Projects:AndroidPrebuilt')
}
android {
compileSdkVersion 19
buildToolsVersion '24.0.1'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
jniLibs.srcDir 'libs'
res.srcDirs = ['res']
assets.srcDirs = ['../../assets']
}
}
}
project.afterEvaluate {
compileDebugNdk.dependsOn 'NDKBuildDebug'
compileReleaseNdk.dependsOn 'NDKBuildRelease'
clean.dependsOn 'NDKBuildClean'
}
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def alignedOutputFile = output.outputFile
def unalignedOutputFile = output.packageApplication.outputFile
def buildTypeName = variant.buildType.name
def finalFileName = rootProject.name + "-" + buildTypeName + ".apk"
def unAlignedFileName = rootProject.name + "-" + buildTypeName + "-unsigned" + ".apk"
output.packageApplication.outputFile =
new File(unalignedOutputFile.parent, unAlignedFileName)
if (output.zipAlign) {
output.outputFile =
new File(alignedOutputFile.parent, finalFileName)
}
}
}
我已经在类似问题上找到了很好的答案: execution failed for task ':app:compileDebugNdk' failed to run this command ndk-build.cmd
Error:Execution failed for task ':app:compileDebugNdk'.
means that the gradle android plugin is trying to call ndk-build itself to compile your sources. You should get more details than the error code in your log window.
Anyway, currently it does this using an auto-generated Makefile and ignores yours, which can't work since you need to integrate ffmpeg.
To overcome this, you should disable the plugin's automatic ndk integration and make it use the standard libs location to get your .so files:
sourceSets.main { jniLibs.srcDir 'src/main/libs' jni.srcDirs = [] //disable automatic ndk-build call }
from there you can call ndk-build yourself, or make gradle call it for you:
import org.apache.tools.ant.taskdefs.condition.Os // call regular ndk-build(.cmd) script from app directory task ndkBuild(type: Exec) { if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine 'ndk-build.cmd', '-C', file('src/main').absolutePath } else { commandLine 'ndk-build', '-C', file('src/main').absolutePath } } tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn ndkBuild }
For more information on why all this, you can check this gist and my blog post.
您需要做的就是 通过在 build.gradle 文件中添加以下 属性 来禁用 ndk-build。
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] //disable automatic ndk-build call
}
或删除第二行:jni.srcDirs = [...]
希望对您有所帮助