Skip to content

Commit 30ad2c6

Browse files
authored
Create initial usage troubleshooting guide for merger into main EDM4U.
1 parent 0ab486a commit 30ad2c6

File tree

1 file changed

+143
-0
lines changed

1 file changed

+143
-0
lines changed

troubleshooting-faq.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
2+
# EDM4U Usage Troubleshooting Guide
3+
4+
---
5+
## Table of contents
6+
1. [Resolver and Target Platform Build Debug Process](#introduction)
7+
2. [General Tips](#general_tips)
8+
1. [Enable Verbose Logging](#verbose_loggin)
9+
2. [Turn off auto-resolution on Android](#android_auto_resolution)
10+
3. [Android](#android)
11+
1. [Fixing "Resolution Failed" errors](#resolution_failed)
12+
2. [Use Force Resolve if having issues with resolution](#force_resolve)
13+
3. [JDK, SDK, NDK, Gradle Issues (including locating)](#jdk_sdk_ndk)
14+
4. [Enable Custom Main Gradle Template, a.k.a. mainTemplate.gradle](#custom_main_gradle_template)
15+
5. [Enable Jetifier if you can](#jetifier)
16+
4. [iOS](#ios)
17+
1. [Investigate Cocoapods if iOS resolution fails](#cocoapods)
18+
2. [Prefer opening Xcode Workspace files in Xcode to opening Xcode Project Files](#xcode_workspace_files)
19+
3. [Win32 Errors when building Xcode Workspace/Project on Mac](#win32_errors)
20+
4. [Runtime Swift Issues](#swift)
21+
---
22+
23+
# Resolver and Target Platform Build Debug Process<a id="introduction"></a>
24+
25+
26+
The following is a roughly chronological process for debugging and exploring the use of EDM4U when building your game/app for a particular platform. The first section ("General Tips'') applies regardless of your target, while the remaining two have to do with which target you are building for (Android or or iOS).
27+
28+
Consider each step within a section in order: If you do not have an issue with the step, move on to the next; If you do have an issue, attempt the listed steps and proceed once the issue is cleared.
29+
30+
Throughout the process, additionally address and explore both warnings and error messages displayed in the Unity Editor console and/or device logs. Oftentimes, seemingly unrelated errors can cause issues and, even when they don't, they can hide bigger issues.
31+
32+
<div class="warning" style='padding:0.1em; background-color:#b6d7a8; color:#000000'>
33+
<span>
34+
<p><strong>Note:</strong> This guide assumes you have already tested and verified the expected functionality of your Unity game/app in the Editor when compiling for the <a href="https://docs.unity3d.com/Manual/BuildSettings.html#:%7E:text=Select-,Switch%20Platforms,-.%0AIf%20Unity">target platform</a>.</p>
35+
<p>If you have not done so yet, perform your tests and resolve any issues you find before returning to this process.</p>
36+
</span>
37+
</div>
38+
<p><p><p>
39+
40+
41+
# **General Tips**<a id="general_tips"></a>
42+
43+
If at any point you want or need more resolver or build information, consider enabling verbose logging and reading the log after trying to build again
44+
45+
### **Enable Verbose Logging**<a id="verbose_loggin"></a>
46+
47+
#### <ins>Android</ins>
48+
49+
Enable **Verbose Logging** in **Assets &gt; External Dependency Manager &gt; Android Resolver &gt; Settings**
50+
51+
#### <ins>iOS</ins>
52+
53+
Enable **Verbose Logging** in **Assets &gt; External Dependency Manager &gt; iOS Resolver &gt; Settings**
54+
55+
### **Turn off auto-resolution on Android**<a id="android_auto_resolution"></a>
56+
57+
When the auto-resolution feature is enabled, the Android resolver can trigger when assets are changed or when AppDomain is reloaded, which happens every time you press the Play button in the editor. Dependency resolution can be slow when the Unity project is big or when the resolver needs to download and patch many Android libraries. You can improve iteration time by disabling most of the auto-resolution features and manually triggering resolution instead.
58+
59+
* Manual resolution is available through **Assets &gt; External Dependency Manager &gt; Android Resolver &gt; Resolve** and **Assets &gt; External Dependency Manager &gt; Android Resolver &gt; Force Resolve** menu items.
60+
* Turn off "Enable Auto-Resolution" in the settings menu to prevent resolution triggered by assets changes and AppDomain reloads.
61+
* Turn off "Enable Resolution on Build" in the settings menu to speed up build time.
62+
63+
# **Android**<a id="android"></a>
64+
65+
### **Fixing "Resolution Failed" errors**<a id="resolution_failed"></a>
66+
67+
If EDM4U fails resolution, try the following sequentially, making sure to check whether resolution succeeded between each. If a section heading includes "if you can", perform the step unless you *know* you cannot or that there are issues with doing so in your project.
68+
69+
### **Use Force Resolve if having issues with resolution**<a id="force_resolve"></a>
70+
71+
* When trying to build, if you receive errors, try to resolve dependencies by clicking **Assets &gt; External Dependency Manager &gt; Android Resolver &gt; Resolve**
72+
* If this fails, try **Assets &gt; External Dependency Manager &gt; Android Resolver &gt; Force Resolve.** While this is slower, it is more dependendable as it clears old intermediate data.
73+
74+
### **JDK, SDK, NDK, Gradle Issues (including locating)**<a id="jdk_sdk_ndk"></a>
75+
76+
* Reasons to do this:
77+
* If **Force Resolve** is failing and you have not done this yet, try this.
78+
* If you receive error logs about Unity being unable to locate the `JDK`, `Android SDK Tools` or `NDK`
79+
* This issue is mostly observed in Unity 2019 and 2020.
80+
* What it does:
81+
* Toggling the external tool settings forces Unity to acknowledge them as it may not have loaded them properly.
82+
* What to do:
83+
* Enter **Unity &gt; Preferences&gt; External Tools**
84+
* Toggle the `JDK`, `Android SDK`, `Android NDK` and `Gradle` **checkboxes** such that they have the opposite value of what they started with
85+
* Toggle them back to their original values
86+
* Try **Force Resolve** and/or building again
87+
88+
### **Enable Custom Main Gradle Template, a.k.a. mainTemplate.gradle**<a id="custom_main_gradle_template"></a>
89+
90+
* By default, EDM4U used [a custom Gradle script](https://github.com/googlesamples/unity-jar-resolver/blob/master/source/AndroidResolver/scripts/download_artifacts.gradle) to download Android libraries to the "Assets/Plugins/Android/" folder. This can be problematic in several cases:
91+
* When Unity adds some common Android libraries with specific versions to the Gradle by default, play-core or game-activity. This would very likely cause duplicate class errors during build time.
92+
* When multiple Unity plugins depend on the same Android libraries with a very different range of versions. The Gradle project generated by Unity can handle resolution far better than the custom script in EDM4U.
93+
* Downloading large amounts of Android libraries can be slow.
94+
* If you do this and are on Unity 2019.3+ you *must* enable [**Custom Gradle Properties Template**](https://docs.unity3d.com/Manual/class-PlayerSettingsAndroid.html#Publishing) to enable AndroidX and Jetifier, which are described in the next step.
95+
96+
### **Enable Jetifier if you can**<a id="jetifier"></a>
97+
98+
* Android 9 introduced a new set of support libraries (AndroidX) which use the same class name but under a different package name. If your project has dependencies (including transitive dependencies) on both AndroidX and the older Android Support Libraries, duplicated class errors in `com.google.android.support.*` and `com.google.androidx.*` will occur during build time. [Jetifier](https://developer.android.com/tools/jetifier) is a tool to resolve such cases. In general, you should *enable Jetifier if your target Android version is 9+, or API level 28+*.
99+
* Android Resolver can configure Unity projects to enable Jetifier. This feature can be enabled by the **Use Jetifier** option in Android Resolver settings. When enabled,
100+
* Android Resolver uses Jetifier to patch every Android library it downloaded to the "Assets/Plugins/Android" folder.
101+
* When **Custom Main Gradle Template** is enabled, it injects scripts to enable AndroidX and Jetifier to this template, prior to Unity 2019.3. After Unity 2019.3, AndroidX and Jetifier can only be enabled in **Custom Gradle Properties Template**.
102+
* When using Unity 2019.3 or above, it is recommended to enable **Custom Gradle Properties Template**, regardless if you are using **Custom Main Gradle Template** or not.
103+
104+
# **iOS**<a id="ios"></a>
105+
106+
If EDM4U fails resolution, try the following sequentially, making sure to check whether resolution succeeded between each.
107+
108+
### **Investigate Cocoapods if iOS resolution fails**<a id="cocoapods"></a>
109+
110+
* First of all make sure it's [properly installed](https://guides.cocoapods.org/using/getting-started.html)
111+
* Verify that [`pod install` and `pod update` run without errors](https://guides.cocoapods.org/using/pod-install-vs-update.html) in the folder where the Podfile is (usually the root folder of the Xcode project).
112+
* Cocoapods text encoding issues when building from Mac
113+
* Do this if you are building on a Mac and see the following in the cocoapods log
114+
`WARNING: CocoaPods requires your terminal to be using UTF-8 encoding.`
115+
* When building for iOS, Cocoapod installation may fail with an error about the language locale, or UTF-8 encoding. There are currently several different ways to work around the issue.
116+
* From the terminal, run `pod install` directly, and open the resulting `xcworkspace` file.
117+
* Downgrade the version of Cocoapods to 1.10.2. The issue exists only in version 1.11 and newer.
118+
* In your `~/.bash_profile` or equivalent, add `export LANG=en_US.UTF-8`
119+
120+
### **Prefer opening Xcode Workspace files in Xcode to opening Xcode Project Files**<a id="xcode_workspace_files"></a>
121+
122+
Try to [build iOS builds from Xcode Workspaces](https://developer.apple.com/library/archive/featuredarticles/XcodeConcepts/Concept-Workspace.html) generated by Cocoapods rather than Xcode projects:
123+
124+
* Rationale:
125+
* Unity by default only generates `.xcodeproject` files. If EDM4U is in the project, it first generates Podfiles from all iOS dependencies specified in files named "Dependencies.xml" with a prefix (ex. "AppDependencies.xml") , then runs Cocoapods, which generates an `.xcworkspace` file
126+
* In this case, it is recommended to open the generated project by double-clicking on `.xcworkspace` instead of `.xcodeproject` since the former contains references to pods.
127+
* If you are building in an environment you cannot open Xcode workspaces from (such as unity cloud build) then go into the **iOS resolver settings**, enter the dropdown **Cocoapods Integration** and select **Xcode project**
128+
129+
### **Win32 Errors when building Xcode Workspace/Project on Mac**<a id="win32_errors"></a>
130+
131+
If the Unity Editor's console displays [build output that mentions win32 errors](https://issuetracker.unity3d.com/issues/webgl-builderror-constant-il2cpp-build-error-after-osx-12-dot-3-upgrade), upgrade to a more recent LTS version of Unity after 2020.3.40f1.
132+
133+
* While workarounds exist, upgrading is the fastest, most convenient and most reliable way to handle it.
134+
135+
### **Runtime Swift Issues**<a id="swift"></a>
136+
137+
If you run into an issue when trying to run the game with error logs that mention Swift, try the following:
138+
139+
* Turn on `Enable Swift Framework Support Workaround` in **Assets &gt; External Dependency Manager &gt; iOS Resolver &gt; Settings**.
140+
* Read the description in the settings menu.
141+
* Make sure those changes are made to the generated Xcode project.
142+
143+
If you are still experiencing issues at this point, investigate whether troubleshooting the product that utilizes EDM4U works differently or better now. Consider filing an issue here or with the product you are employing that utilizes EDM4U.

0 commit comments

Comments
 (0)