Unable to link native library in OpenCV Android sample - android

I have OpenCV code (c++), which I want to use in Android. To do this I have to use Android NDK. I downloaded OpenCV package for Android development (ver. 2.4.0) and did all steps from that manual. Basic samples (Java API only) run without problems. Sample #3 (Tutorial 3 (Advanced) - Add Native OpenCV) builds from ndk-builder correctly. But always got exception when I'm trying to run/debug it on device from eclipse:
Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/opencv/samples/tutorial3/Sample3View;
In this line:
System.loadLibrary("native_sample");
Here's full logcat log:
05-31 23:41:45.976: W/ActivityThread(9708): Application org.opencv.samples.tutorial3 is waiting for the debugger on port 8100...
05-31 23:41:45.983: I/System.out(9708): Sending WAIT chunk
05-31 23:41:45.983: I/dalvikvm(9708): Debugger is active
05-31 23:41:46.179: I/System.out(9708): Debugger has connected
05-31 23:41:46.179: I/System.out(9708): waiting for debugger to settle...
05-31 23:41:46.382: I/System.out(9708): waiting for debugger to settle...
05-31 23:41:46.585: I/System.out(9708): waiting for debugger to settle...
05-31 23:41:46.788: I/System.out(9708): waiting for debugger to settle...
05-31 23:41:46.983: I/System.out(9708): waiting for debugger to settle...
05-31 23:41:47.186: I/System.out(9708): waiting for debugger to settle...
05-31 23:41:47.389: I/System.out(9708): waiting for debugger to settle...
05-31 23:41:47.585: I/System.out(9708): waiting for debugger to settle...
05-31 23:41:47.788: I/System.out(9708): debugger has settled (1463)
05-31 23:41:47.819: D/szipinf(9708): Initializing inflate state
05-31 23:41:47.866: I/Sample::Activity(9708): Instantiated new class org.opencv.samples.tutorial3.Sample3Native
05-31 23:41:48.909: D/dalvikvm(9708): threadid=1: still suspended after undo (sc=1 dc=1)
05-31 23:41:51.770: I/Sample::Activity(9708): onCreate
05-31 23:41:59.283: W/dalvikvm(9708): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/opencv/samples/tutorial3/Sample3View;
05-31 23:42:01.965: D/AndroidRuntime(9708): Shutting down VM
05-31 23:42:01.965: W/dalvikvm(9708): threadid=1: thread exiting with uncaught exception (group=0x40015560)
05-31 23:42:01.999: E/AndroidRuntime(9708): FATAL EXCEPTION: main
05-31 23:42:01.999: E/AndroidRuntime(9708): java.lang.ExceptionInInitializerError
05-31 23:42:01.999: E/AndroidRuntime(9708): at org.opencv.samples.tutorial3.Sample3Native.onCreate(Sample3Native.java:21)
05-31 23:42:01.999: E/AndroidRuntime(9708): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-31 23:42:01.999: E/AndroidRuntime(9708): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
05-31 23:42:01.999: E/AndroidRuntime(9708): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
05-31 23:42:01.999: E/AndroidRuntime(9708): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
05-31 23:42:01.999: E/AndroidRuntime(9708): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
05-31 23:42:01.999: E/AndroidRuntime(9708): at android.os.Handler.dispatchMessage(Handler.java:99)
05-31 23:42:01.999: E/AndroidRuntime(9708): at android.os.Looper.loop(Looper.java:130)
05-31 23:42:01.999: E/AndroidRuntime(9708): at android.app.ActivityThread.main(ActivityThread.java:3835)
05-31 23:42:01.999: E/AndroidRuntime(9708): at java.lang.reflect.Method.invokeNative(Native Method)
05-31 23:42:01.999: E/AndroidRuntime(9708): at java.lang.reflect.Method.invoke(Method.java:507)
05-31 23:42:01.999: E/AndroidRuntime(9708): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
05-31 23:42:01.999: E/AndroidRuntime(9708): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
05-31 23:42:01.999: E/AndroidRuntime(9708): at dalvik.system.NativeStart.main(Native Method)
05-31 23:42:01.999: E/AndroidRuntime(9708): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load native_sample: findLibrary returned null
05-31 23:42:01.999: E/AndroidRuntime(9708): at java.lang.Runtime.loadLibrary(Runtime.java:429)
05-31 23:42:01.999: E/AndroidRuntime(9708): at java.lang.System.loadLibrary(System.java:554)
05-31 23:42:01.999: E/AndroidRuntime(9708): at org.opencv.samples.tutorial3.Sample3View.<clinit>(Sample3View.java:48)
05-31 23:42:01.999: E/AndroidRuntime(9708): ... 14 more
I find solutions for the same problem but none of them didn't help me:
Native OpenCV Samples for Android throws UnsatisfiedLinkError
java.lang.UnsatisfiedLinkError: Couldn't load opencv_java: findLibrary returned null
Major OpenCV-Android for Windows Installing and Running Issues (no answer)
Also I have tested it on different devices and Android API versions.
My system configuration:
astor#astor-K42Jv:~$ uname -a
Linux astor-K42Jv 3.2.0-24-generic-pae #39-Ubuntu SMP Mon May 21 18:54:21 UTC 2012 i686 i686 i386 GNU/Linux
I've been tried to fix this problem for 4 nights (it's my free time :) ), but with no luck. I really need this for my thesis, so any help will be appreciated.
Update: I have tested this sample on Windows 7 (64), but result is the same.
It seems that this is OpenCV bug.
Update: Build log:
astor#astor-K42Jv:/opt/eclipse-android/workspace/OpenCV-2.4.0-samples/tutorial-3-native$ ndk-build
Install : libnative_camera_r2.2.0.so => libs/armeabi-v7a/libnative_camera_r2.2.0.so
Install : libnative_camera_r2.3.3.so => libs/armeabi-v7a/libnative_camera_r2.3.3.so
Install : libnative_camera_r3.0.1.so => libs/armeabi-v7a/libnative_camera_r3.0.1.so
Install : libnative_camera_r4.0.0.so => libs/armeabi-v7a/libnative_camera_r4.0.0.so
Install : libnative_camera_r4.0.3.so => libs/armeabi-v7a/libnative_camera_r4.0.3.so
Install : libnative_sample.so => libs/armeabi-v7a/libnative_sample.so

