androidandroid-studiopocketsphinxandroid-studio-importpocketsphinx-android

How do you import Pocketsphinx library in Android Studio 1.5?


I'm trying to import PocketSphinx into a project using Android Studio 1.5. This page details how to install and use the library. However I stumble at the following step:

In Android Studio you need to place jar file in app/libs folder and jni .so files into app/src/main/jniLibs folder.

My project directory tree does not contain these directories and I have been unable to create them myself. This is my directory tree:

Directory tree

That webpage also provides a sample android studio project, which works just fine, but I think it is designed for an older version of android studio because the directory structure is totally different to any app I've seen before (While I do have some years of coding experience in other areas, I only started developing android apps in the last 2 or 3 months). This is what it's directory tree looks like: Directory Tree 2

(I haven't expanded the entire tree this time)

One last thing: I tried to import the library (as available for download here) by using "File -> New -> Import Module" But doing this breaks the project (and it can't be fixed by simply clicking "undo"). The error message I get is:

V:\Documents\ButterflyMilk\SpeechRecDemo\pocketsphinx-android-master\build.gradle

Error:(7, 0) Could not find property 'sdkDir' on org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@606a97f. Open File

and at the top of the code view it now permanently says:

Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly.

Thanks in advance for any help and advice you can offer! I will also quickly note again that the sample program provided works just fine, and I've managed to tweak it and play around with it. However I still need to be able to import the library into a separate project. Thanks again


Solution

  • My project directory tree does not contain these directories and I have been unable to create them myself. This is my directory tree:

    This is "Android" view.

    This is what it's directory tree looks like

    This is "Project" view. You can switch between views with a dropdown selector on the top of the region (it says "Project" in second screenshot)

    I have been unable to create them myself.

    You can create folders in file manager.

    You can also use IDE, right click on the app, then select "New" -> "Folder (green in the bottom)" -> "JNI Folder" for example.

    You can also use "New" -> "Directory".