Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Unable to build using custom gradle

Discussion in 'Android' started by ysleungrockman, Nov 13, 2020.

  1. ysleungrockman

    ysleungrockman

    Joined:
    Mar 16, 2014
    Posts:
    31
    My project was edited using Unity 2017.1.1 and for the build system, we were using Internal (Default) and there was no problem. However, since we introduced a new plugin into the project, we were told that it was unable to build until we added multidex. So the build system was changed to Gradle (New) and a custom gradle was made. After several attempts of editing the gradle, it was still unable to build. I even exported and copied the build.gradle of the old project before changing and it still did not work. So here is the error:

    Code (JavaScript):
    1. CommandInvokationFailure: Gradle build failed.
    2. C:/Program Files/Java/jdk1.8.0_191\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2017.1.1f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-2.14.jar" org.gradle.launcher.GradleMain "assembleRelease"
    3.  
    4. stderr[
    5. C:\Users\3Circles\Documents\Unity\CirclAppSourceCode VRLCS\Temp\gradleOut\mediarouter\build\intermediates\bundles\release\res\values\values.xml:164: AAPT: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.Light.ActionButton'.
    6.    
    7. C:\Users\3Circles\Documents\Unity\CirclAppSourceCode VRLCS\Temp\gradleOut\mediarouter\build\intermediates\bundles\release\res\values\values.xml:168: AAPT: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.ActionButton'.
    8.    
    9.  
    10. FAILURE: Build failed with an exception.
    11.  
    12. * What went wrong:
    13. Execution failed for task ':mediarouter:processReleaseResources'.
    14. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\3Circles\AppData\Local\Android\Sdk\build-tools\30.0.2\aapt.exe'' finished with non-zero exit value 1
    15.  
    16. * Try:
    17. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    18. ]
    19. stdout[
    20. Incremental java compilation is an incubating feature.
    21. :preBuild UP-TO-DATE
    22. :preReleaseBuild UP-TO-DATE
    23. :checkReleaseManifest
    24. :preDebugBuild UP-TO-DATE
    25. :appcompat:preBuild UP-TO-DATE
    26. :appcompat:preReleaseBuild UP-TO-DATE
    27. :appcompat:compileReleaseNdk UP-TO-DATE
    28. :appcompat:compileLint
    29. :appcompat:copyReleaseLint UP-TO-DATE
    30. :appcompat:mergeReleaseProguardFiles
    31. :appcompat:packageReleaseRenderscript UP-TO-DATE
    32. :appcompat:checkReleaseManifest
    33. :appcompat:prepareReleaseDependencies
    34. :appcompat:compileReleaseRenderscript
    35. :appcompat:generateReleaseResValues
    36. :appcompat:generateReleaseResources
    37. :appcompat:packageReleaseResources
    38. :appcompat:compileReleaseAidl
    39. :appcompat:generateReleaseBuildConfig
    40. :appcompat:mergeReleaseShaders
    41. :appcompat:compileReleaseShaders
    42. :appcompat:generateReleaseAssets
    43. :appcompat:mergeReleaseAssets
    44. :appcompat:processReleaseManifest
    45. :appcompat:processReleaseResources
    46. :appcompat:generateReleaseSources
    47. :appcompat:incrementalReleaseJavaCompilationSafeguard
    48. :appcompat:compileReleaseJavaWithJavac
    49. :appcompat:processReleaseJavaRes UP-TO-DATE
    50. :appcompat:transformResourcesWithMergeJavaResForRelease
    51. :appcompat:transformClassesAndResourcesWithSyncLibJarsForRelease
    52. :appcompat:mergeReleaseJniLibFolders
    53. :appcompat:transformNative_libsWithMergeJniLibsForRelease
    54. :appcompat:transformNative_libsWithSyncJniLibsForRelease
    55. :appcompat:bundleRelease
    56. :google-play-services_lib:preBuild UP-TO-DATE
    57. :google-play-services_lib:preReleaseBuild UP-TO-DATE
    58. :google-play-services_lib:compileReleaseNdk UP-TO-DATE
    59. :google-play-services_lib:compileLint
    60. :google-play-services_lib:copyReleaseLint UP-TO-DATE
    61. :google-play-services_lib:mergeReleaseProguardFiles
    62. :google-play-services_lib:packageReleaseRenderscript UP-TO-DATE
    63. :google-play-services_lib:checkReleaseManifest
    64. :google-play-services_lib:prepareReleaseDependencies
    65. :google-play-services_lib:compileReleaseRenderscript
    66. :google-play-services_lib:generateReleaseResValues
    67. :google-play-services_lib:generateReleaseResources
    68. :google-play-services_lib:packageReleaseResources
    69. :google-play-services_lib:compileReleaseAidl
    70. :google-play-services_lib:generateReleaseBuildConfig
    71. :google-play-services_lib:mergeReleaseShaders
    72. :google-play-services_lib:compileReleaseShaders
    73. :google-play-services_lib:generateReleaseAssets
    74. :google-play-services_lib:mergeReleaseAssets
    75. :google-play-services_lib:processReleaseManifest
    76. :google-play-services_lib:processReleaseResources
    77. :google-play-services_lib:generateReleaseSources
    78. :google-play-services_lib:incrementalReleaseJavaCompilationSafeguard
    79. :google-play-services_lib:compileReleaseJavaWithJavac
    80. :google-play-services_lib:processReleaseJavaRes UP-TO-DATE
    81. :google-play-services_lib:transformResourcesWithMergeJavaResForRelease
    82. :google-play-services_lib:transformClassesAndResourcesWithSyncLibJarsForRelease
    83. :google-play-services_lib:mergeReleaseJniLibFolders
    84. :google-play-services_lib:transformNative_libsWithMergeJniLibsForRelease
    85. :google-play-services_lib:transformNative_libsWithSyncJniLibsForRelease
    86. :google-play-services_lib:bundleRelease
    87. :mediarouter:preBuild UP-TO-DATE
    88. :mediarouter:preReleaseBuild UP-TO-DATE
    89. :mediarouter:compileReleaseNdk UP-TO-DATE
    90. :mediarouter:compileLint
    91. :mediarouter:copyReleaseLint UP-TO-DATE
    92. :mediarouter:mergeReleaseProguardFiles
    93. :mediarouter:packageReleaseRenderscript UP-TO-DATE
    94. :mediarouter:checkReleaseManifest
    95. :mediarouter:prepareReleaseDependencies
    96. :mediarouter:compileReleaseRenderscript
    97. :mediarouter:generateReleaseResValues
    98. :mediarouter:generateReleaseResources
    99. :mediarouter:packageReleaseResources
    100. :mediarouter:compileReleaseAidl
    101. :mediarouter:generateReleaseBuildConfig
    102. :mediarouter:mergeReleaseShaders
    103. :mediarouter:compileReleaseShaders
    104. :mediarouter:generateReleaseAssets
    105. :mediarouter:mergeReleaseAssets
    106. :mediarouter:processReleaseManifest
    107. :mediarouter:processReleaseResources FAILED
    108.  
    109. BUILD FAILED
    110.  
    111. Total time: 13.4 secs
    112. ]
    113. exit code: 1
    114. UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    115. UnityEditor.Android.GradleWrapper.RunJava (System.String args, System.String workingdir, UnityEditor.Android.Progress progress)
    116. Rethrow as GradleInvokationException: Gradle build failed
    117. UnityEditor.Android.GradleWrapper.RunJava (System.String args, System.String workingdir, UnityEditor.Android.Progress progress)
    118. UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, UnityEditor.Android.Progress progress)
    119. UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    120. UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    121. UnityEditor.HostView:OnGUI()
    Here is the gradle:

    Code (JavaScript):
    1. buildscript {
    2.     repositories {
    3.         jcenter()
    4.     }
    5.  
    6.     dependencies {
    7.         classpath 'com.android.tools.build:gradle:2.1.0'
    8.     }
    9. }
    10.  
    11. allprojects {
    12.    repositories {
    13.       flatDir {
    14.         dirs 'libs'
    15.       }
    16.    }
    17. }
    18.  
    19. apply plugin: 'com.android.application'
    20.  
    21. dependencies {
    22.     compile fileTree(dir: 'libs', include: ['*.jar'])
    23.     compile(name: 'android-device-names-1.1.9', ext:'aar')
    24.     compile(name: 'GoogleCastRemoteDisplay', ext:'aar')
    25.     compile(name: 'gvr-keyboard', ext:'aar')
    26.     compile(name: 'gvr-keyboardsupport-release', ext:'aar')
    27.     compile(name: 'gvr-permissionsupport-release', ext:'aar')
    28.     compile(name: 'gvr', ext:'aar')
    29.     compile(name: 'unityandroidpermissions', ext:'aar')
    30.     compile(name: 'unitygvr', ext:'aar')
    31.     compile project(':appcompat')
    32.     compile project(':google-play-services_lib')
    33.     compile project(':mediarouter')
    34.     compile project(':unity-android-resources')
    35. }
    36.  
    37. android {
    38.     compileSdkVersion 30
    39.     buildToolsVersion '30.0.2'
    40.  
    41.     defaultConfig {
    42.         targetSdkVersion 30
    43.         applicationId 'com.ooovr.offlinebeta'
    44.     }
    45.  
    46.     lintOptions {
    47.         abortOnError false
    48.     }
    49.  
    50.     buildTypes {
    51.           debug {
    52.              minifyEnabled false
    53.              useProguard false
    54.              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
    55.               jniDebuggable true
    56.           }
    57.           release {
    58.              minifyEnabled true
    59.              useProguard true
    60.               proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
    61.           }
    62.     }
    63.  
    64. }
    65.  
    I think it may be due to either Appcompat or MediaRouter. They are currently inside the Plugins/Android folder and they both have their own folder with libs, res folders, etc. I tried to change the dependencies to compile files or fileTree but they still didn't work. What can I do about them?
     
  2. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    822
  3. ysleungrockman

    ysleungrockman

    Joined:
    Mar 16, 2014
    Posts:
    31
  4. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    822