Whoohoo!
Finally I found solution for this problem by myself!
I decided to debug line:
System.loadLibrary("native_sample");
To do this I downloaded android source code from Android-SDK and then attached source folder (/opt/android-sdk-linux/sources/android-15) to my project.
After this I found that error was:
Cannot load library: link_image[1936]: 37 could not load needed library 'libopencv_java.so' for 'libhello-jni.so' (load_library[1091]: Library 'libopencv_java.so' not found)
And really this library is not in lib directory. I don't know why but ndk-build ignored it. So i decided to copy and load it manualy. For this I copied libopencv_java.so from /opt/OpenCV-2.4.0/libs/armeabi-v7a and also edited java code:
static {
System.loadLibrary("opencv_java"); //load opencv_java lib
System.loadLibrary("native_sample");
}
Actually similar problems are:
Can not load Opencv libraries in necessitas
Android OpenCV: cannot dlopen camera wrapper library
From second solution I found that I can load libraries using dlopen, but I haven't tried it yet.
So I will write simple bash-script that will do it (just copy) for myself.
Thanks to all.

Instead of loading your native library as
static{
System.loadLibrary("YOUR_LIBRARY");
}
load your library after opencv manager is connected in "onManagerConnected" method in you "BaseLoaderCallBack". Following is my code snippet working for me
public void onManagerConnected(int status) {
switch(status){
case LoaderCallbackInterface.SUCCESS:
Toast.makeText(getApplicationContext(), "manager connected", Toast.LENGTH_LONG).show();
System.loadLibrary("MYNATIVELIB");
break;
default:
super.onManagerConnected(status);
break;
}
}

You're at a higher level than the actual problem. See "Getting started with the NDK", when you run
cd <project>
<ndk>/ndk-build
... what does it say? (Remember to use the cygwin window and not a dos prompt).

Related

Apache Cordova Facebook Plugin (latest version/current master) crashes my android app while initializing

