Jkeeper 发布的文章

上傳 google play 提交版本時出現錯誤

您的應用程式目前採用第 3.0.3 版 play 帳款服務程式庫,但至少須更新至第 5.2.1 版,才能使用 google play 的最新營利功能

這是因為上傳 aab 裡面使用到了 billing 是 3.0.3 版本的, 發現項目並沒有使用 billing 功能索性就刪除掉了

unityLibrary/build.grade

implementation(name: 'billing-3.0.3', ext:'aar') // 刪除

unityLibrary/src/main/AndroidManifest.xml

// 刪除

IL_0066: call System.Collections.Generic.IEnumerable`1<System.Linq.IGrouping`2<!!1,!!0>> System.Linq.Enumerable::GroupBy<System.Int32,System.Int32>(System.Collections.Generic.IEnumerable`1<!!0>,System.Func`2<!!0,!!1>) 

打包了pc版本, 運行時出現錯誤, 查了下 ILRuntime 官方, 總覺得 Linq 似乎沒法用 RegisterFunctionDelegate 解決, 查了網上說的的確只能自己改寫功能

private List<int> getUniqNumList(List<int> nums)
{
    List<int> ret = new List<int>();

    Dictionary<int, int> groupCounts = new Dictionary<int, int>();
    foreach (int num in nums)
    {
        if (!groupCounts.TryGetValue(num, out int oNum))
            groupCounts[num] = 1;
        else
            groupCounts[num]++;
    }

    foreach(int k in groupCounts.Keys)
    {
        if (groupCounts[k] == 1)
            ret.Add(k);
    }
    return ret;
}

#if ILRuntime
    List<int> guess_one = this.getUniqNumList(guess_list);
#else
    List<int> guess_one = guess_list.GroupBy(x => x).Where(x => x.Count() == 1).Select(x => x.Key).ToList();
#endif

打包PC版本

error: Could not set up a toolchain for Architecture x64. Make sure you have the right build tools installed for il2cpp builds. Details:

Internal build system error. BuildProgram exited with code -2146233088.
error: Could not set up a toolchain for Architecture x64. Make sure you have the right build tools installed for il2cpp builds. Details:
IL2CPP C++ code builder is unable to build C++ code. In order to build C++ code for Windows Desktop, you must have one of these installed:
 * Visual Studio 2022 or newer with C++ compilers and Windows 10 SDK (recommended)
 * Visual Studio 2019 with C++ compilers and Windows 10 SDK
 * Visual Studio 2017 with C++ compilers and Windows 10 SDK
 * Visual Studio 2015 with C++ compilers and Windows 10 SDK

Visual Studio 2017 (or newer) is detected using `vswhere.exe` as well as VSCOMNTOOLS environment variables.
Visual Studio 2015 is detected by looking at "SOFTWARE\Microsoft\VisualStudio\14.0_Config\InstallDir" in the registry as well as VSCOMNTOOLS environment variables.
Windows 10 SDK is detected by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0\InstallationFolder" in the registry.

Windows 10 SDK is not installed. You can install from here: https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/


Unity.IL2CPP.Bee.BuildLogic.ToolchainNotFoundException: IL2CPP C++ code builder is unable to build C++ code. In order to build C++ code for Windows Desktop, you must have one of these installed:
 * Visual Studio 2022 or newer with C++ compilers and Windows 10 SDK (recommended)
 * Visual Studio 2019 with C++ compilers and Windows 10 SDK
 * Visual Studio 2017 with C++ compilers and Windows 10 SDK
 * Visual Studio 2015 with C++ compilers and Windows 10 SDK

Visual Studio 2017 (or newer) is detected using `vswhere.exe` as well as VSCOMNTOOLS environment variables.
Visual Studio 2015 is detected by looking at "SOFTWARE\Microsoft\VisualStudio\14.0_Config\InstallDir" in the registry as well as VSCOMNTOOLS environment variables.
Windows 10 SDK is detected by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0\InstallationFolder" in the registry.

Windows 10 SDK is not installed. You can install from here: https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/


   at Unity.IL2CPP.Bee.BuildLogic.WindowsDesktop.WindowsDesktopBuildLogic.UserAvailableToolchainFor(Architecture architecture, NPath toolChainPath, NPath sysRootPath)
   at PlayerBuildProgramLibrary.PlayerBuildProgramBase.GetIl2CppToolChain(PlatformBuildLogic platform, Architecture architecture, NPath toolChainPath, NPath sysrootPath)
   at PlayerBuildProgramLibrary.PlayerBuildProgramBase.SetupIl2CppBuild()
   at PlayerBuildProgramLibrary.PlayerBuildProgramBase.SetupPlayerBuild()
   at WinPlayerBuildProgram.WinPlayerBuildProgram.SetupPlayerBuild()
   at PlayerBuildProgramLibrary.PlayerBuildProgramBase.RunBuildProgram()
   at PlayerBuildProgramTypeWrapper.Run(String[] args)
   at Program.Main(String[] args)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

重新安裝vs2022桌面開發環境工具
93402-394pwj5xvx5.png

開始下載安裝
03284-xemnwtyl3m.png

安裝好之後就行了, 打包還是出問題
51331-72d7eh1jz7e.png

網上找了方案, 說是把下面這段加入項目就行

#if UNITY_EDITOR
using System;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
public class MsvcStdextWorkaround : IPreprocessBuildWithReport
{
    const string kWorkaroundFlag = "/D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS";
    public int callbackOrder => 0;
    public void OnPreprocessBuild(BuildReport report)
    {
        var clEnv = Environment.GetEnvironmentVariable("_CL_");
        if (string.IsNullOrEmpty(clEnv))
        {
            Environment.SetEnvironmentVariable("_CL_", kWorkaroundFlag);
        }
        else if (!clEnv.Contains(kWorkaroundFlag))
        {
            clEnv += " " + kWorkaroundFlag;
            Environment.SetEnvironmentVariable("_CL_", clEnv);
        }
    }
}
#endif // UNITY_EDITOR

這個問題在版本 Unity 2020.3.42f1, 2021.3.14f1, 2022.1.23f1, 2022.2.0b16 and 2023.1.0a19.修復

[https://forum.unity.com/threads/unity-2022-1-22f1-with-il2cpp-not-working.1359580/][1]

$ pip install opencv-python

出現錯誤, python setup.py egg_info
23546-nulflha4fhj.png

需要升级 pip 版本
$ pip install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple/

安裝失敗, 後來去官網下載安裝檔升級

安裝 opencv 老是失敗, 應該是被牆了, 但掛了vpn還是無效

$ pip install opencv-python -i https://mirrors.aliyun.com/pypi/simple/
50505-r297uv50pvb.png

直接到網上下載檔案安裝, windows 選擇 win_amd64 格式
https://pypi.tuna.tsinghua.edu.cn/simple/opencv-python/

安裝檔案
$ pip install opencv_python-4.5.5.64-cp36-abi3-win_amd64.whl

查看安裝清單
$ pip list
04921-kiurv32sr2o.png