How do you import Pocketsphinx library in Android Studio 1.5? - android

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:
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:
(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

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".

Related

Android Project Import to Eclipse does not show Project name in Import Projects window but rather 'PTPlayer' - the project is not importing correctly

I have created a game in Buildbox which I've exported to Android. Upon importing this project to Eclipse (Import -> Existing Android Code into Workspace -> Browse for folder) the project does not appear, but rather the directory under 'Project to Import', and 'PTPlayer' under 'New Project Name' (as per this screenshot) which indicates it hasn't imported correctly.
I am aware that I should get two items, one with the 'New Project Name' (something in the format of com.companyname.gamename) as well as a lib item.
Annoyingly I was able to produce the desired output about eighteen months ago using the same procedure, and I have followed various tutorials online without success. Clearly I am doing something wrong here. Any help would be greatly appreciated.
Many thanks
You could use General -> Existing Projects into Workspace instead of the Android -> Existing Android Code into Workspace.
and go to correct location:

Android Studio - project explorer not in correct shape

I don't know if it is the place to ask this question, but i thinks it's more relevant to ask it here than in http://android.stackexchange.com.
The android studio project explorer always is like image below:
But in one of my new projects it became like below:
It's a bit confusing i could not find manifest and other xmls easily.
You are switching between Android project view and Project files view.
There is a menu on top of the tree view to change it.
Example screenshots:
Package view:
Android project view:
Project files view:
Android Studio creates the default structure for your project and
opens the development environment. If your app supports more than one
form factor, Android Studio creates a module folder with complete
source files for each of them .
You should check Projects Overview .You can change its structure by selecting above picture .

Android Exclamatory red mark

I'm very new to Android. Whenever I create a new project using a new workspace, I get an exclamatory red mark in Eclipse in my project and an error at Appcompat. I searched here for an answer, but no answer was what I was looking for, so I just asked this. When I create a workspace at DDMS it displays this:
Sending Tracking request failed!
At Android, after I create a new project
WARNING: unable to write jarlist cache file here, src file, layout file not available.
I've searched a lot and found no solution.
OK, first thing first. Eclipse is no longer supported by Google. The only official IDE for Android Development is Android Studio Download Page.
Here is the announcement of Eclipse support ending
Over the past few years, our team has focused on improving the development experience for building Android apps with Android Studio. Since the launch of Android Studio, we have been impressed with the excitement and positive feedback. As the official Android IDE, Android Studio gives you access to a powerful and comprehensive suite of tools to evolve your app across Android platforms, whether it's on the phone, wrist, car or TV.
To that end and to focus all of our efforts on making Android Studio better and faster, we are ending development and official support for the Android Developer Tools (ADT) in Eclipse at the end of the year. This specifically includes the Eclipse ADT plugin and Android Ant build system.
Please note that the number of people using Eclipse to develop Android apps are going down. You will get less and less support even on Stackoverflow as time goes by. Overall, it is better to just make the switch while you are just starting.
Check on the first link, you will see some amazing documentation in the Android Studio IDE
If you 100% required to use Eclipse...
OK, so you have a job that requires Eclipse or there is some other reason, then check out this documentation by Eclipse.
Also, here is a list of all the different icons that can be displayed by Eclipse (credit for the icon list).
Build path problems are sometimes easy to miss among other problems in a project. The Package Explorer and Project Explorer views now show a new decorator on Java projects and working sets that contain build path errors:
The concrete errors can be seen in the Problems view, and if you open the view menu and select Group By > Java Problem Type, they all show up in the Build Path category:
Please refer this link too here
If you go to appcompat_v7/bin folder, you'll see that file "jarlist.cache" doesn´t appear or is unsynchronized. You need to
refresh the appcompat_v7 folder, only press F5 over that folder.
The appcompat_v7 folder is added because you use an action bar
component.
Aah. To avoid a new appcompat_v7_XX folder when you are creating a new
project, choose a LEVEL API 14 as Minimun Required SDK. After you must
modifier the AndroidManifest.xml and put the level that you need.
change it
android:targetSdkVersion="19" />
Delete all appcompat_v7_XX. It is a bug.
With appcompat_v7, You will see that Eclipse creates two XML files:
Activity_main.xml and fragment_main.xml. If you want to have an option
to create a project in the old way only with activity_main.xml, do
that:
Make a copy of the folder "BlanckActivity" located in this path:
\sdk\tools\templates\activities of an ADT previous version.
Rename the folder as “BlankActivityNoFragment”, then edit the field
name of the file "template.xml" with a notepad as
name=”BlankActivityNoFragment”
Copy the new folder in the same path of the new Eclipse
IDE:sdk/tools/templates/activities
Now you´ll see the new template when you go to create a new project.
Remember to choose as Minimum Required SDK an API 14
If you don't want the support of appcompat library then just remove it from your project by following steps :
Right click on project
Select properties
In dialog select android on left side
In dialog check library section
Remove appcompat library by selecting it and press remove
Extends your MainActivity.java with Activity
You can run your project successfully.
If you want the support of appcompat then follow this steps :
download the latest appcompat using Sdk Manager
import appcompat project in your eclipse
add it as a library project
extend your MainActivity with AppCompatActivity.
If you're getting any problem with app_compact library... This is the solution
Hopefully it will work....
According to the documentation
Decorates Java projects and working sets that contain build path
errors
There can be several reasons. Most of the times it may be some of the below reasons ,
You have deleted some of the .jar files from your /lib folder
You have added new .jar files
you have added new .jar files which may be conflict with others
So what to do is we have to resolve those missing / updating / newly_added jar files.
right click on the project and go to properties
Select Java Build Path
go to the Libraries tab
Remove the references of the jar files which you have removed already. There will be a red mark near them so you can identify them easily.
Add the references to the newly added .jar files by using Add JARs Refresh the project
This will solve the problem if it's because one of the above reasons.
Still Facing problem ??Try this:
Go to Windows -> Preferences -> Android -> Build and uncheck "Skip packaging and dexing until export or launch" then restart Eclipse.

Red exclamation mark over the project in eclipse

I am trying to run a project but there is a red exclamation mark over the project name. When checked in Problems, its throwing an error "project is missing required library". The library is pointed to android.jar located in some path. When checked in package explorer, I found the android.jar in Android 2.3.1 folder structure of project in package explorer. The android.jar located in Android 2.3.1 folder is pointing to some other path. Is the build error occurring due to the difference in paths for android.jar files? I have imported the project.So, how should I modify the path which is shown in the problems window? I am newbie to android and so pls help me.
Thanks!!!
The easiest way to resolve this common problem is to re-associate your project with an SDK version. You do this by opening project properties, clicking on Android, select a different SDK version to that which is currently selected (if one is selected at all), click okay, and then repeat the process to switch back to the desired SDK version, if desired.
I tried Phillip's answer and it didn't work in my case. Another place to look is opening project properties and clicking on "Java Build Path" -- if your project used some external JARs, check to make sure the links haven't been broken. If they have, reimport them again and remove the missing ones.
Import your library through the option: File/ Import... / Android / Existing Android Code Into Workspace, and not by creating a New Project and referencing the other (if you did this way).
I had this same problem and solved that way. As example, there is a PDF which demonstrates how to import other projects [Look at the page 28] (The material are in Portuguese)

How to start an android project with downloaded sample code

I'm pretty new to android, and just finished setup my environment and reading some tutorials. Then I got sdk samples from the web. Okay, what I wanna ask you is that is there a way to start a sample as a project in the Eclipse? I mean like clicking a project file in c# or a solution file.
Here is my folder which I unzipped the code,
\android-sdk-windows\samples\android-8\NotePad
There are three folders and one file in the folder, \res, \src, \tests, and AndroidManifest.xml
Or, do I need to make a new android project and import (or add files? maybe) them?
Thanks in advance,
yokyo
#sgarman
I don't think that's a very good way of doing it. Sadly the 'Create Project from existing sample' feature you describe functions in such a way that when it creates a project from a sample it leaves you editing the source code in the actual SDK sample itself instead of a copy of the source imported into your Eclipse workspace.
This is problematic for a number of reasons including:
Once you've edited the new project you no longer have the original sample to refer to, which is the whole point of the samples in the first place.
If you want to hack a sample in several different ways you will want several copies of the sample, but again once you've edited the original sample you no longer have the original sample to make a copy from.
If the SDK is ever patched then when you update it you may end up overwriting your code.
In short it makes far more sense to treat the SDK as a readonly reference and not treat it as a sandpit in which to do your own messing around. So imo the best way to create an Eclipse project from a sample is do take a copy of the sample and put it somewhere else.
If you want the sample to not exist in your actual Eclipse workspace directory then this is very easy. Just copy the sample to a new location and inside Eclipse with your workspace open do New->Android Project and 'Create Project From Existing Source'.
If on the other hand you want to make the project inside your Eclipse workspace directory then there is a problem which is that if you just copy the sample code inside your workspace folder and do 'New->Android Project' and 'Create Project From Existing Source' for me at least it fails with the error "Invalid project description: c:\Users\usernamme\blah\blah\projectname overlaps the location of another project projectname". I don't know why, if you create a project from sample code using 'New->Java Project' it works just fine so I suspect there is a problem with the Android Project Eclipse plugin that is causing this to fail.
There is a way to get around this which is to first copy the sample code to a temporary location on disk that is outside of the workspace directory. Then use New->Android Project and 'Create Project From Existing Source' which turns the temporary copy of the sample code into a project but leaves it orphaned outside the workspace directory. Then delete the project from the workspace (but without deleting the project from disk). Then use Import->Existing Projects Into Workspace with the 'Copy Projects Into Workspace' checkbox ticked to copy the project into the workspace directory, before finally deleting the project from the temporary location.
But ultimately I decided to structure my workspace in such a way that projects are not inside the workspace folder like this:
Eclipse Workspaces
\
Android Projects
\
Workspace
Project 1
Project 2
Java Projects
\
Workspace
Project 1
Project 2
Other Projects
\
Workspace
Project 1
Project 2
In this layout the Android Projects, Java Projects and Other Projects directories are conceptually my workspaces but in reality in each case it is the nested Workspace folder which is the actual Eclipse workspace. This enables me to keep my projects contained within their respective pseudo-workspaces while not being inside their actual Eclipse workspace folder which neatly gets around the problem of not being able to easily create Android projects if the project directory is inside the Eclipse workspace directory.
Sorry that's all a bit long winded, but it's taken me ages to work out how to get this to work efficiently and I figure it might help someone.
From eclipse go to: File > New >
Project...
Select the Android Folder and pick
Android Project
Then in the Contents section at the
top click the "Create project from
existing sample" radio button. Once
you pick a target from the bottom
the drop down will become selectable
and your good to go.
Copy the downloaded project into your workspace
i.e space allocated for android project
Open the Eclipse
Choose File---> Import ---> Android --> Existing Android code into workspace
Choose Next
Click Browse
choose the foldername (downloaded)
click finish
If you are using ADT 20 then it's quite easy. Select New > Other...>Android Sample Project > [Select the platform from which you would like to pick the sample] > You must see the available samples, select the one you wish to open,you will see that in your workspace.
This may not be a definitive answer because I'm relatively new to Android as well (and come from more of a .Net background too).
When you create a new Workspace in Eclipse, you'll see a new folder created with the name of your workspace and a .metadata folder inside of it. I don't think there's a "workspace file" per se, so you don't double click anything to bring it back up. You just open to that workspace (by telling the Eclipse dialog what path to open).
As far as importing existing projects into a workspace, copy the whole folder into your workspace and click File - Import... - General - Existing Projects into Workspace. Click the Browse button to select the Root directory and it should default to the Workspace's main folder. Click OK and the project should show up in the dialog. Select it and click Finish
The code samples don't come with eclipse project files out of the box. There are a number of ways to create them but the easiest is probably this. From eclipse (with the android plugin installed), File -> New -> Project, Android Project, Next, select the "Create project from existing source" radio button and specify the location of the existing source. The project wizard should then find your manifest and fill out the rest of the information it needs automatically.
http://developer.android.com/samples/index.html
It states here:
"Using Android Studio
Unpack the downloaded project package.
In Android Studio, chose File > Import Project and select the root folder of the unpacked project.
Android Studio may ask you to choose the type of project you are importing. If this is the case, make sure to choose Import project from external model and select the Gradle option."
I hope this helps you.

Categories

Resources