'Unity - Gradle Build error : Could not resolve all files for configuration ':releaseCompileClasspath'
I am developing a game for Android mobile phones on Unity. I recently updated my facebook SDK , due to merge conflicts when building the app caused by the extra libraries that had to be added to the project by the Play Services Resolver I had to edit my Gradle.properties file to look like below.
org.gradle.jvmargs=-Xmx4096M
android.useAndroidX=true
android.enableJetifier=true
I did this mainly cause some of the support libraries were the cause of the merge conflicts. But now I keep getting the following error and I do not know how to fix it. I have tried reimporting the SDK several times but I still get the same problem. I have also tried asking on the Unity forums but I have received no responses yet. Any help would be appreciated.
* What went wrong:
Execution failed for task ':preReleaseBuild'.
> Could not resolve all files for configuration ':releaseCompileClasspath'.
> Failed to transform artifact 'com.android.support.support-v4-27.0.2.aar (:com.android.support.support-v4-27.0.2:)' to match attributes {artifactType=android-manifest}
> Execution failed for JetifyTransform: D:\Unity\Projects\Mzito-NewBG\2017.3\Mzito - Unity 2018.1.2f1 - GameTrove\Mzito\Temp\gradleOut\libs\com.android.support.support-v4-27.0.2.aar.
> Failed to transform 'D:\Unity\Projects\Mzito-NewBG\2017.3\Mzito - Unity 2018.1.2f1 - GameTrove\Mzito\Temp\gradleOut\libs\com.android.support.support-v4-27.0.2.aar' using Jetifier. Reason: The given artifact contains a string literal with a package reference 'android.support.v4' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.. (Run with --stacktrace for more details.)
Solution 1:[1]
go to Assets\Plugins\Android and remove all content then in unity editor in Assets menu go to Play Service Resolver(or external play resolver) >Android Resolver>Resolve now everyThing is oK!
Solution 2:[2]
I was having the same issue, I've fixed it with :
- Assets
- Play Service Resolver
- Android resolver
- force resolve
Solution 3:[3]
- Right click on assets folder
- Select Play Service Resolver
- Android resolver
- Resolve
It will fix the problem but make sure your java environment variable is setup otherwise it might not work
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | M.ghorbani |
| Solution 2 | JALAL ENNAKHLI |
| Solution 3 | Pablo Pantaleon |

