2

I have an app which uses a 3rd party library - Simple Facebook - to access the Facebook Graph APIs. This 3rd party library itself internally uses the Facebook SDK as a library.


I have few questions regarding this -

  • Since the library is 3rd party, should it also be included in the APK?
    Scope

    If so, then it gives an error. Scope Exception
    NOTE: Could someone also explain the meaning of Compile, Provided, APK, Test compile, Debug compile and Release compile.

  • My Project structure is like this -
    Part 1
    Part 2
    Part 3

    Is the project structure right or should the Facebook SDK be not included at all.

How do we add source/docs to a library?

We can attach source files/jars to a library jar in eclipse (as shown in this example). This makes it very easy to read the documentation of the imports used. Is there any thing similar to this in Android Studio?

Community
  • 1
  • 1
yadav_vi
  • 1,289
  • 4
  • 16
  • 46

2 Answers2

6

Add source code / docs

There doesn't seem to be a central place in the Project config. What I usually do is that I Ctrl + click on an imported class in the code editor. In case there are no source attached just yet, it displays the Attach Sources.. button on top.

Tomas Zezula
  • 220
  • 4
  • 7
1

If you add the compile fileTree(dir: 'libs', include: ['*.jar']) in your app's build.gradle.

enter image description here

It will compile jar file in the libs folder under the app folder.

enter image description here

So, you need to add simple-facebook-2.2.jar or simple-facebook-1.2.jar in that libs folder.

At this point I think you good to go.

bjiang
  • 6,068
  • 2
  • 22
  • 35
  • After the setup in 'Project Settings' the build.gradle has following entry - `dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:support-v4:21.0.3' compile 'com.android.support:appcompat-v7:21.0.3' apk project(':Simple Facebook') }` However, my doubt is about the 'apk' or 'Compile' or other things that we put in Scope in 'Project Settings'. Also, will this generated jar file be available in the APK? – yadav_vi Mar 06 '15 at 19:52
  • If you `compile the jar`, it will `available in the apk` – bjiang Mar 06 '15 at 19:58
  • To test it again, I deleted the previously generated jar - `simple-facebook-2.2.jar` - in the `libs` folder, changed the scope to 'Compile', now when I build the project, it doesn't show the jar file anymore but it also doesn't give any errors. Am I doing it right? – yadav_vi Mar 06 '15 at 20:14