1

I have my Android Studio project structured as follow:

/mysdk
  -manifests
  -java
     -com.xxx.sdk
     -ext-libs
       -com.yyy.lib (not .jar but .java files instead)
  -res
/app
 -manifests
 -java
 -res

I can include com.yyy.lib.* inisde com.xxx.sdk and reference all the methods without any symbol resolution problem in Eclipse project.

But after I transfer my IDE from Eclipse to Android Studio and it tells me it cannot resolve the symbols/methods from com.yyy.lib inside com.xx.sdk (ex: com.xxx.sdk.Activty.java)

How can I fix this dependency problem in Android studio?

Owen
  • 55
  • 8
  • Can you share the full file view, instead of the Android project view, that might help a little. It could be that your configuration differs from gradle convention and is not picking up `com.yyy.lib` as part of your sources. – loosebazooka May 14 '15 at 19:27
  • I think you also need to make it clear that `com.yyy.lib` are source files that NEED to be compiled with your `mysdk` project. The answers you're getting are explaining how to get a pre-compiled library (as a jar) into your project. – loosebazooka May 14 '15 at 19:50

3 Answers3

1

That's because Android Studio uses Gradle as its dependency manager, whereas Eclipse uses either Maven or Ant.

You can read more about managing dependencies with Gradle, here.

This answer explains how to add a dependency/library to Gradle in Android Studio.

Community
  • 1
  • 1
D. Visser
  • 875
  • 2
  • 12
  • 19
1

In your project file browser:
enter image description here
Go to libs folder. and add your library if not present
enter image description here

and then in gradle: add
compile files('libs/your_library')
in dependencies and then Sync Gradle

mongiabrothers
  • 375
  • 3
  • 9
1

If you have no strong preference for the location of com.yyy.lib, just moving it into the parent (is it src/main/java? based on gradle convention) it will probably get picked up.

It appears the IDE is treating src/main/java (or whatever) as a source folder and your package paths aren't matching up with your directory structure

ext-libs.com.yyy.lib instead of com.yyy.lib

loosebazooka
  • 2,363
  • 1
  • 21
  • 32