PocketSphinx android

322 views
Skip to first unread message

cpw

unread,
Sep 30, 2010, 10:53:41 PM9/30/10
to android-ndk
I m using PocketSphinxAndroidDemo from this link: http://github.com/cjac/cmusphinx/

How to solve this 2 problems since this demo cant install in real
device:

1/2 are showing in logcat,
1) No JNI_OnLoad found in /data/data/edu.cmu.pocketsphinx.demo/lib/
libpocketsphinx_jni.so 0x44c44b90
2) +++ not scanning '/system/lib/libwebcore.so' for........


When i run it, the logcat show:

09-28 18:20:06.360 D/dalvikvm( 1303): Trying to load lib /data/data/
edu.cmu.pocketsphinx.demo/lib/libpocketsphinx_jni.so 0x44c44b90

09-28 18:20:06.371 D/dalvikvm( 1303): Added shared lib /data/data/
edu.cmu.pocketsphinx.demo/lib/libpocketsphinx_jni.so 0x44c44b90

09-28 18:20:06.371 D/dalvikvm( 1303): No JNI_OnLoad found in /data/
data/edu.cmu.pocketsphinx.demo/lib/libpocketsphinx_jni.so 0x44c44b90

09-28 18:20:06.410 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libwebcore.so' for 'setLogfile' (wrong CL)

09-28 18:20:06.410 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libmedia_jni.so' for 'setLogfile' (wrong CL)

09-28 18:20:06.410 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libexif.so' for 'setLogfile' (wrong CL)

09-28 18:20:06.410 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libwebcore.so' for 'new_Config__SWIG_0' (wrong CL)

09-28 18:20:06.410 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libmedia_jni.so' for 'new_Config__SWIG_0' (wrong CL)

09-28 18:20:06.410 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libexif.so' for 'new_Config__SWIG_0' (wrong CL)

09-28 18:20:06.421 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libwebcore.so' for 'Config_setString' (wrong CL)

09-28 18:20:06.421 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libmedia_jni.so' for 'Config_setString' (wrong CL)

09-28 18:20:06.421 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libexif.so' for 'Config_setString' (wrong CL)

09-28 18:20:06.421 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libwebcore.so' for 'Config_setFloat' (wrong CL)

09-28 18:20:06.431 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libmedia_jni.so' for 'Config_setFloat' (wrong CL)

09-28 18:20:06.431 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libexif.so' for 'Config_setFloat' (wrong CL)

09-28 18:20:06.431 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libwebcore.so' for 'Config_setInt' (wrong CL)

09-28 18:20:06.431 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libmedia_jni.so' for 'Config_setInt' (wrong CL)

09-28 18:20:06.431 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libexif.so' for 'Config_setInt' (wrong CL)

09-28 18:20:06.431 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libwebcore.so' for 'Config_setBoolean' (wrong CL)

09-28 18:20:06.431 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libmedia_jni.so' for 'Config_setBoolean' (wrong CL)

09-28 18:20:06.431 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libexif.so' for 'Config_setBoolean' (wrong CL)

09-28 18:20:06.431 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libwebcore.so' for 'new_Decoder__SWIG_1' (wrong CL)

09-28 18:20:06.431 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libmedia_jni.so' for 'new_Decoder__SWIG_1' (wrong CL)

09-28 18:20:06.431 D/dalvikvm( 1303): +++ not scanning '/system/lib/
libexif.so' for 'new_Decoder__SWIG_1' (wrong CL)

09-28 18:20:06.480 I/ActivityManager( 83): Process
edu.cmu.pocketsphinx.demo (pid 1303) has died.

09-28 18:20:06.480 E/ActivityManager( 83): fail to set top app
changed!

09-28 18:20:06.490 D/Sensors ( 83): close_akm, fd=120

09-28 18:20:06.490 D/Zygote ( 56): Process 1303 exited cleanly
(255)

09-28 18:20:06.500 I/UsageStats( 83): Unexpected resume of
com.htc.launcher while already resumed in edu.cmu.pocketsphinx.demo

09-28 18:20:06.530 W/InputManagerService( 83): Window already
focused, ignoring focus gain of:
com.android.internal.view.IInputMethodClient$Stub$Proxy@450a8540

