0

I'm playing around with an Android app from a vendor that our company might be doing business with (so for legal reasons I'll leave out any names). They sent me the source including a compiled .jar library that exposes Android's hidden classes (like android.os.SystemProperties) as well as enables hardware-specific functionality.

I imported their project and the library following this process here, but when trying to build I get,

"error: cannot find symbol method Foo() in class Bar"

for several methods used throughout the code. I inspected the library and found that these methods do indeed exist, so if the library imported successfully (which I assume because there are no errors concerning the hidden classes), why won't it find those variables?

I believe this is an issue of Android Studio looking up the class name "Bar", finding it in the SDK, and stopping there without checking the library .jar because when I right-click on the class in question, and select "Go To Declaration," it takes me to the SDK class, not the library class. Any help is appreciated!

(Potentially) useful info:

  • Android Studio v1.4
  • JRE 1.8.0_60-b27 amd64
  • Gradle v2.2.1 (jcenter repo)
  • Android Plugin Version: 1.3.0
  • Compile SDK: API 19: Android 4.4 (KitKat)
  • Build Tools Version: 23.0.1

EDIT:

I guess I should clarify: The .jar library I have has structure like

+--  library.jar
|    +-- android
|    |    +-- app
|    |    +-- content
|    |    +-- graphics
|    |    |    +-- PixelFormat
...

etc.

Community
  • 1
  • 1

1 Answers1

1

From Android Studio 1.3 prefered way of adding jar/aar libraries is by doing

File -> New -> Module -> Import Jar/Aar Package -> Select your jar, edit name and import

Then File -> Project Structure (Ctr+Alt+Shift+S(win) or CMD+; (mac))

Under your module on cart Dependencies adding module dependency by clicking + -> module dependency -> Imported Module Name Here

Inverce
  • 1,487
  • 13
  • 27
  • Hi Inverce, Thank you for your response, but unfortunately that didn't seem to do the trick :/ The same methods and variables are not found. Any other suggestions? –  Oct 11 '15 at 16:36
  • only suggetion is to check whatever you have proguard (build.gradle : minifyEnabled) turned on and disable it for now, as well as check whatever your jar actually has class files (via any jar lookoup tool :) – Inverce Jan 21 '16 at 11:45