problem in running an backend application from android application using android NDK

61 views
Skip to first unread message

Arun

unread,
Sep 7, 2009, 10:04:29 AM9/7/09
to android-ndk, achoudh...@gmail.com, arun...@rediffmail.com
Hi All,


I am trying to run an application "ushare" which is found at "system/
bin" in android filesystem through an UI application written using
android NDK.

This application works fine when run by command line in file system.

but when i run the same application using Android UI. it fails

respective code to call the application in NDK is

jstring Java_com_Android_uShare_uShare_RunuShare()
{
jboolean iscopy;
if(system("/system/bin/ushare"))
{
printf("\nExec failed\n\n");
return (*env)->NewStringUTF(env, "exec failed !!!!!!!!!!!!!!");
}
else
{
return (*env)->NewStringUTF(env, "uShare is running successfully");
}

}
}

2. respective code calling this api in application
tview.setText(RunuShare());


Please guide me on the same.

eror log ::

I/ActivityManager( 582): Starting activity: Intent
{ action=android.intent.action.MAIN categories=
{android.intent.category.LAUNCHER} flags=0x10200000 comp=
{com.Android.uShare/com.Android.uShare.uShare} }
I/ActivityManager( 582): Start proc com.Android.uShare for activity
com.Android.uShare/.uShare: pid=763 uid=10029 gids={}
I/jdwp ( 763): received file descriptor 10 from ADB
D/dalvikvm( 763): Trying to load lib /data/data/com.Android.uShare/
lib/libuShare.so 0x437341b0
D/dalvikvm( 763): Added shared lib /data/data/com.Android.uShare/lib/
libuShare.so 0x437341b0
D/dalvikvm( 763): No JNI_OnLoad found in /data/data/
com.Android.uShare/lib/libuShare.so 0x437341b0
W/IInputConnectionWrapper( 624): showStatusIcon on inactive
InputConnection
I/ActivityManager( 582): Displayed activity
com.Android.uShare/.uShare: 1799 ms
W/KeyCharacterMap( 763): No keyboard for id 0
W/KeyCharacterMap( 763): Using default keymap: /system/usr/keychars/
qwerty.kcm.bin
D/dalvikvm( 582): GC freed 10301 objects / 547816 bytes in 207ms
D/dalvikvm( 763): +++ not scanning '/system/lib/libwebcore.so' for
'RunuShare' (wrong CL)
D/dalvikvm( 763): +++ not scanning '/system/lib/libmedia_jni.so' for
'RunuShare' (wrong CL)
I/DEBUG ( 551): *** *** *** *** *** *** *** *** *** *** *** *** ***
*** *** ***
I/DEBUG ( 551): Build fingerprint: 'generic/google_sdk/generic/:1.5/
CUPCAKE/148875:eng/test-keys'
I/DEBUG ( 551): pid: 763, tid: 763 >>> com.Android.uShare <<<
I/DEBUG ( 551): signal 7 (SIGBUS), fault addr 00000000
I/DEBUG ( 551): r0 00000302 r1 40014e10 r2 00033588 r3 0000060c
I/DEBUG ( 551): r4 41db1054 r5 410499a0 r6 becfc5e0 r7 ad00e540
I/DEBUG ( 551): r8 00000020 r9 00000000 10 41049990 fp 00000000
I/DEBUG ( 551): ip 00000020 sp becfc5a0 lr ad01236c pc
ad00ed40 cpsr 20000010
I/DEBUG ( 551): #00 pc 0000ed40 /system/lib/libdvm.so
I/DEBUG ( 551): #01 pc 00017b1c /system/lib/libdvm.so
I/DEBUG ( 551): #02 pc 00017560 /system/lib/libdvm.so
I/DEBUG ( 551): #03 pc 00052268 /system/lib/libdvm.so
I/DEBUG ( 551): #04 pc 000596ee /system/lib/libdvm.so
I/DEBUG ( 551): #05 pc 00013118 /system/lib/libdvm.so
I/DEBUG ( 551): #06 pc 00017b1c /system/lib/libdvm.so
I/DEBUG ( 551): #07 pc 00017560 /system/lib/libdvm.so
I/DEBUG ( 551): #08 pc 000520ec /system/lib/libdvm.so
I/DEBUG ( 551): #09 pc 0003f0f8 /system/lib/libdvm.so
I/DEBUG ( 551): #10 pc 00031ac2 /system/lib/libdvm.so
I/DEBUG ( 551): #11 pc 00028280 /system/lib/
libandroid_runtime.so
I/DEBUG ( 551): #12 pc 00028d7e /system/lib/
libandroid_runtime.so
I/DEBUG ( 551): #13 pc 00008bf2 /system/bin/app_process
I/DEBUG ( 551): #14 pc 0001fd22 /system/lib/libc.so
I/DEBUG ( 551): #15 pc 0000bcb2 /system/lib/libc.so
I/DEBUG ( 551): #16 pc b000157e /system/bin/linker
I/DEBUG ( 551): stack:
I/DEBUG ( 551): becfc560 4124cfb0
I/DEBUG ( 551): becfc564 43737140
I/DEBUG ( 551): becfc568 ad083e10
I/DEBUG ( 551): becfc56c ad042deb /system/lib/libdvm.so
I/DEBUG ( 551): becfc570 4000c708
I/DEBUG ( 551): becfc574 ad083e10
I/DEBUG ( 551): becfc578 0000bc60 [heap]
I/DEBUG ( 551): becfc57c becfc5e8 [stack]
I/DEBUG ( 551): becfc580 41049a2c
I/DEBUG ( 551): becfc584 00000000
I/DEBUG ( 551): becfc588 00000000
I/DEBUG ( 551): becfc58c 41046858
I/DEBUG ( 551): becfc590 41049a60
I/DEBUG ( 551): becfc594 becfc5e0 [stack]
I/DEBUG ( 551): becfc598 df002777
I/DEBUG ( 551): becfc59c e3a070ad
I/DEBUG ( 551): #00 becfc5a0 43730360
I/DEBUG ( 551): becfc5a4 41048200
I/DEBUG ( 551): becfc5a8 becfc5e0 [stack]
I/DEBUG ( 551): becfc5ac ad017ac4 /system/lib/libdvm.so
I/DEBUG ( 551): becfc5b0 00000328
I/DEBUG ( 551): becfc5b4 becfc668 [stack]
I/DEBUG ( 551): becfc5b8 0000bc60 [heap]
I/DEBUG ( 551): becfc5bc 41049f04
I/DEBUG ( 551): becfc5c0 00000000
I/DEBUG ( 551): becfc5c4 ad017b20 /system/lib/libdvm.so
I/DEBUG ( 551): #01 becfc5c8 400307a0
I/DEBUG ( 551): becfc5cc 00000001
I/DEBUG ( 551): becfc5d0 0000bc60 [heap]
I/DEBUG ( 551): becfc5d4 ad017564 /system/lib/libdvm.so
D/dalvikvm( 624): GC freed 216 objects / 10528 bytes in 230ms
D/Zygote ( 553): Process 763 terminated by signal (7)
I/DEBUG ( 551): *** *** *** *** *** *** *** *** *** *** *** *** ***
*** *** ***
I/DEBUG ( 551): Build fingerprint: 'generic/google_sdk/generic/:1.5/
CUPCAKE/148875:eng/test-keys'
I/DEBUG ( 551): pid: 770, tid: 770 >>> com.Android.uShare <<<
I/DEBUG ( 551): signal 11 (SIGSEGV), fault addr 445a9028
I/DEBUG ( 551): r0 00141778 r1 00000000 r2 00000004 r3 445a9028
I/DEBUG ( 551): r4 becfc570 r5 00000004 r6 ad337829 r7 41049dc0
I/DEBUG ( 551): r8 becfc550 r9 41049db8 10 41049da4 fp 00000000
I/DEBUG ( 551): ip ad35b918 sp becfc544 lr ad337839 pc
a9d31bcc cpsr 60000030
I/DEBUG ( 551): #00 pc 00031bcc /system/lib/libutils.so
I/DEBUG ( 551): #01 pc 00037834 /system/lib/
libandroid_runtime.so
I/DEBUG ( 551): #02 pc 0000e3b4 /system/lib/libdvm.so
I/DEBUG ( 551): #03 pc 00040a8a /system/lib/libdvm.so
I/DEBUG ( 551): #04 pc 00013118 /system/lib/libdvm.so
I/DEBUG ( 551): #05 pc 00017b1c /system/lib/libdvm.so
I/DEBUG ( 551): #06 pc 00017560 /system/lib/libdvm.so
I/DEBUG ( 551): #07 pc 00052268 /system/lib/libdvm.so
I/DEBUG ( 551): #08 pc 000596ee /system/lib/libdvm.so
I/DEBUG ( 551): #09 pc 00013118 /system/lib/libdvm.so
I/DEBUG ( 551): #10 pc 00017b1c /system/lib/libdvm.so
I/DEBUG ( 551): #11 pc 00017560 /system/lib/libdvm.so
I/DEBUG ( 551): #12 pc 000520ec /system/lib/libdvm.so
I/DEBUG ( 551): #13 pc 0003f0f8 /system/lib/libdvm.so
I/DEBUG ( 551): #14 pc 00031ac2 /system/lib/libdvm.so
I/DEBUG ( 551): #15 pc 00028280 /system/lib/
libandroid_runtime.so
I/DEBUG ( 551): #16 pc 00028d7e /system/lib/
libandroid_runtime.so
I/DEBUG ( 551): #17 pc 00008bf2 /system/bin/app_process
I/DEBUG ( 551): #18 pc 0001fd22 /system/lib/libc.so
I/DEBUG ( 551): #19 pc 0000bcb2 /system/lib/libc.so
I/DEBUG ( 551): #20 pc b000157e /system/bin/linker
I/DEBUG ( 551): stack:
I/DEBUG ( 551): becfc504 ad03dcd9 /system/lib/libdvm.so
I/DEBUG ( 551): becfc508 0000a9d0 [heap]
I/DEBUG ( 551): becfc50c ad030031 /system/lib/libdvm.so
I/DEBUG ( 551): becfc510 0000a9d0 [heap]
I/DEBUG ( 551): becfc514 00141778 [heap]
I/DEBUG ( 551): becfc518 001417b0 [heap]
I/DEBUG ( 551): becfc51c 4108c0e8
I/DEBUG ( 551): becfc520 00000000
I/DEBUG ( 551): becfc524 0000a9d0 [heap]
I/DEBUG ( 551): becfc528 ad35ad30
I/DEBUG ( 551): becfc52c 43732858
I/DEBUG ( 551): becfc530 41049dc0
I/DEBUG ( 551): becfc534 ad33765d /system/lib/
libandroid_runtime.so
I/DEBUG ( 551): becfc538 df002777
I/DEBUG ( 551): becfc53c e3a070ad
I/DEBUG ( 551): becfc540 ad337829 /system/lib/
libandroid_runtime.so
I/DEBUG ( 551): #00 becfc544 ad337839 /system/lib/
libandroid_runtime.so
I/DEBUG ( 551): #01 becfc548 43732858
I/DEBUG ( 551): becfc54c ad00e3b8 /system/lib/libdvm.so
I/ActivityManager( 582): Process com.Android.uShare (pid 763) has
died.
I/WindowManager( 582): WIN DEATH: Window{43751510 com.Android.uShare/
com.Android.uShare.uShare paused=false}
W/InputManagerService( 582): Got RemoteException sending setActive
(false) notification to pid 763 uid 10029


