【避坑指南】Unity3D接入外网SDK笔记(GooglePlay/FaceBook/AppsFlyer)

这段时间折腾了一下获取归因数据相关的SDK,遇到非常多奇奇怪挂的报错,在此记录一下。

准备资源

  1. Unity的Jar包解析器,下面提及的SDK都需要工具解析并下载依赖 https://github.com/googlesamples/unity-jar-resolver
  2. AndroidStudio,非常强大的工具,开发Android少不了,里面的SDKManager非常实用
    https://developer.android.com/studio
  3. GooglePlay
    适用于Unity的GooglePlaySDK(current-build目录下有个unitypackage):https://github.com/playgameservices/play-games-plugin-for-unity
    接入指南:https://developer.android.com/games/pgs/unity/unity-start?hl=zh-cn
  4. FaceBook
    适用于Unity的FaceBookSDK: https://developers.facebook.com/docs/unity/?locale=zh_CN
    接入指南:https://developers.facebook.com/docs/unity/gettingstarted
  5. AppsFlyer
    适用于Unity的AppsFlyerSDK(根目录下有个unitypackage):https://github.com/AppsFlyerSDK/appsflyer-unity-plugin
    接入指南:https://support.appsflyer.com/hc/zh-cn/articles/360007314277
  6. adb,安卓调试神器
    Windows版本:https://dl.google.com/android/repository/platform-tools-latest-windows.zip
    Mac版本:https://dl.google.com/android/repository/platform-tools-latest-darwin.zip
    Linux版本:https://dl.google.com/android/repository/platform-tools-latest-linux.zip
    然后配置一下环境变量:https://blog.csdn.net/x2584179909/article/details/108319973
    在cmd输入 adb logcat 即可,只看error级别的打印可以输入 adb logcat *:E

报错以及解决方案

  1. 解析Jar包出错

“Assembly ‘Assets/ExternalDependencyManager/Editor/Google.VersionHandlerImpl_v1.2.156.dll’ will not be loaded due to errors: Assembly name’Google.VersionHandlerImpl’ does not match file name’Google.VersionHandlerImpl_v1.2.156’ Assembly’Assets/ExternalDependencyManager/Editor/1.2.175/Google.IOSResolver.dll’will not be loaded due to errors: Unable to resolve reference ‘UnityEditor.iOS.Extensions.Xcode’. Is the assembly missing or incompatible with the current platform? Reference validation can be disabled in the Plugin Inspector.”
在这里插入图片描述

下载一个新版的ExternalDependencyManager工具包(版本1.2.176),详情看油管视频: https://www.youtube.com/watch?v=z4ERv0oLJXc

  1. 打包出错,提示Gradle构建失败,显示AAPT2啥的

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
AAPT2 aapt2-4.1.0-6503028-windows Daemon #0: Unexpected error during link, attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.

一般是因为JDK、SDK、NDK、Gradle在Unity中配置不正确或者版本太低引起的,建议 JDK和Grade使用Unity内置的版本,而SDK或者NDK使用自己下载好的高版本(AndroidStudio的SDKManager可以很方便下载到)。

  1. 解析Jar包卡住了
    【避坑指南】Unity3D接入外网SDK笔记(GooglePlay/FaceBook/AppsFlyer)_第1张图片
    如果Assets/Plugins/Android目录下没有出现一大堆jar包,可以断定解析Jar包报错了,这个报错比较复杂,检查一下有没有解决本博客提及的其他报错问题。最简单的方法就是新建一个工程,重新导入所有SDK。

  2. 提示循环导入

An infinite import loop has been detected. The following Assets were imported multiple times, but no changes to them have been detected. Please check if any custom code is trying to import them:

关闭Unity,删除Unity工程的Library目录,重新打开工程。
原因可能是解析Jar包解析到一半,没删掉旧的文件又重新开始解析。

你可能感兴趣的:(避坑,Android,Unity3D,SDK,GooglePlay,Facebook,AppsFlyer)