I've created the sample app given in the latest version (current master) of Apache Cordova Facebook Plugin several times:
https://github.com/phonegap/phonegap-facebook-plugin
Currently, I'm working on Android only.
The first time I created this sample app (about two weeks ago) everything worked fine. I successfully logged in with my facebook account, posted a status to my wall and logged out (all the other actions worked fine as well).
But since than I've created this sample app several more times (in the exact same way), and it has never worked again (the last time I tried was today). In the new apps (with the very same code as the first app, which still works), I press "LOGIN WITH FACEBOOK", and my app crashes immediately. Sometimes the app doesn't crash immediately, and I can get the message "Argument 'session' cannot be null". Then I press "LOGIN WITH FACEBOOK" again, and the app crashes. Sometimes I can get this message several times before the app eventually crashes.
If I press "LOGOUT WITH FACEBOOK", I get the message: "No valid session found, must call init and login before logout".
I also don't think that the problem is that I have a wrong hash key or something like that, because I've been careful with the settings of the facebook app every time.
I also believe that I've installed the plugin correctly each time, because I've always done it the same way I did it the first time, which worked fine.
So how is it that in my latest attempts the session variable is NULL??
Why did it work only in the first time??
I'm very frustrated..
Edit:
Here is the relevant segment of the LogCat log:
D/ConnectPlugin( 7064): login FB
W/dalvikvm( 7064): VFY: unable to resolve static field 2130 (com_facebook_internet_permission_error_title) in Lcom/facebook/android/R$string;
D/dalvikvm( 7064): VFY: replacing opcode 0x60 at 0x0010
I/dalvikvm( 7064): DexOpt: unable to optimize static field ref 0x0851 at 0x18 in Lcom/facebook/AuthorizationClient;.checkInternetPermission
W/dalvikvm( 7064): VFY: unable to resolve static field 2120 (com_facebook_login_activity_layout) in Lcom/facebook/android/R$layout;
D/dalvikvm( 7064): VFY: replacing opcode 0x60 at 0x0003
W/dalvikvm( 7064): VFY: unable to resolve static field 2103 (com_facebook_login_activity_progress_bar) in Lcom/facebook/android/R$id;
D/dalvikvm( 7064): VFY: replacing opcode 0x60 at 0x0008
I/ActivityManager( 2112): START {intent.toShortString} from pid 7064
I/power ( 2112): *** acquire_dvfs_lock : lockType : 1 freq : 1000000
D/PowerManagerService( 2112): acquireDVFSLockLocked : type : DVFS_MIN_LIMIT frequency : 1000000 uid : 1000 pid : 2112 tag : ActivityManager
W/ActivityManager( 2112): mDVFSLock.acquire()
D/dalvikvm( 7064): GC_CONCURRENT freed 455K, 6% free 12931K/13639K, paused 4ms+5ms
W/PluginManager( 7064): THREAD WARNING: exec() call to FacebookConnectPlugin.login blocked the main thread for 207ms. Plugin should use CordovaInterface.getThreadPool().
D/CordovaActivity( 7064): Paused the application!
D/CordovaWebView( 7064): Handle the pause
D/FirewallPolicy( 2112): getURLFilterEnabled(true)
D/FirewallPolicy( 2112): isUrlBlocked - Policy disabled
D/webkit ( 7064): Firewall not null
D/FirewallPolicy( 2112): getURLFilterEnabled(true)
D/FirewallPolicy( 2112): isUrlBlocked - Policy disabled
I/ClipboardServiceEx( 2112): mCBPickerDialog enter case. MSG_DISMISS_DIALOG
D/webkit ( 7064): euler: isUrlBlocked = false
D/FirewallPolicy( 2112): getURLFilterEnabled(true)
D/FirewallPolicy( 2112): isUrlBlocked - Policy disabled
D/ActivityManager( 2112): Trying to launch applicationName
D/KeyguardViewMediator( 2112): setHidden false
I/ClipboardServiceEx( 2112): mCBPickerDialog enter case. MSG_DISMISS_DIALOG
D/AndroidRuntime( 7064): Shutting down VM
W/dalvikvm( 7064): threadid=1: thread exiting with uncaught exception (group=0x40c6c1f8)
E/AndroidRuntime( 7064): FATAL EXCEPTION: main
E/AndroidRuntime( 7064): java.lang.NoClassDefFoundError: com.facebook.android.R$layout
E/AndroidRuntime( 7064): at com.facebook.LoginActivity.onCreate(LoginActivity.java:57)
E/AndroidRuntime( 7064): at android.app.Activity.performCreate(Activity.java:4562)
E/AndroidRuntime( 7064): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
E/AndroidRuntime( 7064): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
E/AndroidRuntime( 7064): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
E/AndroidRuntime( 7064): at android.app.ActivityThread.access$600(ActivityThread.java:128)
E/AndroidRuntime( 7064): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
E/AndroidRuntime( 7064): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 7064): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 7064): at android.app.ActivityThread.main(ActivityThread.java:4514)
E/AndroidRuntime( 7064): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 7064): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 7064): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
E/AndroidRuntime( 7064): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
E/AndroidRuntime( 7064): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 2112): Force finishing activity com.yomama.test/com.facebook.LoginActivity
W/ActivityManager( 2112): Force finishing activity com.yomama.test/.Test
Another strange thing that happened to me yesterday was that I recompiled and re-installed (on my phone) the first working app, and suddenly it didn't work either (I got the same message after pressing "LOGIN WITH FACEBOOK", and then the app crashed). Then I recompiled and re-installed the app again, and it was working fine again. Weird.
Try the following steps (from this GitHub issue; had worked for me):
+### Android Setup without Eclipse (just CLI)
+Follow the steps above:
cordova create myApp
cd myApp/
cordova platform add android
cordova -d plugin add https://github.com/phonegap/phonegap-facebook-plugin.git --variable APP_ID="123456789" --variable APP_NAME="myApplication"
// add FacebookLib
echo "android.library.reference.2=com.phonegap.plugins.facebookconnect/FacebookLib" >> platforms/android/project.properties
cp platforms/android/local.properties platforms/android/com.phonegap.plugins.facebookconnect/FacebookLib
android update project -p platforms/android/
cd platforms/android/
ant clean
cd com.phonegap.plugins.facebookconnect/FacebookLib
ant clean
open -e AndroidManifest.xml
// change your minSdkVersion and your targetSdkVersion to your environment settings.
ant release
cd ../../../..
cordova build android
With this steps you can add the Plugin without using Eclipse

