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
AssetBundle과 관련된 다양한 규칙들을 설정하고, 해당 규칙에 대한 검증 및 문제 해결까지 가능한 시스템이다.
기본적으로 아래와 같은 규칙이 제공된다.
중복 번들 종속성
빌트인 리소스와 어드레서블 어셋간 종속성
씬과 어드레서블간 종속성
번들 레이아웃 프리뷰 기능 (명시적, 암묵적으로 포함되는 어셋목록 리스트업)
패키지에 포함되어 있는 Analyze Rule
기존에도 어셋의 종속성이나 Duplicated 이슈를 검증할 수 있는 AssetBundle Rrowser라는 툴을 제공되었으나,
기능을 확장하거나, 번들마다 설정을 달리하는 등의 작업이 용이하진 않았다.
Analyze System은 종전의 문제점들에서 착안 다양한 옵션을 제공하고 있다.
| Custom Analyze Rule 추가방법
using UnityEditor;
using UnityEditor.AddressableAssets.Build.AnalyzeRules;
public class CustomRule : AnalyzeRule
{
public override string ruleName
{
get { return "룰 이름"; }
}
// 문제 해결이 가능한지 여부
public override bool CanFix
{
get { return false; }
set { }
}
public override void FixIssues(AddressableAssetSettings settings)
{
base.FixIssues(settings);
// ...
// 문제 해결 로직
// ...
}
public override List<AnalyzeResult> RefreshAnalysis(AddressableAssetSettings settings)
{
var results = new List<AnalyzeResult>();
// ...
// 분석 로직
// ...
results.Add(new AnalyzeResult()
{
resultName = "Result Message",
severity = UnityEditor.MessageType.Info | Warning | Error
});
return results;
}
}
[InitializeOnLoad]
class RegisterCustomRule
{
static RegisterCustomRule()
{
// Analyze System에 등록을 해야만 Analzye 윈도우에서 노출됨
AnalyzeSystem.RegisterNewRule<CustomRule>();
}
}
AnalyzeRule 클래스를 상속하고 AnalyzeSystem에 등록만 해주면 간단하게 커스텀 Analyze Rule을 추가할 수 있다.
| GroupSchema로 AnalyzeSystem 100% 활용하기
어셋 그룹을 추가하게되면 아래 스키마들이 기본적으로 추가되어 있다.
(Assets/AddressableAssetsData/AssetGroupTemplates/Packed Assets 파일 참조)
BundledAssetGroupScehema: 번들 빌드 및 로드 경로 / 압축 포맷 / 빌드 포함 여부 등 어셋번들에 관련된 다양한 옵션을 설정할 수 있는 스키마
ContentUpdateGroupSchema: 해당 컨텐츠가 업데이트 가능한지 여부를 설정
패키지에서 제공하는 스키마외에도 커스텀 스키마를 정의, 추가가 가능하다.
using UnityEditor;
using UnityEditor.AddressableAssets.Build.AnalyzeRules;
using UnityEditor.AddressableAssets.Settings;
public class CustomSchema : AddressableAssetGroupSchema
{
[SerializeField] public string Foo;
}
public class CustomRule : AnalyzeRule
{
// ...
public override List<AnalyzeResult> RefreshAnalysis(AddressableAssetSettings settings)
{
ClearAnalysis();
var results = new List<AnalyzeResult>();
foreach (var group in settings.groups)
{
if (group.HasSchema<CustomSchema>())
{
var schema = group.GetSchema<CustomSchema>();
// ...
// 분석 로직
// ...
}
}
results.Add(new AnalyzeResult()
{
resultName = "Result Message",
severity = UnityEditor.MessageType.Info | Warning | Error
});
return results;
}
}
CustomSchema를 추가한 그룹에 대한 별도 처리가 가능하다.
이제부터 AnalyzeSystem 활용에 대한 다양한 활용방법이 떠오르는데, 이를테면 이런 것들이다.
[어셋그룹]내의 텍스쳐 어셋의 포맷 혹은 압축 및 POT 여부를 설정하는 스키마를 추가 > 해당 그룹내의 텍스쳐를 분석 후 지정된 포맷으로 변환
[어셋그룹]내의 저해상도 및 저성능 관련 내용을 설정하는 스키마 추가 > 해당 그룹내 저해상도 어셋을 자동생성
[어셋그룹]내 시즌 상품에 관련된 모든 어셋을 지정하는 스키마를 추가, 미노출되어야하는 어세에 대한 처리
Bundle Mode 중 Pack Together By Label이란 옵션이 있는데,
(동일한 그룹내에서도 라벨 기준으로 번들 파일을 분리하여서 패키징할 수 있는 옵션)
패킹 레벨에서의 그룹과 Label의 용도의 차이점이 무엇인지 이해하기 어려웠다.
하지만 어셋 그룹 스키마와 Custom Analyze Rule에 관련된 예제를 보고는 확실히 개념이 정리가 되었다.
라벨링이 필요없는 경우 > Pack Together
번들 자체는 분리되어야 하지만, 어셋 그룹에 대한 설정은 공유하는 경우 > Pack Togher by Label
| 마치며
AnalzyeSystem의 사용법과 커스텀 룰을 추가하는 방법과 어셋 그룹 스키마와 활용하는 방법까지 알아보았다.
테스트나 번들 별 옵션 지정 등다양한 기능을 제공하면서도 잘 정리된 느낌이 들었다.
종전의 시스템으론 커버하기 힘든 요구사항까지 다 핸들링 가능한 시스템으로 적극적으로 사용한다면 다양한 용도로 사용할 수 있을 것으로 기대된다.