Dianne Hackborn

unread,
Sep 7, 2009, 2:45:44 PM9/7/09
to andro...@googlegroups.com, achoudh...@gmail.com, arun...@rediffmail.com
There us no "ushare" that is part of the platform, afaik, and the shell commands are not part of the SDK/NDK, so this would probably be best posted to android-porting (since presumably you are not writing a third party app but working on the platform).

For the crash, you can decode the raw stack to symbols with I think stack_dump...  unfortunately I don't know off-hand how to do this in the public tree, there is another tool I use that doesn't seem to be part of it.
--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

arun choudhary

unread,
Sep 8, 2009, 12:38:55 AM9/8/09
to Dianne Hackborn, andro...@googlegroups.com, arun...@rediffmail.com
Thanks for reply

Actually i have got a third party application "ushare" . which works fine if its is run by shell.
but if I try to run it by UI Application written in NDK as explained it gives error.
--

wish u all the best

arun choudhary

unread,
Sep 9, 2009, 12:32:33 AM9/9/09
to Dianne Hackborn, andro...@googlegroups.com, arun...@rediffmail.com
Elaborating a little more

I have ported ushare and upnp for Android. and I want to run this using an front end android application.

So I wrote the app using Android NDK:
in which Source part contains source code for shared lib

jstring Java_com_Android_uShare_
uShare_RunuShare(JNIEnv *env, jobject jobj)
{

if (execl("/system/bin/ushare","ushare",(char*)0) < 0)


        {
           fprintf(stderr,"\nExec failed\n\n");

 return (*env)->NewStringUTF(env, "exec failed !!!!!!!!!!!!!!");
}
else
{

return (*env)->NewStringUTF(env, "uShare is running successfully");
}          

and application part contains ::

package com.Android.uShare;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import android.widget.TextView;
import java.io.*;
public class uShare extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
       
     
        final Button btnOk;
        final TextView tview;
     
   
              class  clicker implements Button.OnClickListener
        {             

        public void onClick(View v)
        {
                       
          
            tview.setText(RunuShare());
         

        }

        }
        btnOk.setOnClickListener(new clicker());
        }
    static
    {
     System.loadLibrary("uShare");
    
    }
 
      public native String RunuShare();
 
   
}

when I run it on emulator it crashes and throw exception

Even i tried it for other binaries found in /system/bin it shows same behaviour for all binaries
So probbaly this issue is related to permission. since all binaries have permission (owner  root and gropu shell) while app has user app

please guide me on the same.

Is there any other constraint as well

Please guide me on same.

Regards,
Arun
Reply all
Reply to author
Forward
0 new messages