Can't use libspotify 12 in android app

I'm trying to load libspotify in my android app using NDK.
I'm using the library libspotify++ and jlibspotify. everything seems to be loaded but it crashes when libspotify is trying to load the library "libspotify.so.12"
I cannot use symbolic links in android.
Code:
public class Session {
static {
System.loadLibrary("spotify");
System.loadLibrary("jlibspotify");
}
}
Log:
05-29 17:27:22.559: D/dalvikvm(32606): threadid=1: still suspended after undo (sc=1 dc=1)
05-29 17:27:25.527: D/dalvikvm(32606): Trying to load lib /data/data/se.warting.spotify/lib/libspotify.so 0x41692100
05-29 17:27:25.535: D/dalvikvm(32606): Added shared lib /data/data/se.warting.spotify/lib/libspotify.so 0x41692100
05-29 17:27:25.535: D/dalvikvm(32606): No JNI_OnLoad found in /data/data/se.warting.spotify/lib/libspotify.so 0x41692100, skipping init
05-29 17:27:25.543: D/dalvikvm(32606): Trying to load lib /data/data/se.warting.spotify/lib/libjlibspotify.so 0x41692100
05-29 17:27:27.637: W/dalvikvm(32606): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lse/sony/tunefeud/spotiwrap/Session;
05-29 17:27:28.824: D/AndroidRuntime(32606): Shutting down VM
05-29 17:27:28.824: W/dalvikvm(32606): threadid=1: thread exiting with uncaught exception (group=0x40a421f8)
05-29 17:27:28.855: E/AndroidRuntime(32606): FATAL EXCEPTION: main
05-29 17:27:28.855: E/AndroidRuntime(32606): java.lang.ExceptionInInitializerError
05-29 17:27:28.855: E/AndroidRuntime(32606): at se.warting.spotify.PocActivity.onCreate(PocActivity.java:18)
05-29 17:27:28.855: E/AndroidRuntime(32606): at android.app.Activity.performCreate(Activity.java:4465)
05-29 17:27:28.855: E/AndroidRuntime(32606): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-29 17:27:28.855: E/AndroidRuntime(32606): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-29 17:27:28.855: E/AndroidRuntime(32606): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-29 17:27:28.855: E/AndroidRuntime(32606): at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-29 17:27:28.855: E/AndroidRuntime(32606): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-29 17:27:28.855: E/AndroidRuntime(32606): at android.os.Handler.dispatchMessage(Handler.java:99)
05-29 17:27:28.855: E/AndroidRuntime(32606): at android.os.Looper.loop(Looper.java:137)
05-29 17:27:28.855: E/AndroidRuntime(32606): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-29 17:27:28.855: E/AndroidRuntime(32606): at java.lang.reflect.Method.invokeNative(Native Method)
05-29 17:27:28.855: E/AndroidRuntime(32606): at java.lang.reflect.Method.invoke(Method.java:511)
05-29 17:27:28.855: E/AndroidRuntime(32606): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-29 17:27:28.855: E/AndroidRuntime(32606): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-29 17:27:28.855: E/AndroidRuntime(32606): at dalvik.system.NativeStart.main(Native Method)
05-29 17:27:28.855: E/AndroidRuntime(32606): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1936]: 118 could not load needed library 'libspotify.so.12' for 'libjlibspotify.so' (load_library[1091]: Library 'libspotify.so.12' not found)
05-29 17:27:28.855: E/AndroidRuntime(32606): at java.lang.Runtime.loadLibrary(Runtime.java:370)
05-29 17:27:28.855: E/AndroidRuntime(32606): at java.lang.System.loadLibrary(System.java:535)
05-29 17:27:28.855: E/AndroidRuntime(32606): at se.warting.spotify.spotiwrap.Session.<clinit>(Session.java:6)
05-29 17:27:28.855: E/AndroidRuntime(32606): ... 15 more
This is what i get from objdump:
$arm-linux-androideabi-objdump -p libs/armeabi/libjlibspotify.so | grep NEEDED
NEEDED libspotify.so.12
NEEDED libstdc++.so
NEEDED libm.so
NEEDED libc.so
NEEDED libdl.so
$arm-linux-androideabi-objdump -p libs/armeabi/libspotify.so | grep NEEDED
NEEDED libm.so
NEEDED libc.so
NEEDED libdl.so
Does anyone know what do do to get it work?
I'll just break out my Java/JVM skills here and try applying them on Android/Dalvik.
System.loadLibrary() expects a JNI library name as its argument. In this case libspotify is not (and never is) a JNI library, but libjlibspotify seems to be. Note how the first call whines in the log about the missing JNI_OnLoad function. This is usually a good hint. System.loadLibrary() does however accept any shared library as long as it can find it, and that's why the call doesn't fail in this scenario.
Dependent libraries of a JNI library are loaded automatically by the platform's built-in shared library loading mechanisms. In this case, libjlibspotify depends on libspotify.so.12, so if there is such a file available in the loader's path, then this should be loaded automatically by the system whenever libjlibspotify is loaded.
Hence, the proper Java code in this case should be:
public class Session {
static {
System.loadLibrary("jlibspotify");
}
}
However, if the dependent library is not found as part of the System.loadLibrary() invocation, then that call will fail with an UnsatisfiedLinkError (see the log about the missing dependent libspotify.so.12 file).
libspotify 12 currently ships in the archive as libspotify.so.12.1.45 (with some symlinks libspotify.so and libspotify.so.12 pointing to that file). I don't know anything about how libjlibspotify has been built in this scenario, but if it is the case that the symlinks aren't relevant in the Android setting, then libjlibspotify should instead be built to load libspotify.so.12.1.45 from the archive, no renaming needed.
It seems you need to change build process of how you are creating the libspotify to have proper name.
Easiest way would be to use Android NDK build system - it will correctly compile and link the libraries.
The answer from Mārtiņš is correct, it should be build with Android's NDK build system.
When don't having controle over the library there is a workaround:
Instead of loading the library with System.loadLibrary( "JLibSpotify" );
i manualy copied /data/data/se.warting.spotify/lib/libspotify.so to /data/data/se.warting.spotify/libspotify.so.12
And then loaded the library with:
System.load("/data/data/se.warting.spotify/libspotify.so.12");
After that i could load jlibspotify as normal:
System.loadLibrary("jlibspotify");

