Hey Developers im working on this for several days and I have no clue what the problem is:
Ok first, what I want to do. I have an app (the service) that includes a native method, which needs a lot of time. And I have another app (the activity) which shows the results of this method. For the communication between them I used IPC, like it is explained in the book I use (Android 2, it is german...: ( ). I tested it in one project where the service is in a separate process and it worked. But when I start with two separate applications I got the following errors in logcat: 08-05 09:17:16.399: DEBUG/AndroidRuntime(4736): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<< 08-05 09:17:16.409: DEBUG/AndroidRuntime(4736): CheckJNI is ON 08-05 09:17:16.730: DEBUG/AndroidRuntime(4736): --- registering native functions --- 08-05 09:17:18.289: DEBUG/dalvikvm(254): GC_EXPLICIT freed 161 objects / 11384 bytes in 103ms 08-05 09:17:18.359: DEBUG/PackageParser(87): Scanning package: /data/ app/vmdl53892.tmp 08-05 09:17:18.509: INFO/PackageManager(87): Removing non-system package:test.versuch.fuenf.service 08-05 09:17:18.509: INFO/ActivityManager(87): Force stopping package test.versuch.fuenf.service uid=10029 08-05 09:17:18.720: DEBUG/PackageManager(87): Scanning package test.versuch.fuenf.service 08-05 09:17:18.720: INFO/PackageManager(87): Package test.versuch.fuenf.service codePath changed from /data/app/ test.versuch.fuenf.service-1.apk to /data/app/ test.versuch.fuenf.service-2.apk; Retaining data and using new 08-05 09:17:18.740: INFO/PackageManager(87): /data/app/ test.versuch.fuenf.service-2.apk changed; unpacking 08-05 09:17:18.770: DEBUG/installd(34): DexInv: --- BEGIN '/data/app/ test.versuch.fuenf.service-2.apk' --- 08-05 09:17:19.049: DEBUG/dalvikvm(4745): DexOpt: load 40ms, verify 31ms, opt 4ms 08-05 09:17:19.070: DEBUG/installd(34): DexInv: --- END '/data/app/ test.versuch.fuenf.service-2.apk' (success) --- 08-05 09:17:19.070: WARN/PackageManager(87): Code path for pkg : test.versuch.fuenf.service changing from /data/app/ test.versuch.fuenf.service-1.apk to /data/app/ test.versuch.fuenf.service-2.apk 08-05 09:17:19.070: WARN/PackageManager(87): Resource path for pkg : test.versuch.fuenf.service changing from /data/app/ test.versuch.fuenf.service-1.apk to /data/app/ test.versuch.fuenf.service-2.apk 08-05 09:17:19.079: DEBUG/PackageManager(87): Services: test.versuch.fuenf.service.mittwochnachtservice 08-05 09:17:19.089: INFO/ActivityManager(87): Force stopping package test.versuch.fuenf.service uid=10029 08-05 09:17:19.369: INFO/installd(34): move /data/dalvik-cache/ d...@app@test.versuch.fuenf.service-2....@classes.dex -> /data/dalvik- cache/d...@app@test.versuch.fuenf.service-2....@classes.dex 08-05 09:17:19.369: DEBUG/PackageManager(87): New package installed in /data/app/test.versuch.fuenf.service-2.apk 08-05 09:17:19.669: INFO/ActivityManager(87): Force stopping package test.versuch.fuenf.service uid=10029 08-05 09:17:19.930: WARN/RecognitionManagerService(87): no available voice recognition services found 08-05 09:17:20.209: DEBUG/dalvikvm(87): GC_EXPLICIT freed 6368 objects / 454216 bytes in 148ms 08-05 09:17:20.309: INFO/installd(34): unlink /data/dalvik-cache/ d...@app@test.versuch.fuenf.service-1....@classes.dex 08-05 09:17:20.319: DEBUG/AndroidRuntime(4736): Shutting down VM 08-05 09:17:20.352: DEBUG/dalvikvm(4736): Debugger has detached; object registry had 1 entries 08-05 09:17:20.379: INFO/AndroidRuntime(4736): NOTE: attach of thread 'Binder Thread #3' failed 08-05 09:17:21.329: DEBUG/AndroidRuntime(4750): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<< 08-05 09:17:21.329: DEBUG/AndroidRuntime(4750): CheckJNI is ON 08-05 09:17:21.650: DEBUG/AndroidRuntime(4750): --- registering native functions --- 08-05 09:17:22.990: INFO/ActivityManager(87): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=test.versuch.fuenf/.mittwochnacht } 08-05 09:17:23.149: DEBUG/AndroidRuntime(4750): Shutting down VM 08-05 09:17:23.199: DEBUG/dalvikvm(4750): Debugger has detached; object registry had 1 entries 08-05 09:17:23.219: INFO/ActivityManager(87): Start proc test.versuch.fuenf for activity test.versuch.fuenf/.mittwochnacht: pid=4758 uid=10030 gids={} 08-05 09:17:23.269: INFO/AndroidRuntime(4750): NOTE: attach of thread 'Binder Thread #3' failed 08-05 09:17:24.199: WARN/dalvikvm(4758): Unable to resolve superclass of Ltest/versuch/fuenf/mittwochnacht$2; (29) 08-05 09:17:24.199: WARN/dalvikvm(4758): Link of class 'Ltest/versuch/ fuenf/mittwochnacht$2;' failed 08-05 09:17:24.209: ERROR/dalvikvm(4758): Could not find class 'test.versuch.fuenf.mittwochnacht$2', referenced from method test.versuch.fuenf.mittwochnacht.<init> 08-05 09:17:24.209: WARN/dalvikvm(4758): VFY: unable to resolve new- instance 27 (Ltest/versuch/fuenf/mittwochnacht$2;) in Ltest/versuch/ fuenf/mittwochnacht; 08-05 09:17:24.219: DEBUG/dalvikvm(4758): VFY: replacing opcode 0x22 at 0x000a 08-05 09:17:24.229: DEBUG/dalvikvm(4758): VFY: dead code 0x000c-0011 in Ltest/versuch/fuenf/mittwochnacht;.<init> ()V 08-05 09:17:24.229: WARN/dalvikvm(4758): VFY: unable to find class referenced in signature (Ltest/versuch/fuenf/service/IServiceRemote;) 08-05 09:17:24.249: WARN/dalvikvm(4758): VFY: unable to find class referenced in signature (Ltest/versuch/fuenf/service/IServiceRemote;) 08-05 09:17:24.249: WARN/dalvikvm(4758): VFY: unable to find class referenced in signature (Ltest/versuch/fuenf/service/ IServiceCallback;) 08-05 09:17:24.259: INFO/dalvikvm(4758): Could not find method test.versuch.fuenf.service.IServiceRemote.getnativeStringAsynchron, referenced from method test.versuch.fuenf.mittwochnacht.onClick 08-05 09:17:24.259: WARN/dalvikvm(4758): VFY: unable to resolve interface method 33: Ltest/versuch/fuenf/service/ IServiceRemote;.getnativeStringAsynchron ()V 08-05 09:17:24.270: DEBUG/dalvikvm(4758): VFY: replacing opcode 0x72 at 0x0022 08-05 09:17:24.279: INFO/dalvikvm(4758): Could not find method test.versuch.fuenf.service.IServiceRemote.getnativeString, referenced from method test.versuch.fuenf.mittwochnacht.onClick 08-05 09:17:24.289: WARN/dalvikvm(4758): VFY: unable to resolve interface method 32: Ltest/versuch/fuenf/service/ IServiceRemote;.getnativeString ()Ljava/lang/String; 08-05 09:17:24.299: DEBUG/dalvikvm(4758): VFY: replacing opcode 0x72 at 0x004e 08-05 09:17:24.299: DEBUG/dalvikvm(4758): VFY: dead code 0x0051-0054 in Ltest/versuch/fuenf/mittwochnacht;.onClick (Landroid/view/View;)V 08-05 09:17:24.309: INFO/dalvikvm(4758): Could not find method test.versuch.fuenf.service.IServiceRemote$Stub.asInterface, referenced from method test.versuch.fuenf.mittwochnacht$1.onServiceConnected 08-05 09:17:24.309: WARN/dalvikvm(4758): VFY: unable to resolve static method 31: Ltest/versuch/fuenf/service/IServiceRemote $Stub;.asInterface (Landroid/os/IBinder;)Ltest/versuch/fuenf/service/ IServiceRemote; 08-05 09:17:24.321: DEBUG/dalvikvm(4758): VFY: replacing opcode 0x71 at 0x000b 08-05 09:17:24.329: DEBUG/dalvikvm(4758): VFY: dead code 0x000e-002a in Ltest/versuch/fuenf/mittwochnacht$1;.onServiceConnected (Landroid/ content/ComponentName;Landroid/os/IBinder;)V 08-05 09:17:24.339: WARN/dalvikvm(4758): VFY: unable to find class referenced in signature (Ltest/versuch/fuenf/service/IServiceRemote;) 08-05 09:17:24.339: WARN/dalvikvm(4758): VFY: unable to find class referenced in signature (Ltest/versuch/fuenf/service/ IServiceCallback;) 08-05 09:17:24.349: INFO/dalvikvm(4758): Could not find method test.versuch.fuenf.service.IServiceRemote.killCallback, referenced from method test.versuch.fuenf.mittwochnacht$1.onServiceDisconnected 08-05 09:17:24.349: WARN/dalvikvm(4758): VFY: unable to resolve interface method 34: Ltest/versuch/fuenf/service/ IServiceRemote;.killCallback (Ltest/versuch/fuenf/service/ IServiceCallback;)V 08-05 09:17:24.359: DEBUG/dalvikvm(4758): VFY: replacing opcode 0x72 at 0x0015 08-05 09:17:24.359: DEBUG/AndroidRuntime(4758): Shutting down VM 08-05 09:17:24.359: WARN/dalvikvm(4758): threadid=1: thread exiting with uncaught exception (group=0x4001d7f0) 08-05 09:17:24.389: ERROR/AndroidRuntime(4758): FATAL EXCEPTION: main 08-05 09:17:24.389: ERROR/AndroidRuntime(4758): java.lang.NoClassDefFoundError: test.versuch.fuenf.mittwochnacht$2 08-05 09:17:24.389: ERROR/AndroidRuntime(4758): at test.versuch.fuenf.mittwochnacht.<init>(mittwochnacht.java:79) 08-05 09:17:24.389: ERROR/AndroidRuntime(4758): at java.lang.Class.newInstanceImpl(Native Method) 08-05 09:17:24.389: ERROR/AndroidRuntime(4758): at java.lang.Class.newInstance(Class.java:1429) 08-05 09:17:24.389: ERROR/AndroidRuntime(4758): at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 08-05 09:17:24.389: ERROR/AndroidRuntime(4758): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 2577) 08-05 09:17:24.389: ERROR/AndroidRuntime(4758): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: 2679) 08-05 09:17:24.389: ERROR/AndroidRuntime(4758): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 08-05 09:17:24.389: ERROR/AndroidRuntime(4758): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 08-05 09:17:24.389: ERROR/AndroidRuntime(4758): at android.os.Handler.dispatchMessage(Handler.java:99) 08-05 09:17:24.389: ERROR/AndroidRuntime(4758): at android.os.Looper.loop(Looper.java:123) 08-05 09:17:24.389: ERROR/AndroidRuntime(4758): at android.app.ActivityThread.main(ActivityThread.java:4627) 08-05 09:17:24.389: ERROR/AndroidRuntime(4758): at java.lang.reflect.Method.invokeNative(Native Method) 08-05 09:17:24.389: ERROR/AndroidRuntime(4758): at java.lang.reflect.Method.invoke(Method.java:521) 08-05 09:17:24.389: ERROR/AndroidRuntime(4758): at com.android.internal.os.ZygoteInit $MethodAndArgsCaller.run(ZygoteInit.java:868) 08-05 09:17:24.389: ERROR/AndroidRuntime(4758): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 08-05 09:17:24.389: ERROR/AndroidRuntime(4758): at dalvik.system.NativeStart.main(Native Method) 08-05 09:17:24.409: WARN/ActivityManager(87): Force finishing activity test.versuch.fuenf/.mittwochnacht 08-05 09:17:24.920: WARN/ActivityManager(87): Activity pause timeout for HistoryRecord{43da6a78 test.versuch.fuenf/.mittwochnacht} 08-05 09:17:31.199: DEBUG/dalvikvm(383): GC_EXPLICIT freed 88 objects / 4320 bytes in 153ms 08-05 09:17:35.837: WARN/ActivityManager(87): Activity destroy timeout for HistoryRecord{43da6a78 test.versuch.fuenf/.mittwochnacht} 08-05 09:17:36.139: DEBUG/dalvikvm(254): GC_EXPLICIT freed 106 objects / 4768 bytes in 88ms 08-05 09:22:24.429: INFO/Process(4758): Sending signal. PID: 4758 SIG: 9 08-05 09:22:24.500: INFO/ActivityManager(87): Process test.versuch.fuenf (pid 4758) has died. 08-05 09:22:24.530: WARN/InputManagerService(87): Window already focused, ignoring focus gain of: com.android.internal.view.iinputmethodclient$stub$pr...@43f1ec90 test.versuch.fuenf.service is the package of the service test.versuch.fuenf is the package of the activity the service is called mittwochnachtservice and the activity mittwochnacht Here is the code from my activity: public class mittwochnacht extends Activity implements OnClickListener { private IServiceRemote mService; private ServiceConnection mServiceConnection = new ServiceConnection() { public void onServiceConnected(ComponentName className,IBinder binder) { mService = IServiceRemote.Stub.asInterface(binder); try{ mService.registerCallback(serviceCallback); } catch(RemoteException e){ } } @Override public void onServiceDisconnected(ComponentName name){ try{ mService.killCallback(serviceCallback);} catch(RemoteException e){ } } }; private final IServiceCallback serviceCallback = new IServiceCallback.Stub() { @Override public void nativeString(String strong) throws RemoteException { txtResult.setText(strong); } }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); txtResult = (TextView) findViewById(R.id.txt_ergebnis); bindService(new Intent("test.versuch.fuenf.service.intent.action.GET_NATIVE_STRING"), mServiceConnection,Context.BIND_AUTO_CREATE); //GET_NATIVE_STRING is defined in my manifestfile for the service } } and this is my service public class mittwochnachtservice extends Service{ private static Manager manager= new Manager(); //manages the native code private final RemoteCallbackList<IServiceCallback> callbacks = new RemoteCallbackList<IServiceCallback>(); private final IServiceRemote.Stub mBinder = new IServiceRemote.Stub() { public String getnativeString() throws RemoteException { final String teststring = manager.stringFromJNI(); return teststring; } @Override public void getnativeStringAsynchron() throws RemoteException { final int countCallbacks=callbacks.beginBroadcast(); for(int i = 0; i<countCallbacks;i++){ try{ callbacks.getBroadcastItem(i).nativeString(manager.stringFromJNI());} catch(RemoteException e){ } callbacks.finishBroadcast(); } } @Override public void killCallback(IServiceCallback callback) throws RemoteException { if(callback!=null){ callbacks.unregister(callback); } } @Override public void registerCallback(IServiceCallback callback) throws RemoteException { if(callback!=null) { callbacks.register(callback); } } }; @Override public IBinder onBind(Intent intent) { return mBinder; } } and the two aidl files: package test.versuch.fuenf.service; import test.versuch.fuenf.service.IServiceCallback; interface IServiceRemote{ String getnativeString(); oneway void getnativeStringAsynchron(); void registerCallback(IServiceCallback callback); void killCallback(IServiceCallback callback); } ________ package test.versuch.fuenf.service; interface IServiceCallback{ void nativeString(in String strong); } It already crashes without calling one of the methods of the interface... If I comment the "private ServiceConnection mServiceConnection = new ServiceConnection(){.." and the "private final IServiceCallback serviceCallback = new IServiceCallback.Stub()..." it is showing me my activity. with this methods it crashes... Can you help me? Thanks for you help M4271N -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en