Get the Tools
First problem is the Android development tool. The Gstreamer-Android library is a NDK pre-built library. However as of today the official development tool for Android is Android Studio, which have no support on NDK. I know some Android developers had done great job to make NDK works on Android Studio, but I found that is out of my hand. So I choose the old tool "ADT for Eclipse". I just grabbed the latest version of Eclipse for Java Development (Luna release 2). And installed ADT plugin as instructed on here. This is just the beginning.
Second tool you'll need is the NDK. The latest version today is NDK-r10d. You just need to download it and extract it somewhere in you hard drive. And, once you started a new work space with Eclipse, remember you need to set the path of NDK in the Eclipse preference (Perference > Android > NDK).
Also you'll need the Gstreamer-Android library. You should get it from here. Note that the library is a pre-built native library so you need to choose the CPU architecture. The site do provide ARM, ARMv7 and x86 for you to choose from. To start with, get the ARM debug version first.
Get the Tutorial Source
There are two main stream versions of Gstreamer: 0.10 and 1.0. Actually the latest version as of today is 1.4.5. The old version was better documented, but you can't make 1.0 version works for you by just reading those old document. The development team had published 5 Gstreamer-Android tutorial programs. With detail document that provide section-by-section explanation. However, in the website for 1.0 you cannot find any tutorial code. Finally I found this, which is great work done by slomo who ported the 0.10 tutorial code to work under 1.0 API. Just use git clone to copy the tutorial code to your own hard disk.
Build the Tutorial Projects
You can easily find the 5 Android Tutorial projects in the tutorial source. Use "New > Project" command. Then choose "New Android Project from existing code". Browse to one of the 5 folders for the tutorials. And I recommend to have Eclipse copy the files into your work space.
Here come all the tricky parts. There are still many small changes you need to make before you can make it work.
1. Define Environment String
Actually you only need to define GSTREAMER_ROOT_ANDROID. Define it in the project's preference. Under "C / C++ Build > Environment". It should points to the root of your Gstreamer-Android API library.
2. Add Some Magic in Android.mk
At this point if you try to build the project. Eclipse will hang at certain point. And you don't get any error or hint. Google bought me the solution. Do two things:
- Add the line "ifdef BUILD_PROJECT" at the beginning of Android.mk under the jni folder in your project. And add the line "endif" at the bottom.
- Open the project's preference. Under "C / C++ Build", un-check "Use default build command". And add "BUILD_PROJECT=1" to the build command
3. Define Path and Symbol
In the project's preference, go to "C/C++ General > Paths and Symbols". Here you need to add all directories that contain all the header files that your C code need. They would be come from the NDK (<ndk root>/platforms/android-xx/arch-arm/usr/include) and GStreamer (<gstreamer-android api root>/include/<library name>). Without this even you can build your project successfully, the project will not run in the simulator as Eclipse still find "error" in the C editor.
4. Define NULL Symbol
Even with all above, you will still find one type of fault in the C editor. The editor cannot resolve the symbol "NULL". I don't know why it is not in any included header files. I think maybe the reason is I'm doing this on Windows. So I added it by putting these 3 lines under the include statements of the C code:
#ifndef NULL
#define NULL ((void *) 0)
#endif
After all these. Try to run your project as an Android Application. If everything is fine, you'll get a working tutorial app.
It is really a pain to do so many Google and troubleshoot all the problems one by one. I'm still wondering why I can't find a single instruction page or forum thread that give me all solution. Hope this can help you.
8 comments:
Thanks for finding out some of those quirks. Was definitely banging my head against the wall with studio. Just wanted to add the following for Tutorial 2. Add the following line in tuutorial-2.c: #include and be sure to include the library path.
I'm still looking forward some other Android guru who will share a version of those tutorials that will work under Android studio.
Thank u so very much for posting such a wonderful Info.
ea sports cricket games | Schedule for IPL 2016 App
Thank you so much for this great post on working with Java. Your tips have helped me make some progress. I often find that when I'm working on a sticky issue it is very difficult to find good tutorials. Thank you for walking through some of the steps here. I'm pretty new at using Android Studio in my work and free time.
Nathan @ Emyoli
Thanks. It's been a while since I wrote this. What version of NDK and gstreamer are you using? Does he new version fix some of the issues, or bring more new issues?
Great Article
Android Final Year Project Ideas for Computer Science
Project Centers in Chennai
Your topic is very nice and helpful to us … Thank you for the information you wrote.
Learn Hadoop Training from the Industry Experts we bridge the gap between the need of the industry. Bangalore Training Academy provide the Best Hadoop Training in Bangalore with 100% Placement Assistance. Book a Free Demo Today.
Big Data Analytics Training in Bangalore
Tableau Training in Bangalore
Data Science Training in Bangalore
Workday Training in Bangalore
Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site.
sap hana courses in bangalore
sap hana classes in bangalore
sap hana training institute in bangalore
sap hana course syllabus
best sap hana training
sap hana training centers
best sap hana training
Post a Comment