Adding addmob adds to main.xml crashes my app

Let me start by saying that this app was working fine the day before. I have restarted the pc, removed the project and added a previous version of the project and it keeps crashing. If i remove this from main.xml which gets loaded from the mainactivity the app does not crash. If i have this in the main.xml :
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="a14ee1ad68dcbdb"
ads:loadAdOnCreate="true" />
the app crashes. If i run the app and this code is not in the main.xml file but in other xml files the app works fine and it will show adds from other activities.
I tried removing all the code in the xml file and just have the above admob adds in there and it still crashed. I was thinking about uninstalling eclipse and installing it again???
Any ideas????
Here is a Everything from start to finish in logcat:
03-30 11:39:17.215: D/AndroidRuntime(338): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
03-30 11:39:17.215: D/AndroidRuntime(338): CheckJNI is ON
03-30 11:39:17.335: D/AndroidRuntime(338): --- registering native functions ---
03-30 11:39:17.825: D/AndroidRuntime(338): Shutting down VM
03-30 11:39:17.825: D/dalvikvm(338): Debugger has detached; object registry had 1 entries
03-30 11:39:17.845: I/AndroidRuntime(338): NOTE: attach of thread 'Binder Thread #3' failed
03-30 11:39:18.215: D/AndroidRuntime(346): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
03-30 11:39:18.215: D/AndroidRuntime(346): CheckJNI is ON
03-30 11:39:18.345: D/AndroidRuntime(346): --- registering native functions ---
03-30 11:39:18.835: I/ActivityManager(59): Force stopping package com.petermihaylov.android.cardcounter uid=10040
03-30 11:39:18.835: I/Process(59): Sending signal. PID: 331 SIG: 9
03-30 11:39:18.896: I/UsageStats(59): Unexpected resume of com.android.launcher while already resumed in com.petermihaylov.android.cardcounter
03-30 11:39:18.905: W/InputManagerService(59): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#45094eb8
03-30 11:39:18.945: I/ActivityManager(59): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.petermihaylov.android.cardcounter/.MainActivity }
03-30 11:39:18.945: D/AndroidRuntime(346): Shutting down VM
03-30 11:39:18.955: D/jdwp(346): Got wake-up signal, bailing out of select
03-30 11:39:18.955: D/dalvikvm(346): Debugger has detached; object registry had 1 entries
03-30 11:39:19.039: I/AndroidRuntime(346): NOTE: attach of thread 'Binder Thread #3' failed
03-30 11:39:19.155: I/ActivityManager(59): Start proc com.petermihaylov.android.cardcounter for activity com.petermihaylov.android.cardcounter/.MainActivity: pid=353 uid=10040 gids={3003}
03-30 11:39:19.345: D/dalvikvm(33): GC_EXPLICIT freed 285 objects / 10864 bytes in 186ms
03-30 11:39:19.475: W/ActivityThread(353): Application com.petermihaylov.android.cardcounter is waiting for the debugger on port 8100...
03-30 11:39:19.525: I/System.out(353): Sending WAIT chunk
03-30 11:39:19.565: I/dalvikvm(353): Debugger is active
03-30 11:39:19.595: D/dalvikvm(33): GC_EXPLICIT freed 47 objects / 2056 bytes in 249ms
03-30 11:39:19.745: I/System.out(353): Debugger has connected
03-30 11:39:19.745: I/System.out(353): waiting for debugger to settle...
03-30 11:39:19.945: I/System.out(353): waiting for debugger to settle...
03-30 11:39:20.075: D/dalvikvm(33): GC_EXPLICIT freed 2 objects / 64 bytes in 422ms
03-30 11:39:20.207: I/System.out(353): waiting for debugger to settle...
03-30 11:39:20.405: I/System.out(353): waiting for debugger to settle...
03-30 11:39:20.605: I/System.out(353): waiting for debugger to settle...
03-30 11:39:20.823: I/System.out(353): waiting for debugger to settle...
03-30 11:39:21.025: I/System.out(353): waiting for debugger to settle...
03-30 11:39:21.225: I/System.out(353): waiting for debugger to settle...
03-30 11:39:21.468: I/System.out(353): waiting for debugger to settle...
03-30 11:39:21.677: I/System.out(353): debugger has settled (1469)
03-30 11:39:29.005: W/ActivityManager(59): Launch timeout has expired, giving up wake lock!
03-30 11:39:29.421: W/ActivityManager(59): Activity idle timeout for HistoryRecord{450bae78 com.petermihaylov.android.cardcounter/.MainActivity}
Looks like you're trying to debug the app, and it's hanging on debug. Do you get any more relevant logs if you try to just run it?
Also, have you updated to r17 of the Android Tools by any chance? r17 of the tools force you to place the SDK in the libs/ folder of your project.
Are you sure you have stepped through a tutorial properly and added the permissions and imported the SDK?
Try stepping through this guide from the beginning:
https://developers.google.com/mobile-ads-sdk/docs/android/fundamentals
Cleaning the project in Eclipse sometimes solves some problems.
I had a very similar bizarre issue with Admob recently after a fresh install of Eclipse. After hours of looking into why, it ended up being my build order in the project preferences. I set the Google AdMob jar to the top, cleaned the project and all my issues were resolved.
The logcat text you have pasted does not give any error information. Can you paste the logcat text from the point of failure, generally you can see the communications with AdMob in here.
May help, just a thought.
New version of Android LED Clock just uploaded to the market
Jason

