Unity FBSDK 接入踩坑记录

news/2024/7/24 7:25:02 标签: unity, 游戏引擎

unity__facebook_sdk_0">关于unity 接入 facebook sdk报错解决记录

问题描述:
打包报错“Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java使用或覆盖了已过时的 API.”

1.期间我尝试了将包导出到AndroidStudio中打包,查看bug,导入之后不作任何处理然后打包

FAILURE: Build completed with 3 failures.

1: Task failed with an exception.
-----------
* What went wrong:
A problem was found with the configuration of task ':unityLibrary:checkDebugManifest' (type 'CheckManifest').
  - In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.internal.tasks.CheckManifest' property 'manifest' has @Input annotation used on property of type 'File'.
    
    Reason: A property of type 'File' annotated with @Input cannot determine how to interpret the file.
    
    Possible solutions:
      1. Annotate with @InputFile for regular files.
      2. Annotate with @InputDirectory for directories.
      3. If you want to track the path, return File.absolutePath as a String and keep @Input.
    
    Please refer to https://docs.gradle.org/7.4/userguide/validation_problems.html#incorrect_use_of_input_annotation for more details about this problem.

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem was found with the configuration of task ':unityLibrary:compileDebugShaders' (type 'ShaderCompile').
  - In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.tasks.ShaderCompile' property 'sourceDir' is annotated with @InputFiles but missing a normalization strategy.
    
    Reason: If you don't declare the normalization, outputs can't be re-used between machines or locations on the same machine, therefore caching efficiency drops significantly.
    
    Possible solution: Declare the normalization strategy by annotating the property with either @PathSensitive, @Classpath or @CompileClasspath.
    
    Please refer to https://docs.gradle.org/7.4/userguide/validation_problems.html#missing_normalization_annotation for more details about this problem.

* 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.
==============================================================================

3: Task failed with an exception.
-----------
* What went wrong:
Some problems were found with the configuration of task ':unityLibrary:transformNativeLibsWithMergeJniLibsForDebug' (type 'TransformTask').
  - In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.internal.pipeline.TransformTask' property 'allSecondaryInputs' is private and annotated with @Internal.
    
    Reason: Annotations on private getters are ignored.
    
    Possible solutions:
      1. Make the getter public.
      2. Annotate the public version of the getter.

作为非专业安卓工程师,我根本就看不懂报错,只知道和“com.android.build.gradle.api.AndroidBasePlugin”脱不了干系,然后紧接着发现AS在建议我升级一些配置,看样子是要升级什么东西。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-RGcVC7Aj-1688017256810)(C:\Users\gy\AppData\Local\Temp\企业微信截图_1687940470251.png)]

神奇的事情发生了,我点击升级后,打包成功了,然后接着我发现他升级的东西就是gradle里面定义的一个依赖版本。

2.gradle android plugin 版本需要升级:

​ 3.4.0 => 4.2.0
​ 此时需要修改gradle里面的依赖,改gradle的文件需要处理一个问题,Unity的Custom Gradle有几种,如果修改错误可能会导致报错:
[Could not find method classpath() for arguments [com.android.tools.build:gradle:4.0.0]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-vvtR12aI-1688017256811)(C:\Users\gy\AppData\Roaming\Typora\typora-user-images\image-20230627143844398.png)]

第二种修改方法:直接修改UnityEditor文件下的gradle文件
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-66sOBv1Y-1688017256811)(file:///C:/Users/gy/Documents/WXWork/1688850302849244/Cache/Image/2023-06/企业微信截图_16879176944369.png)]

感恩戴德出包了!

装上包,NMD闪退了

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-sRkflf41-1688017256811)(C:\Users\gy\AppData\Roaming\Typora\typora-user-images\image-20230628170748477.png)]

2023/06/28 16:38:56.105 4912 4979 Error Unity The file ‘/data/app/~~9dlUytlV0Q8idFcjL1iVkA==/com.lmd.dev.xproject-x4dpKkGPp7G8SwWpLHuc4g==/base.apk/assets/bin/Data/ea726188743d68d45b5a458307e424f8’ is corrupted! Remove it and launch unity again!

继续解决问题:
网上根本搜不到关于Fascebook是如何处理这个问题的。看样子就是facebook初始化报错了,网上的各种解决办法都千奇百怪。

