Unity导出Android项目与Facebook SDK问题 [英] Unity exporting android project with Facebook SDK issue

查看:3098
本文介绍了Unity导出Android项目与Facebook SDK问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当涉及到SDK SDK时,我发现将Unity3D项目导出到Android Studio时出现问题。目前我正在使用 Unity 5.4.1f1 facebook-unity-sdk-7.9.0



重现问题的步骤


  1. 创建一个Unity项目并添加 Facebook sdk (导入自定义包等)

  2. 然后从 Facebook>编辑设置的顶部栏上的菜单中进行配置(添加应用ID

  3. 在构建设置中,选择Android平台并编辑播放器预先添加包ID ,并将 min sdk版本设置为15

  4. 保存场景

  5. 尝试构建一个apk,它应该工作

  6. 现在,而不是构建检查Google Android项目'在构建设置中,点击导出

  7. 之后打开 android studio ,然后点击导入项目

  8. 选择您选择的项目名称的文件夹,您可以在导出期间选择的文件夹中找到它从Unity执行程序

  9. 下一步完成

  10. 当成绩完成他的内容并构建时,您会收到错误

  11. <检索项目的父项时发生错误:找不到与给定名称匹配的资源@ style / Theme.AppCompat.NoActionBar的资源错误:




    错误:(136)检索项目的父项时出错:找不到符合给定名称@ style / Theme.AppCompat.Dialog的资源。



    错误:(131)检索项目的父项时出错:找不到与给定名称匹配的资源@ style / Theme.AppCompat.NoActionBar。



    错误:(136)检索项目的父项时出错:找不到符合给定名称@ style / Theme.AppCompat.Dialog的资源。



    错误:执行失败的任务':facebookandroidsdk4170:processDebugResources'。
    com.android.ide.common.process.ProcessException:无法执行aapt


    有人做了这个,已经有找到一个解决方案?

    解决方案

    似乎你错过了appcompat库,导出到android studio的问题是它没有' t导出.aar文件(至少在Unity 5.5之前)。



    您必须将所有.aar文件复制到您的插件/ Android中(也可能在然后打开你的应用程序build.gradle(通常命名的应用程序或与你的项目的名称一样),并将它放在依赖关系中对于每个.aar文件:

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

    例如,如果你有一个common.aar文件,你应该这样说:



    编译(名称:'common',ext:'aar')

    确保在该文件中您也有这个:

      allprojects {
    存储库{
    jcenter()

    flatDir {
    dirs'libs'
    }
    }
    }

    as flatDir libs告诉android studio在那里寻找库(记住,你将所有.aar文件从unity复制到libs文件夹里面的android studio project)


    I found an issue on exporting a project from Unity3D to Android Studio when Facebook SDK is involved. Currently I'm using Unity 5.4.1f1 and facebook-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)
    2. Then configure it from the menu on the top bar under Facebook > Edit settings (it's enough adding the app id)
    3. In build settings select Android platform and edit player prefs adding a bundle id and setting min sdk version to 15
    4. Save the scene
    5. Try to build an apk, it should work
    6. Now instead of building check 'Google Android project' in build setting and click export
    7. After that open android studio and click on import project
    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
    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'.

    Error:(136) Error retrieving parent for item: No resource found that matches the given name '@style/Theme.AppCompat.Dialog'.

    Error:(131) Error retrieving parent for item: No resource found that matches the given name '@style/Theme.AppCompat.NoActionBar'.

    Error:(136) Error retrieving parent for item: No resource found that matches the given name '@style/Theme.AppCompat.Dialog'.

    Error:Execution failed for task ':facebookandroidsdk4170:processDebugResources'. com.android.ide.common.process.ProcessException: Failed to execute 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).

    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.

    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:

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

    for example if you have a common.aar file you should put this:

    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)

    这篇关于Unity导出Android项目与Facebook SDK问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