libs suddenly won't load in dynamic linker (NDK)

I've been developing an NDK app for quite some time and it's been working well. However, today the app randomly decided to not start anymore, after I compiled it after making some nominal change. It's caused by a cryptic problem with loading the app's main library. Here's some log output:
08-11 18:38:11.220 D/dalvikvm( 1237): Added shared lib /mnt/asec/com.audia.rta-1/lib/libqtandroid.so 0x40513bd8
08-11 18:38:11.220 D/dalvikvm( 1237): No JNI_OnLoad found in /mnt/asec/com.audia.rta-1/lib/libqtandroid.so 0x40513bd8, skipping init
08-11 18:38:11.220 D/dalvikvm( 1237): Trying to load lib /mnt/asec/com.audia.rta-1/lib/librta.so 0x40513bd8
08-11 18:38:11.260 D/AndroidRuntime( 1237): Shutting down VM
08-11 18:38:11.260 W/dalvikvm( 1237): threadid=1: thread exiting with uncaught exception (group=0x40015560)
08-11 18:38:11.260 E/AndroidRuntime( 1237): FATAL EXCEPTION: main
08-11 18:38:11.260 E/AndroidRuntime( 1237): java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1311]: 67 cannot locate '_ZNSaIcEC1Ev'...
08-11 18:38:11.260 E/AndroidRuntime( 1237):
08-11 18:38:11.260 E/AndroidRuntime( 1237): at java.lang.Runtime.loadLibrary(Runtime.java:434)
08-11 18:38:11.260 E/AndroidRuntime( 1237): at java.lang.System.loadLibrary(System.java:554)
08-11 18:38:11.260 E/AndroidRuntime( 1237): at com.audia.rta.RTA.onCreate(RTA.java:139)
According to some Google results, _ZNSaIcEC1Ev is part of libstdc++. I've checked, and it gets linked in the build process, and g++ is being used for linking.
Oddly enough, reverting to an older apk of the app fixes the problem, but compiling an old revision and installing that doesn't fix the problem. Everything in my build system is checked into version control, and I've done several clean builds. All my builds were working today and then they just stopped working. I didn't upgrade or install anything; it happened while I was in the middle of testing new code. What happened?
Update: Building from a freshly checked out copy doesn't fix the problem.
Update 2: Is there any way I can track down the link to that symbol, maybe with objdump? Maybe this could provide some clues.
I ended up compiling everything with a fresh NDK install, and it worked. It's as if the old one was corrupted somehow, though I have no idea how.
It was also an upgrade from r5b to r6, so maybe it's related to the NDK version.

