Unity Android构建失败

时间:2019-04-09 02:18:30

标签: android unity3d android-gradle

我正在尝试为Android构建统一的VR应用程序。但是我每次都收到错误,我已经更改了gradle版本和源代码路径,但无济于事。错误似乎是由于无法从我的应用程序中利用https://github.com/google/ExoPlayer编译本机视频播放器而导致的,该播放器已预先包装在Oculus SDK中。

CommandInvokationFailure: Gradle build failed. 
C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\OpenJDK\Windows\>>bin\java.exe -classpath "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradl>>e-launcher-4.6.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleDebug"

stderr[
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\aiden\Documents\GitHub\Lidos\Temp\gradleOut\build.gradle' line: 30

* What went wrong:
A problem occurred evaluating root project 'gradleOut'.
> Could not find method implementation() for arguments [{name=audio360-exo28, ext=aar}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

>>BUILD FAILED in 6s
>>]
>>stdout[
>>NDK is missing a "platforms" directory.
>>If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  >>It is currently set to C:\Users\aiden\AppData\Local\Android\sdk\ndk-bundle.
>>If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or >>local.properties to remove this warning.
>>
>>]

存在构建问题的那一行来自使用实现的第一行

apply plugin: 'com.android.application'

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.exoplayer:exoplayer:2.8.4'
    implementation(name: 'audio360-exo28', ext:'aar')
    implementation(name: 'audio360', ext:'aar')
    implementation(name: 'gvr', ext:'aar')
    implementation(name: 'OVRPlugin', ext:'aar')
    implementation(name: 'unitygvr', ext:'aar')
}

依赖关系似乎都在gradleOut中,所以我不知道为什么它无法实现audio360-exo28

3 个答案:

答案 0 :(得分:1)

Aiden,

1. Modify your build.gradle dependency as

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.exoplayer:exoplayer:2.8.4'
    //implementation(name: 'audio360-exo28', ext:'aar')
    implementation project(":audio360-exo28")
}

2. Download Audio-360 and add it as new library module.
   https://s3.amazonaws.com/fb360-spatial-workstation/RenderingEngine/1.6.0/Audio360_SDK_1.6.0-3f1ecee14.zip

In your Android Studio project window, go to File ‣ New ‣ New Module..

Select Import .JAR/.AAR Package from the grid of options and select Next

Load the relevant Audio360 ExoPlayer library (audio360-exo28.aar) from Audio360/Android-Java/ into the File name: field and select Finish.

答案 1 :(得分:0)

我通过创建一个新的Unity项目并复制我的资产和脚本以及场景来解决了该问题。程序包和附加组件似乎无法正常工作,但是当我再次从头开始该项目时可以正常工作。

答案 2 :(得分:0)

如果您仍然遇到相同的问题:

  1. 写在main Template grandle file上,而不是其他一些。
  2. 包括2.11.1版的exoplayer,而不是2.8.x