我重新打包报错是一样的,然后拆包查看那个资源文件,文件一大堆乱码,但是有个Facebooksetting字眼,该文件是记录AppID等信息的一个asset,且文件的位置在Resources下面,恰好网上有说asset问题的,有说Resources文件夹问题的,我只能一一都试一试。关键是我手动打包是不会报错闪退的,tmd。

Script attached to ‘FacebookSettings’ in scene ‘’ is missing or no valid script is attached.

改meta冲突解决的
In my case I found that the meta file for the script was checked in in a conflicted state. The team uses SVN, so the left right and working copies were all in there. I manually fixed the meta file and it seems to have worked. You could probably also just delete the meta file and let unity regenerate it, but the guid would probably change, which is why I opted for doing it manually.

删除丢失脚本引用的
I got this error after deleting some scripts but not deleting some prefabs that used those scripts. Even though those prefabs are not being used anywhere, they generated those warnings during builds. Check your prefabs for missing script references and delete them (or remove the script component)

有ScriptableObject的asset文件和cs文件同名的(这个存疑,因为FB的package默认命名就是这样的,demo也出包成功了的)
I had kind of the same error, but I had a ScriptableObject class called Item, but the filename was Items.cs - then I got this error. Had to rename the file to Item.cs

手动打包发现console面板有个日志叫我 regenerate AndroidMenifist 文件,于是我点击后出的包初始化FBSDK就会成功,于是乎需要处理的是在自动打包流程里面需要处理这件事情。


http://www.niftyadmin.cn/n/774983.html

相关文章

SpringSecurity实现登录和权限【真~前后端分离】

整合这个SpringSecurity花了我好几天的时间,也让我很头疼。 倒不是因为它很难,只是我搜索到的前后端分离验证,多多少少都有些问题。 下面我就把我完整的代码贡献出来、避免后面的人也走坑。 1、阐述几个问题 这里有几个问题需要表达一下&…

SpringSecurity解决跨域问题

今天集成了SpringSecurity发现postman可以访问,浏览器不可以访问,但是我之前已经做好了跨域的。 如果你的SpringBoot项目已经解决了跨域,那么只需要在SpringSecurityConfig做如下配置就好了 如果你还没有解决跨域,那么你只需要把…

封装RedisUtils,静态调用超级简单。【xdxFramework】

这里做一个Reids的封装,可能相对有些复杂,但是很好用,全是静态方法直接调用,不需要每次都注入。 下面我的会详细的把过程列举出来,如果还是有问题可以联系我。 1、项目截图 2、代码 2-1:RedisConfig impo…

Linux安装RocketMQ【阿里云ESC,CentOS7+,踩坑无数】

文章优先发表在个人博客,后面修改可能忘记同步到CSDN,给你带来不便抱歉。 个人博客本篇文章地址:https://www.xdx97.com/article/684051789376389120 1、下载 https://rocketmq.apache.org/dowloading/releases/ 2、安装 2-1&#xff1a…

SpringBoot整合RocketMQ,三种测试附带源码【rocketmq-spring-boot-starter】

我们整合boot项目的时候都是引入 xxx-start 依赖,但是现在大多数的整合RocketMQ都还不是这样。 我花了一天时间使用rocketmq-spring-boot-starter整合,使得操作起来更加简单。 1、说明 1-1:rocketmq-spring-boot-starter 提供了一个 rocketM…

微服务集成Swagger2【SpringCloud,SpringBoot】

文章优先发表在个人博客上面,后续更新可能忘记同步到CSDN,给你带来不便抱歉。 个人博客本篇文章地址:https://www.xdx97.com/article/688418128744415232 因为微服务是由多个服务构成如果每个服务的接口去开启新的页面这将十分难受。 下面教大…

SpringBoot配置Filter和Interceptor【附带源码】

博客优先发表在个人博客,后续更新可能忘记同步到CSDN,望理解。 个人博客本篇文章地址:https://www.xdx97.com/article/698261857995063296 一、先看一下目录结构 二、我们先配置启动类和配置文件 这里面其实没有什么东西,但是为了…

单例模式【创建型模式】

文章优先发布在个人博客。 https://www.xdx97.com/article/699258099130695680 所谓单例模式,就是对某个类只能存在一个对象实例,并且该类只提供一个获取其对象实例的方法(静态方法) 单例模式一共有八种方式 1、饿汉式 (静态常量…