Import Facebook SDK on Android Studio 0.5.1

夙愿已清 提交于 2019-12-03 00:14:26

The directory structure of your project doesn't match the dependency specs you're using; it's not clear what's in your settings.gradle. That error you get with "Configuration name 'default' not found" is terribly unintuitive, but it's the message you get when Gradle is looking for a module in a certain directory and it's not finding it. If you have a dependency spec (and settings.gradle include) like :libs:facebook, it will look in MyProj/libs/facebook, not MyProj/app/libs/facebook where you've placed it.

I would recommend this structure:

MyProj
 -app
 --build.gradle (1)
 -libs
 --facebook
 ---build.gradle (2)
 -settings.gradle

i.e. move the libs directory one level up so it's alongside app directory instead of underneath it.

Your settings.gradle file should be:

include ':app', ':libs:facebook'

(which is probably how you already have it set up) and a dependency on facebook should look like:

compile project(':libs:facebook')

(also like how you already have it set up)

On Mac with Android Studio 0.5.8, this is what worked for me:

  1. Click on the top level project and select project structure:

  2. Click the + to add another module

  3. Click on "Import Existing Project" and "Next"

  4. Select the facebook directory from your SDK folder and click next

  5. The facebook module should now be shown in addition to your existing module

  6. Click on your project, select the Dependencies tab and click '+' to add a dependency.

  7. Select "Module Dependency" as dependency type.

  8. Select the Facebook module that we just added

  9. Note that it shows up under dependencies (of your app)

And you're all set!

Follow this step to add Facebook SDK to your Android project.

1) Open your fresh Android project 
2) Go to File -> Project Structure (or) Alt+Ctrl+Shift+S
3) Go to module click + on second row of window then import module
4) After Facebook SDK imported click + on third row and select Module Dependency select Facebook SDK Apply and press ok 

I made a Facebook Module version from scratch https://github.com/cesarferreira/Facebook-Module

If you want to use this module for your projects you should follow the next steps:

  • You should create a new 'libs' folder in your project root
  • You should copy this project into the 'libs' folder, you must manually copy the project, because if you copy it using the drag and drop action the project doesn't work because android studio throw an error
  • Add the next line into settings.gradle file: include ':libs:facebook'
  • You should rebuild the project

THAT'S IT!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!