Android Hello World app crashes: IllegalArgumentException from Surface.lockCanvasNative

I am trying to run the simplest Hello World example app and looks like I can crash it even all it does is showing a TextView.
Steps to reproduce: Launch it in the emulator (1.5). Open the app - it shows the text view, then lock the phone by pressing "end call" button. Unlock by pressing "menu", then press "back". App crashes with "The process android.process.acore has stopped unexpectedly..." and Force Close button. It does not happen all the time, but I am able to reproduce it every time after wiping the user data at least.
I wonder if default Hello World is missing a detail which was considered too advanced for a hello world... Such problems with a basic example does not look very encouraging =)
Any idea what detail is missing and how to avoid this crash?
Stack (I've truncated timestamps):
37.478: DEBUG/KeyguardViewMediator(576): wakeWhenReadyLocked(82)
37.481: DEBUG/KeyguardViewMediator(576): handleWakeWhenReady(82)
37.481: DEBUG/KeyguardViewMediator(576): pokeWakelock(5000)
39.110: DEBUG/KeyguardViewMediator(576): pokeWakelock(5000)
39.140: WARN/InputManagerService(576): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#436e3fc0
40.990: ERROR/IMemory(679): binder=0x238aa8 transaction failed fd=-2147483647, size=0, err=-2147483646 (Unknown error: 2147483646)
40.990: ERROR/IMemory(679): cannot dup fd=-2147483647, size=0, err=-2147483646 (Bad file number)
40.990: ERROR/IMemory(679): cannot map BpMemoryHeap (binder=0x238aa8), size=0, fd=-1 (Bad file number)
40.990: ERROR/Surface(679): Couldn't map Surface's heap (binder=0x238aa8, heap=0x238b00)
40.990: DEBUG/AndroidRuntime(679): Shutting down VM
40.990: WARN/dalvikvm(679): threadid=3: thread exiting with uncaught exception (group=0x4000fe70)
40.990: ERROR/AndroidRuntime(679): Uncaught handler: thread main exiting due to uncaught exception
40.990: ERROR/AndroidRuntime(679): java.lang.IllegalArgumentException
40.990: ERROR/AndroidRuntime(679): at android.view.Surface.lockCanvasNative(Native Method)
40.990: ERROR/AndroidRuntime(679): at android.view.Surface.lockCanvas(Surface.java:196)
40.990: ERROR/AndroidRuntime(679): at android.view.ViewRoot.draw(ViewRoot.java:1175)
40.990: ERROR/AndroidRuntime(679): at android.view.ViewRoot.performTraversals(ViewRoot.java:1030)
40.990: ERROR/AndroidRuntime(679): at android.view.ViewRoot.handleMessage(ViewRoot.java:1482)
40.990: ERROR/AndroidRuntime(679): at android.os.Handler.dispatchMessage(Handler.java:99)
40.990: ERROR/AndroidRuntime(679): at android.os.Looper.loop(Looper.java:123)
40.990: ERROR/AndroidRuntime(679): at android.app.ActivityThread.main(ActivityThread.java:3948)
40.990: ERROR/AndroidRuntime(679): at java.lang.reflect.Method.invokeNative(Native Method)
40.990: ERROR/AndroidRuntime(679): at java.lang.reflect.Method.invoke(Method.java:521)
40.990: ERROR/AndroidRuntime(679): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
40.990: ERROR/AndroidRuntime(679): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
40.990: ERROR/AndroidRuntime(679): at dalvik.system.NativeStart.main(Native Method)
41.000: INFO/Process(576): Sending signal. PID: 679 SIG: 3
41.000: INFO/dalvikvm(679): threadid=7: reacting to signal 3
41.030: ERROR/ActivityThread(576): Failed to find provider info for android.server.checkin
41.030: ERROR/Checkin(576): Error reporting crash: java.lang.IllegalArgumentException: Unknown URL content://android.server.checkin/crashes
41.070: INFO/dalvikvm(679): Wrote stack trace to '/data/anr/traces.txt'
50.940: WARN/ActivityManager(576): Launch timeout has expired, giving up wake lock!
50.980: WARN/ActivityManager(576): Activity idle timeout for HistoryRecord{4366ac40 {com.android.launcher/com.android.launcher.Launcher}}
sounds to me more like something wrong with your emulator. Why dont you delete your emulator and create a new one and try again with a fresh project.
Hope that will help you. BTW why are you using emulator on 1.5?? Start to build applications for min 2.1.
Good luck.

Categories

Resources