简体   繁体   English

Unity导出Android项目与Facebook SDK问题

[英]Unity exporting android project with Facebook SDK issue

I found an issue on exporting a project from Unity3D to Android Studio when Facebook SDK is involved. 我发现在涉及Facebook SDK时将项目从Unity3D导出到Android Studio时出现问题。 Currently I'm using Unity 5.4.1f1 and facebook-unity-sdk-7.9.0 . 目前我正在使用Unity 5.4.1f1facebook-unity-sdk-7.9.0

Here the steps to reproduce the issue : 这里是重现问题的步骤:

  1. Create a Unity project and add Facebook sdk (Import custom package etc) 创建一个Unity项目并添加Facebook sdk (导入自定义包等)
  2. Then configure it from the menu on the top bar under Facebook > Edit settings (it's enough adding the app id ) 然后在Facebook>编辑设置下的顶栏上的菜单中进行配置 (这足以添加应用ID
  3. In build settings select Android platform and edit player prefs adding a bundle id and setting min sdk version to 15 在构建设置中,选择Android平台并编辑播放器首选项,添加包ID并将min sdk版本设置为15
  4. Save the scene 保存场景
  5. Try to build an apk, it should work 尝试构建一个apk,它应该工作
  6. Now instead of building check 'Google Android project' in build setting and click export 现在,而不是在构建设置中构建检查“Google Android项目”,然后单击“ 导出”
  7. After that open android studio and click on import project 之后打开android studio并点击导入项目
  8. Select the folder with the name of the project you choose, you can find it inside the folder you select during the export procedure from Unity 选择具有您选择的项目名称的文件夹,您可以在Unity导出过程中选择的文件夹中找到它
  9. Press next and finish 按下一步完成
  10. When grade finishes his stuff and builds you get the error 当成绩完成他的东西和构建时,你得到错误

Error:(131) Error retrieving parent for item: No resource found that matches the given name '@style/Theme.AppCompat.NoActionBar'. 错误:(131)检索项目的父项时出错:找不到与给定名称“@ style / Theme.AppCompat.NoActionBar”匹配的资源。

Error:(136) Error retrieving parent for item: No resource found that matches the given name '@style/Theme.AppCompat.Dialog'. 错误:(136)检索项目的父项时出错:找不到与给定名称“@ style / Theme.AppCompat.Dialog”匹配的资源。

Error:(131) Error retrieving parent for item: No resource found that matches the given name '@style/Theme.AppCompat.NoActionBar'. 错误:(131)检索项目的父项时出错:找不到与给定名称“@ style / Theme.AppCompat.NoActionBar”匹配的资源。

Error:(136) Error retrieving parent for item: No resource found that matches the given name '@style/Theme.AppCompat.Dialog'. 错误:(136)检索项目的父项时出错:找不到与给定名称“@ style / Theme.AppCompat.Dialog”匹配的资源。

Error:Execution failed for task ':facebookandroidsdk4170:processDebugResources'. 错误:任务':facebookandroidsdk4170:processDebugResources'的执行失败。 com.android.ide.common.process.ProcessException: Failed to execute aapt com.android.ide.common.process.ProcessException:无法执行aapt

Someone did face this and has already found a solution? 有人确实面对这个并且已经找到了解决方案吗?

Seems like you are missing the appcompat library, the problem with exporting to android studio is that it doesn't export .aar files well (at least before Unity 5.5). 好像你错过了appcompat库,导出到android studio的问题是它不能很好地导出.aar文件(至少在Unity 5.5之前)。

You have to copy all your .aar files in your Plugins/Android (there may be also in the facebook folder) into your android studio project libs folder. 你必须将你的插件/ Android中的所有.aar文件(也可能在facebook文件夹中)复制到你的android studio项目libs文件夹中。

Then open your app build.gradle (normally named app or same as your project's name) and put inside the dependencies this for each .aar file: 然后打开你的应用程序build.gradle(通常命名app或与你的项目名称相同),并为每个.aar文件放入这个依赖项:

compile(name: 'aarlibrarywithoutextension', ext: 'aar')

for example if you have a common.aar file you should put this: 例如,如果你有一个common.aar文件,你应该把它:

compile(name: 'common', ext: 'aar')

make sure in that file that you have this also: 确保在该文件中您还拥有此文件:

allprojects {
   repositories {
      jcenter()

      flatDir {
        dirs 'libs'
      }
   }
}

as the flatDir libs tells android studio to look for libraries there (remember that you copied all your .aar files from unity into the libs folder inside android studio project) 因为flatDir libs告诉android studio在那里寻找库(记得你将所有的.aar文件从unity复制到android studio项目中的libs文件夹中)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM