UnityException: Error
mainTemplate.gradle file is using the old aaptOptions noCompress property definition which does not include types defined by unityStreamingAssets constant.
keystore 정보는 ProjectSettings.asset 파일에 아래와 같이 저장된다.
AndroidKeystoreName: '{inproject}: Keystore/name.keystore'
AndroidKeyaliasName: name
...중략...
androidUseCustomKeystore: 1
하지만 비밀번호와 같은 정보는 별도로 저장되다보니 체크아웃을 새로 받을 때마다, keystore 세팅을 다시 해줘야했다.
| 현상
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':launcher:packageRelease'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> com.android.ide.common.signing.KeytoolException: Failed to read key creature from store "/Users/${USER}/.jenkins/workspace/${PROJECT_NAME}/Keystore/user.keystore": Keystore was tampered with, or password was incorrect
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.1.1/userguide/command_line_interface.html#sec:command_line_warnings
ProjectSettings.asset 파일에는 androidUseCustomKeystore값은 1로 남아있는데,
alias나 비밀번호 같은 값이 날아가 버려서 위와 같은 에러가 발생한다.
| 해결
using UnityEditor;
using UnityEngine;
namespace Tools.Settings
{
[FilePath("UserSettings/BuildConfigs.asset", FilePathAttribute.Location.ProjectFolder)]
public class BuildConfigs : ScriptableSingleton<BuildConfigs>
{
public string __ks_pass;
public string __ks_key_alias;
public string __key_pass;
public string KeyStorePassword => Base64.Decode(__ks_pass);
public string KeyAlias => Base64.Decode(__ks_key_alias);
public string KeyPass => Base64.Decode(__key_pass);
public void Save()
{
Save(true);
}
}
sealed class BuildConfigsProvider : SettingsProvider
{
public const string Url = "{url}/manage/configure";
public BuildConfigsProvider()
: base("Preferences/Build Configs", SettingsScope.User)
{
}
public override void OnGUI(string search)
{
var settings = BuildConfigs.instance;
var __ks_pass = settings.KeyStorePassword;
var __ks_key_alias = settings.KeyAlias;
var __key_pass = settings.KeyPass;
EditorGUI.BeginChangeCheck();
__ks_pass = EditorGUILayout.PasswordField("--ks-pass", __ks_pass);
__ks_key_alias = EditorGUILayout.PasswordField("--ks-key-alias", __ks_key_alias);
__key_pass = EditorGUILayout.PasswordField("--key-pass", __key_pass);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Overview"))
{
Application.OpenURL(Url);
}
GUILayout.EndHorizontal();
if (EditorGUI.EndChangeCheck())
{
settings.__ks_pass = Base64.Encode(__ks_pass);
settings.__ks_key_alias = Base64.Encode(__ks_key_alias);
settings.__key_pass = Base64.Encode(__key_pass);
settings.Save();
}
}
}
static class BuildConfigsRegister
{
[SettingsProvider]
public static SettingsProvider CreateCustomSettingsProvider()
=> new BuildConfigsProvider();
}
}
CI 툴에서 파라미터로 전달해도 되지만,
버전 관리 툴에서 관리되었으면 해서 UserSettings에 값을 저장할 수 있도록 하였다.
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/<user>/.jenkins/workspace/<job>/GradleProject/unityLibrary/build.gradle' line: 176
* What went wrong:
Execution failed for task ':unityLibrary:BuildIl2CppTask'.
> NDK is not installed
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings
Gradle 빌드 중 설치된 NDK를 인식하지 못하는 현상
UnityHub가 도입되고 고도화되면서 Unity 설치 시에 각 플랫폼 별 빌드 지원하는 툴들을 설치하게 되었다.
그 후로는 유사한 이슈가 발생하지 않았는데 2021.3.22f1버전에서 2022.3.6f1버전으로 업그레이드 하면서 발생했다.
| 해결
using System.IO;
using UnityEditor.Android;
namespace Tools
{
#if UNITY_2022_3_OR_NEWER
public class AndroidPostBuildProcessor : IPostGenerateGradleAndroidProject
{
public int callbackOrder => 1;
public void OnPostGenerateGradleAndroidProject(string path)
{
Debug.Log("OnPostGenerateGradleAndroidProject: " + path);
var di = new DirectoryInfo(path);
var localPropertiesFile = Path.Combine(di.Parent.FullName, "local.properties");
if (File.Exists(localPropertiesFile))
{
var hasNdkProp = HasNdkProp(localPropertiesFile);
if (false == hasNdkProp)
{
var ndkDir = $"{System.Environment.NewLine}ndk.dir={AndroidExternalToolsSettings.ndkRootPath}";
File.AppendAllText(localPropertiesFile, ndkDir);
}
}
}
private bool HasNdkProp(string path)
{
using (var streamReader = new StreamReader(path, System.Text.Encoding.UTF8))
{
string line = string.Empty;
while ((line = streamReader.ReadLine()) != null)
{
if (line.StartsWith("ndk.dir="))
return true;
}
}
return false;
}
}
#endif
}
근본적인 해결책은 아니지만 Android Project를 생성할 때, local.properties 파일에 NDK 정보를 입력하는 식으로 해결하였다.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':unityLibrary:parseReleaseLocalResources'.
> Could not resolve all dependencies for configuration ':unityLibrary:androidApis'.
> Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven4(http://maven.singular.net)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.2/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details.
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings
Unity3d를 2021.3.22f1버전에서 2022.3.6f1버전으로 업그레이드 하면서 그래들 버전이 달라져서 그런지 http 리포지터리를 허용하지 않았다.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':unityLibrary:hive.androidlib:compileReleaseAidl'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;30.0.3 Android SDK Build-Tools 30.0.3
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: /Applications/Unity/Hub/Editor/2021.3.22f1/PlaybackEngines/AndroidPlayer/SDK
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 24s
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':stripReleaseDebugSymbols'.
> No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 36s
WARN: Unable to load JNA library (OS: Mac OS X 11.5.2)
java.lang.UnsatisfiedLinkError: /Users/<user>/Library/Caches/JNA/temp/jna13372397078913963777.tmp: dlopen(/Users/<user>/Library/Caches/JNA/temp/jna13372397078913963777.tmp, 1): no suitable image found. Did find:
/Users/<user>/Library/Caches/JNA/temp/jna13372397078913963777.tmp: no matching architecture in universal wrapper
/Users/<user>/Library/Caches/JNA/temp/jna13372397078913963777.tmp: no matching architecture in universal wrapper
at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)