09-28 18:20:06.990 W/Rosie ( 155): mAddHtcWidgetByOtherActivity =
false, mIsOpenSlideWhenLeaveLaunch = true

09-28 18:20:07.090 D/AK8973 ( 61): Compass CLOSE

09-28 18:20:07.450 I/BatteryStatsImpl( 83):
notePhoneSignalStrengthLocked: 3->2

09-28 18:20:07.460 D/BT HS/HF_S( 143): gsmAsuToSignal=7

09-28 18:20:08.820 D/NetworkLocationProvider( 83):
onCellLocationChanged [8101,72155441]

09-28 18:20:10.450 I/BatteryStatsImpl( 83):
notePhoneSignalStrengthLocked: 2->3

09-28 18:20:10.460 D/BT HS/HF_S( 143): gsmAsuToSignal=8

09-28 18:20:16.470 D/BT HS/HF_S( 143): gsmAsuToSignal=11

09-28 18:20:19.460 D/BT HS/HF_S( 143): gsmAsuToSignal=10

09-28 18:20:22.470 D/BT HS/HF_S( 143): gsmAsuToSignal=9

09-28 18:20:25.460 D/BT HS/HF_S( 143): gsmAsuToSignal=8

09-28 18:20:31.450 I/BatteryStatsImpl( 83):
notePhoneSignalStrengthLocked: 3->2

09-28 18:20:31.470 D/BT HS/HF_S( 143): gsmAsuToSignal=7

09-28 18:20:37.450 I/BatteryStatsImpl( 83):
notePhoneSignalStrengthLocked: 2->3

09-28 18:20:37.460 D/BT HS/HF_S( 143): gsmAsuToSignal=8

09-28 18:20:47.630 D/dalvikvm( 143): GC freed 16477 objects / 856552
bytes in 94ms

09-28 18:20:47.640 D/NetworkLocationProvider( 83):
onCellLocationChanged [8101,72155475]

09-28 18:20:49.460 I/BatteryStatsImpl( 83):
notePhoneSignalStrengthLocked: 3->2

09-28 18:20:49.470 D/BT HS/HF_S( 143): gsmAsuToSignal=7

Got anyone here know how to solve this problems? I m appreciate with
your help.


TQ

Tim Mensch

unread,
Oct 1, 2010, 11:35:07 AM10/1/10
to andro...@googlegroups.com
On 9/30/2010 8:53 PM, cpw wrote:
> Got anyone here know how to solve this problems?
The warnings you're seeing are completely benign. Obviously things are
dying:

09-28 18:20:06.480 I/ActivityManager( 83): Process
edu.cmu.pocketsphinx.demo (pid 1303) has died.
09-28 18:20:06.480 E/ActivityManager( 83): fail to set top app changed!
09-28 18:20:06.490 D/Sensors ( 83): close_akm, fd=120
09-28 18:20:06.490 D/Zygote ( 56): Process 1303 exited cleanly (255)

...but whenever I've seen a spontaneous application death like that,
it's been accompanied by a stack trace, which doesn't seem to appear in
your log. :/

If I had to guess, I'd say that something in the JNI is calling exit(),
possibly due to an error condition...or that the main application is
exiting, again possibly due to some kind of failure. Even if it were to
throw a signal or otherwise crash, it should end up with a stack trace.

Does it just exit when you run it? It looks like it does. You might be
stuck throwing in log messages to get an idea of how far it gets before
dying.

Tim

cpw

unread,
Oct 1, 2010, 12:43:09 PM10/1/10
to android-ndk
Thanks for your replied.

I think that is the problem.
Because when i running this program in emulator, when i startup the
program again once return to home, the emulator show black screen.
I need to clicked the icon of the program more than one times than
only the program can start.

In your opinion, which part i need to change? Or i need to create a
button to stop the program?

Thank you.

Tim Mensch

unread,
Oct 1, 2010, 1:08:19 PM10/1/10
to andro...@googlegroups.com
On 10/1/2010 10:43 AM, cpw wrote:

> I think that is the problem. Because when i running this program in
> emulator, when i startup the program again once return to home, the
> emulator show black screen. I need to clicked the icon of the program
> more than one times than only the program can start.


So sometimes it runs correctly, but sometimes it fails? Sounds like the
program isn't handling "onStop/onDestroy" correctly.

