Reputation: 53
Trying to add external library jars to my project, but imports still don't work. Tutorials keep telling me to click "Add as library", but I don't have that option:
But I did add them through Module Settings...
I also added the 2 .jar files to: /src/main/libs/ and added this to build.gradle inside 'app'.
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.1'
compile 'de.hdodenhof:circleimageview:1.3.0'
--> compile files('src/main/libs/jsonbeans-0.5.jar')
--> compile files('src/main/libs/kryo-2.23.1-SNAPSHOT-all-debug.jar')
}
What else can I try to fix this? I don't understand why imports just don't work since the files are included in my build.gradle.
Edit: After changing the directory from /src/main/libs/
to /libs/
directly, nothing changed. Imports still do not work.
Upvotes: 1
Views: 1236
Reputation: 83537
The libs
folder should be a subfolder of app
. Instead you have it buried in app/src/main
. Note that you already have a dependency for the libs
folder if you put it in the correct place.
When you use a file manager or the command line to move files to your Android Studio project, you sometimes need to synchronize the folder structure by right clicking in the Project pane and clicking Synchronize in the popup menu.
Upvotes: 3