Spectorsky
Spectorsky

Reputation: 667

Cannot refer to imported jar-library in Android Studio project

I have imported an external jar-library find-local-devices.jar into Android Studio project. I've put it into libs folder, right-clicked and chosen Add as library, ensured about dependency in build.gradle, cleaned and built again the project - everything as described, e.g., here. , but I cannot still use the classes from jar:

enter image description here

Could somebody tell me what I do wrong?

Upvotes: 4

Views: 2209

Answers (3)

James Oanta
James Oanta

Reputation: 132

Try "Invalidate Caches and restart" on Android Studio.

enter image description here

EDIT :

Also try deleting you current module and everything referring to it. And add it as the official google documentation is showing you too. The image is from here : https://developer.android.com/studio/projects/android-library.html

Upvotes: 3

Shashidhar Mayannavar
Shashidhar Mayannavar

Reputation: 560

Try another way of importing jar/aar packages into Android studio.

Goto File -> New Module -> import .JAR/.AAR package -> Select file path and say Finish.

Then add this line in Gradle.

compile project(':your_imported_file_name')

Upvotes: 0

Yongho
Yongho

Reputation: 21

compile fileTree(dir: 'libs', include: ['*.jar'])

try this in gradle file and rebuild

Upvotes: 0

Related Questions