Search Unity

Gradle build Failed

Discussion in 'Android' started by Neozman, Jul 17, 2018.

  1. Neozman

    Neozman

    Joined:
    Sep 29, 2016
    Posts:
    67
    Ver.
    Unity 2017.4.3f1

    Problem describtion
    Needs for multiple plugins integrating lead us to use gradle build (because of 64k limit). But unfortunatly we faced with impossibility to make this build via gradle. Google researches gave us a clue to ad to mainTemplate.gradle lines such as:

    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
    }

    But it didnt help us. What should we do?


    Error code
    Code (CSharp):
    1. CommandInvokationFailure: Gradle build failed.
    2. C:/Program Files/Java/jdk1.8.0_172\bin\java.exe -classpath "C:\Program Files\Unity2017_4\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.0.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx2048m" "assembleDebug"
    3.  
    4. stderr[
    5. Dex: Error converting bytecode to dex:
    6. Cause: Dex cannot parse version 52 byte code.
    7. This is caused by library dependencies that have been compiled using Java 8 or above.
    8. If you are using the 'java' gradle plugin in a library submodule add
    9. targetCompatibility = '1.7'
    10. sourceCompatibility = '1.7'
    11. to that submodule's build.gradle file.
    12.    UNEXPECTED TOP-LEVEL EXCEPTION:
    13. java.lang.RuntimeException: Exception parsing classes
    14.    at com.android.dx.command.dexer.Main.processClass(Main.java:781)
    15.    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:747)
    16.    at com.android.dx.command.dexer.Main.access$1200(Main.java:88)
    17.    at com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1689)
    18.    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
    19.    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
    20.    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
    21.    at com.android.dx.command.dexer.Main.processOne(Main.java:695)
    22.    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:592)
    23.    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:321)
    24.    at com.android.dx.command.dexer.Main.run(Main.java:292)
    25.    at com.android.builder.internal.compiler.DexWrapper.run(DexWrapper.java:54)
    26.    at com.android.builder.core.DexByteCodeConverter.lambda$dexInProcess$0(DexByteCodeConverter.java:174)
    27.    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    28.    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    29.    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    30.    at java.lang.Thread.run(Thread.java:748)
    31. Caused by: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
    32.    at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:476)
    33.    at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
    34.    at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
    35.    at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
    36.    at com.android.dx.command.dexer.Main.parseClass(Main.java:793)
    37.    at com.android.dx.command.dexer.Main.access$1600(Main.java:88)
    38.    at com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1728)
    39.    at com.android.dx.command.dexer.Main.processClass(Main.java:779)
    40.    ... 16 more
    41.  
    42. 1 error; aborting
    43.  
    44. FAILURE: Build failed with an exception.
    45.  
    46. * What went wrong:
    47. Execution failed for task ':transformClassesWithDexForDebug'.
    48. > com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process
    49.  
    50. * Try:
    51. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    52.  
    53. BUILD FAILED in 4s
    54. ]
    55. stdout[
    56. The setTestClassesDir(File) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the setTestClassesDirs(FileCollection) method instead.
    57. The getTestClassesDir() method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the getTestClassesDirs() method instead.
    58. The ConfigurableReport.setDestination(Object) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the method ConfigurableReport.setDestination(File) instead.
    59. :preBuild UP-TO-DATE
    60. :preDebugBuild UP-TO-DATE
    61. :checkDebugManifest
    62. :preReleaseBuild UP-TO-DATE
    63. :prepareAndroidArchLifecycleRuntime100Library
    64. :prepareComAndroidSupportSupportCompat2610Library
    65. :prepareComAndroidSupportSupportCoreUi2610Library
    66. :prepareComAndroidSupportSupportCoreUtils2610Library
    67. :prepareComAndroidSupportSupportFragment2610Library
    68. :prepareComAndroidSupportSupportMediaCompat2610Library
    69. :prepareComAndroidSupportSupportV42610Library
    70. :prepareComGoogleAndroidGmsPlayServicesAdsIdentifier1501Library
    71. :prepareComGoogleAndroidGmsPlayServicesAnalytics1601Library
    72. :prepareComGoogleAndroidGmsPlayServicesAnalyticsImpl1601Library
    73. :prepareComGoogleAndroidGmsPlayServicesAuth1501Library
    74. :prepareComGoogleAndroidGmsPlayServicesAuthApiPhone1501Library
    75. :prepareComGoogleAndroidGmsPlayServicesAuthBase1501Library
    76. :prepareComGoogleAndroidGmsPlayServicesBase1501Library
    77. :prepareComGoogleAndroidGmsPlayServicesBasement1501Library
    78. :prepareComGoogleAndroidGmsPlayServicesDrive1501Library
    79. :prepareComGoogleAndroidGmsPlayServicesGames1501Library
    80. :prepareComGoogleAndroidGmsPlayServicesMeasurementBase1600Library
    81. :prepareComGoogleAndroidGmsPlayServicesNearby1501Library
    82. :prepareComGoogleAndroidGmsPlayServicesStats1501Library
    83. :prepareComGoogleAndroidGmsPlayServicesTagmanagerV4Impl1601Library
    84. :prepareComGoogleAndroidGmsPlayServicesTasks1501Library
    85. :prepareComGoogleFirebaseFirebaseAnalytics1601Library
    86. :prepareComGoogleFirebaseFirebaseAnalyticsImpl1611Library
    87. :prepareComGoogleFirebaseFirebaseAppUnity511Library
    88. :prepareComGoogleFirebaseFirebaseCommon1600Library
    89. :prepareComGoogleFirebaseFirebaseCore1601Library
    90. :prepareComGoogleFirebaseFirebaseIid1620Library
    91. :prepareComGoogleFirebaseFirebaseIidInterop1600Library
    92. :prepareComGoogleFirebaseFirebaseMeasurementConnector1600Library
    93. :prepareComGoogleFirebaseFirebaseMeasurementConnectorImpl1601Library
    94. :prepareComGoogleFirebaseFirebaseMessaging1710Library
    95. :prepareComGoogleFirebaseFirebaseMessagingUnity511Library
    96. :prepareComGoogleGamesGpgsPluginSupport0950Library
    97. :prepareCommonLibrary
    98. :prepareGoogleAIDLLibrary
    99. :prepareGooglePlayLibrary
    100. :prepareUnityAdsLibrary
    101. :Firebase:preBuild UP-TO-DATE
    102. :Firebase:preReleaseBuild UP-TO-DATE
    103. :Firebase:checkReleaseManifest
    104. :Firebase:prepareReleaseDependencies
    105. :Firebase:compileReleaseAidl
    106. :Firebase:compileReleaseNdk NO-SOURCE
    107. :Firebase:compileLint
    108. :Firebase:copyReleaseLint NO-SOURCE
    109. :Firebase:mergeReleaseShaders
    110. :Firebase:compileReleaseShaders
    111. :Firebase:generateReleaseAssets
    112. :Firebase:mergeReleaseAssets
    113. :Firebase:mergeReleaseProguardFiles UP-TO-DATE
    114. :Firebase:packageReleaseRenderscript NO-SOURCE
    115. :Firebase:compileReleaseRenderscript
    116. :Firebase:generateReleaseResValues
    117. :Firebase:generateReleaseResources
    118. :Firebase:packageReleaseResources
    119. :Firebase:processReleaseManifest
    120. :Firebase:generateReleaseBuildConfig
    121. :Firebase:processReleaseResources
    122. :Firebase:generateReleaseSources
    123. :Firebase:incrementalReleaseJavaCompilationSafeguard
    124. :Firebase:javaPreCompileRelease
    125. :Firebase:compileReleaseJavaWithJavac
    126. :Firebase:processReleaseJavaRes NO-SOURCE
    127. :Firebase:transformResourcesWithMergeJavaResForRelease
    128. :Firebase:transformClassesAndResourcesWithSyncLibJarsForRelease
    129. :Firebase:mergeReleaseJniLibFolders
    130. :Firebase:transformNativeLibsWithMergeJniLibsForRelease
    131. :Firebase:transformNativeLibsWithStripDebugSymbolForRelease
    132. :Firebase:transformNativeLibsWithSyncJniLibsForRelease
    133. :Firebase:bundleRelease
    134. :GooglePlayGamesManifest.plugin:preBuild UP-TO-DATE
    135. :GooglePlayGamesManifest.plugin:preReleaseBuild UP-TO-DATE
    136. :GooglePlayGamesManifest.plugin:checkReleaseManifest
    137. :GooglePlayGamesManifest.plugin:prepareReleaseDependencies
    138. :GooglePlayGamesManifest.plugin:compileReleaseAidl
    139. :GooglePlayGamesManifest.plugin:compileReleaseNdk NO-SOURCE
    140. :GooglePlayGamesManifest.plugin:compileLint
    141. :GooglePlayGamesManifest.plugin:copyReleaseLint NO-SOURCE
    142. :GooglePlayGamesManifest.plugin:mergeReleaseShaders
    143. :GooglePlayGamesManifest.plugin:compileReleaseShaders
    144. :GooglePlayGamesManifest.plugin:generateReleaseAssets
    145. :GooglePlayGamesManifest.plugin:mergeReleaseAssets
    146. :GooglePlayGamesManifest.plugin:mergeReleaseProguardFiles UP-TO-DATE
    147. :GooglePlayGamesManifest.plugin:packageReleaseRenderscript NO-SOURCE
    148. :GooglePlayGamesManifest.plugin:compileReleaseRenderscript
    149. :GooglePlayGamesManifest.plugin:generateReleaseResValues
    150. :GooglePlayGamesManifest.plugin:generateReleaseResources
    151. :GooglePlayGamesManifest.plugin:packageReleaseResources
    152. :GooglePlayGamesManifest.plugin:processReleaseManifest
    153. :GooglePlayGamesManifest.plugin:generateReleaseBuildConfig
    154. :GooglePlayGamesManifest.plugin:processReleaseResources
    155. :GooglePlayGamesManifest.plugin:generateReleaseSources
    156. :GooglePlayGamesManifest.plugin:incrementalReleaseJavaCompilationSafeguard
    157. :GooglePlayGamesManifest.plugin:javaPreCompileRelease
    158. :GooglePlayGamesManifest.plugin:compileReleaseJavaWithJavac
    159. :GooglePlayGamesManifest.plugin:processReleaseJavaRes NO-SOURCE
    160. :GooglePlayGamesManifest.plugin:transformResourcesWithMergeJavaResForRelease
    161. :GooglePlayGamesManifest.plugin:transformClassesAndResourcesWithSyncLibJarsForRelease
    162. :GooglePlayGamesManifest.plugin:mergeReleaseJniLibFolders
    163. :GooglePlayGamesManifest.plugin:transformNativeLibsWithMergeJniLibsForRelease
    164. :GooglePlayGamesManifest.plugin:transformNativeLibsWithStripDebugSymbolForRelease
    165. :GooglePlayGamesManifest.plugin:transformNativeLibsWithSyncJniLibsForRelease
    166. :GooglePlayGamesManifest.plugin:bundleRelease
    167. :UnityOBBDownloader:preBuild UP-TO-DATE
    168. :UnityOBBDownloader:preReleaseBuild UP-TO-DATE
    169. :UnityOBBDownloader:checkReleaseManifest
    170. :UnityOBBDownloader:prepareReleaseDependencies
    171. :UnityOBBDownloader:compileReleaseAidl
    172. :UnityOBBDownloader:compileReleaseNdk NO-SOURCE
    173. :UnityOBBDownloader:compileLint
    174. :UnityOBBDownloader:copyReleaseLint NO-SOURCE
    175. :UnityOBBDownloader:mergeReleaseShaders
    176. :UnityOBBDownloader:compileReleaseShaders
    177. :UnityOBBDownloader:generateReleaseAssets
    178. :UnityOBBDownloader:mergeReleaseAssets
    179. :UnityOBBDownloader:mergeReleaseProguardFiles UP-TO-DATE
    180. :UnityOBBDownloader:packageReleaseRenderscript NO-SOURCE
    181. :UnityOBBDownloader:compileReleaseRenderscript
    182. :UnityOBBDownloader:generateReleaseResValues
    183. :UnityOBBDownloader:generateReleaseResources
    184. :UnityOBBDownloader:packageReleaseResources
    185. :UnityOBBDownloader:processReleaseManifest
    186. :UnityOBBDownloader:generateReleaseBuildConfig
    187. :UnityOBBDownloader:processReleaseResources
    188. :UnityOBBDownloader:generateReleaseSources
    189. :UnityOBBDownloader:incrementalReleaseJavaCompilationSafeguard
    190. :UnityOBBDownloader:javaPreCompileRelease
    191. :UnityOBBDownloader:compileReleaseJavaWithJavac
    192. :UnityOBBDownloader:processReleaseJavaRes NO-SOURCE
    193. :UnityOBBDownloader:transformResourcesWithMergeJavaResForRelease
    194. :UnityOBBDownloader:transformClassesAndResourcesWithSyncLibJarsForRelease
    195. :UnityOBBDownloader:mergeReleaseJniLibFolders
    196. :UnityOBBDownloader:transformNativeLibsWithMergeJniLibsForRelease
    197. :UnityOBBDownloader:transformNativeLibsWithStripDebugSymbolForRelease
    198. :UnityOBBDownloader:transformNativeLibsWithSyncJniLibsForRelease
    199. :UnityOBBDownloader:bundleRelease
    200. :prepareDebugDependencies
    201. :compileDebugAidl UP-TO-DATE
    202. :compileDebugRenderscript UP-TO-DATE
    203. :generateDebugBuildConfig UP-TO-DATE
    204. :generateDebugResValues UP-TO-DATE
    205. :generateDebugResources UP-TO-DATE
    206. :mergeDebugResources UP-TO-DATE
    207. :processDebugManifest
    208. :processDebugResources
    209. :generateDebugSources
    210. :incrementalDebugJavaCompilationSafeguard UP-TO-DATE
    211. :javaPreCompileDebug
    212. :compileDebugJavaWithJavac UP-TO-DATE
    213. :compileDebugNdk NO-SOURCE
    214. :compileDebugSources UP-TO-DATE
    215. :mergeDebugShaders UP-TO-DATE
    216. :compileDebugShaders UP-TO-DATE
    217. :generateDebugAssets UP-TO-DATE
    218. :mergeDebugAssets
    219. :transformClassesWithDexForDebug FAILED
    220. 126 actionable tasks: 114 executed, 12 up-to-date
    221. ]
    222. exit code: 1
    223. UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    224. UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    225. UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1 progress, System.String error)
    226. UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action`1 progress)
    227. Rethrow as GradleInvokationException: Gradle build failed
    228. UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action`1 progress)
    229. UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    230. UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    231. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Why are you adding those lines to your Gradle file? not sure they're needed. in case you're not adding that, what kind of error are you seeing ?
     
  3. Neozman

    Neozman

    Joined:
    Sep 29, 2016
    Posts:
    67

    Code (CSharp):
    1. Dex: Error converting bytecode to dex:
    2. Cause: Dex cannot parse version 52 byte code.
    3. This is caused by library dependencies that have been compiled using Java 8 or above.
    4. If you are using the 'java' gradle plugin in a library submodule add
    5. targetCompatibility = '1.7'
    6. sourceCompatibility = '1.7'
    7. to that submodule's build.gradle file.
    This is the error. I added those lines just to find out will it help or not. Anyway nothing has changed after adding those lines - build is failing each time ;(
     
  4. Neozman

    Neozman

    Joined:
    Sep 29, 2016
    Posts:
    67
    Still looking for decision