Due to the Java-centric nature of Android, it assumes it can reuse an
instance of an executable by simply handing it a new Java object. See
the Activity lifecycle on this page:

http://developer.android.com/reference/android/app/Activity.html

With respect to Java, this may be technically correct, but it's
deceptive, and with respect to the NDK, it's wrong: after "onDestroy"
the application is NOT shut down, it simply goes back to onCreate()
again. So if your NDK code has any static variables, they're still
sitting around.

And it gets worse, actually: The onCreate() can (and tends to) happen
before the onDestroy() from the previous run. I discovered this by
reading Android platform source code, where they were handling that case
internally. So you can't be safe in killing your app in onDestroy(),
because the next instance's onCreate() might have already happened, and
then onDestroy() will destroy the state from the NEW instance that's
trying to start up.

I track the main Java object, and if it changes, I destroy the old state
and ignore any additional JNI calls coming from the old state (like the
inevitable onDestroy() call that would otherwise kill my state). To
compare the Java objects, you should use the JNI call IsSameObject(),
since the pointers aren't guaranteed to be equal (though in fact they
tend to be).

Tim

cpw

unread,
Oct 2, 2010, 10:24:58 AM10/2/10
to android-ndk
Thanks for your replied.

>So sometimes it runs correctly, but sometimes it fails? Sounds like the
>program isn't handling "onStop/onDestroy" correctly.

Yes, the program sometimes will run correctly, sometimes will fails.
But this will happen once i return to home and startup the program
again.

"I track the main Java object, and if it changes, I destroy the old
state
and ignore any additional JNI calls coming from the old state (like
the
inevitable onDestroy() call that would otherwise kill my state). To
compare the Java objects, you should use the JNI call IsSameObject(),
since the pointers aren't guaranteed to be equal (though in fact they
tend to be). "

Tim, i m not understand in this part. What is your meaning?

Izit you mean i need to add onDestroy() in PocketSphinDemo.java?

Or,

I need to change the coding in the following part:

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.rec = new RecognizerTask();
this.rec_thread = new Thread(this.rec);
this.listening = false;
Button b = (Button) findViewById(R.id.Button01);
b.setOnTouchListener(this);
this.performance_text = (TextView)
findViewById(R.id.PerformanceText);
this.edit_text = (EditText) findViewById(R.id.EditText01);
this.rec.setRecognitionListener(this);
this.rec_thread.start();
}

TQ.

Tim Mensch

unread,
Oct 2, 2010, 1:01:10 PM10/2/10
to andro...@googlegroups.com
On 10/2/2010 8:24 AM, cpw wrote:
> "I track the main Java object, and if it changes, I destroy the old
> state and ignore any additional JNI calls coming from the old state (like
> the inevitable onDestroy() call that would otherwise kill my state). To
> compare the Java objects, you should use the JNI call IsSameObject(),
> since the pointers aren't guaranteed to be equal (though in fact they
> tend to be). "
>
> Tim, i m not understand in this part. What is your meaning?
>
> Izit you mean i need to add onDestroy() in PocketSphinDemo.java?
Not necessarily. I don't know anything about your C++ or C code, but if
it has any static initialization that happens in C or C++, you may need
to manually reinitialize it in onCreate(), depending on how the code
works. For instance, if you have a singleton that's created by the C++
library that it attempts to create a second time if it's being run a
second time.

I really can't tell you specifically what you need to do, pretty much at
all. My intent was to let you know of a pitfall that may be biting you.
In particular, TWO different instances of the Java application may
coexist for a short time, and depending on your Java code, may be trying
to access the same C++ code simultaneously (maybe even from different
threads? I don't recall). Look at how your JNI code is bound to Java,
what state it contains, and how it manages that state.

Your objective is to understand what is REALLY going on, and once you
have that understanding, then you'll know whether you need an
onDestroy(), or a flag to prevent a double-initialization in JNI, or
what other change you need to make to fix it. Worst case, pepper the
code with log statements, especially around anywhere there's a call to
"assert" or "exit", directly or indirectly. Track down WHY (or at least
WHERE) it's exiting. Once you understand THAT, you'll have a better
chance of understanding the big picture.

Tim

Reply all
Reply to author
Forward
0 new messages