Xuggler on Android - android

I am trying to use Xuggler on Android to convert WAV files to M4A.
I have used the xuggle-xuggler-noarch-5.4.jar in my java build path
and copied the libxuggler.so file out of xuggle-xuggler-arch-i686-pc-linux-gnu.jar to my libs folder within my android application.
in my main activity i have a static initialiser that attempts to System.loadlibrary("libxuggler")
however i just get these set of info and error messages
I/dalvikvm(27614): Could not find method com.xuggle.mediatool.ToolFactory.makeReader, referenced from method com.example.quality.MainActivity.convertToMP3
W/dalvikvm(27614): VFY: unable to resolve static method 3376: Lcom/xuggle/mediatool/ToolFactory;.makeReader (Ljava/lang/String;)Lcom/xuggle/mediatool/IMediaReader;
W/dalvikvm(27614): Unable to resolve superclass of Lcom/example/quality/MainActivity$6; (485)
W/dalvikvm(27614): Link of class 'Lcom/example/quality/MainActivity$6;' failed
W/dalvikvm(27614): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/example/quality/MainActivity;
W/dalvikvm(27614): Class init failed in newInstance call (Lcom/example/quality/MainActivity;)
W/dalvikvm(27614): threadid=1: thread exiting with uncaught exception (group=0x40acf228)
My System.loadlibrary called failed with
UnsatisfiedLinkError: Couldn't load libxuggle: findLibrary returned null
is it possible to use Xuggler on Android
What have i done wrong?
What havent i done?

There is an explanation on xuggler-users group from Art Clarke :
I have not attempted to port xuggler to android, but if someone is interested all jvm related code is in the 'ferry' module. Memory mgmt is particularly complicated and hard, but in theory a port would be possible.

Related

qt android ClassNotFoundException

I'm using Qt (qml) to make an android app but I'm getting errors trying to register native methods to be called from java. In one section on my native code I'm calling java static functions with no problems:
void NotificationClient::powerOff() {
QAndroidJniObject::callStaticMethod<void>("com/my_app/Utils",
"powerOff",
"()V"
);
}
Now I'm trying to add some calls from java back to my native code (based on this example) but it fails
QAndroidJniEnvironment env;
jclass objectClass = env->FindClass("com/my_app/Utils");
Results in:
Pending exception java.lang.ClassNotFoundException: Didn't find class "com.my_app.Utils" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/system/lib, /vendor/lib, /system/lib, /vendor/lib]]
I've checked the dexdump from classes.dex and the class string matches. All paths in my AndroidManifest.xml are absolute. I've cleaned and rebuilt. Nothing is getting around that problem and I can't figure out why the static method call works but the object one does not.
(Yes, yet another ClassNotFoundException post but I really have searched for answers already).
edit The original failed method based on creating an object threw a different error so I switched back to use FindClass which gives the ClassNotFound error
UPDATE
OK, so I think I've figured out why FindClass is failing: according to this FindClass will search the callstack to figure out which ClassLoader to use. Normally this is fine but I believe Qt for android loads under a different thread so the wrong ClassLoader is getting called.
The link recommends caching the classes in JNI_onLoad but with Qt that's behind the scenes. Is there some other place where I could cache class id's on the main thread instead of the qt thread?
To answer my own question for completeness ...
The reason it failed to find the classes was Qt runs on a different thread than the main java thread, which caused the java classloader to fail in the lookup (see link in question update).
As a solution I added a JNI_onLoad function in one of my cpp files, which is called on the main java thread so the class lookup works correctly.

Unity cannot find classes inside AAR

I have a Unity game which uses an Android Library packed in an AAR (library.aar). However, I need to access the Main Activity's lifecycle callbacks (onPause(), onResume(), to name a few).
So I created a new library project in Android Studio (let's call this plugin). I imported library.aar into plugin and added it to the Dependencies. I tested it by calling the functions inside library.aar inside MainActivity. It doesn't throw any errors at this point.
In MainActivity, I called Library.onActivityResult(), Library.onResume(), and Library.onPause() in the respective functions.
Next, I added the classes.jar from Unity/Editor/Data/PlaybackEngines/androidplayer/release/bin into my plugin project. I added the JAR into the dependencies. I tested it by trying to subclass UnityPlayerActivity. Again, no errors yet.
I compile plugin into plugin-debug.aar and put it in Assets/Plugins/Android. I also created an AndroidManifest.xml which I got from the Unity Manual and put it inside Assets/Plugins.
I call the functions from a button in a Unity scene like so:
AndroidJavaClass jc = new AndroidJavaClass("com.alxcyl.plugin.MainActivity");
jc.CallStatic("connect");
// "connect" is a static function in the Java class MainActivity containing
// a short message like so:
// Log.d("My Plugin", "connect() was called");
I build the game and run it on my Android device. If I click the button, MyPlugin.connect() is properly called since it logs the message it's supposed to when clicked.
I think the lifecycle callbacks are properly called but the problem is that it logs an error saying:
I/dalvikvm( 5466): Could not find method com.somecompany.library.Library.onActivityResult, referenced from method com.alxcyl.plugin.MainActivity.onActivityResult
W/dalvikvm( 5466): VFY: unable to resolve virtual method 276: Lcom/somecompany/library/Library;.onActivityResult (IILandroid/content/Intent;)V
I/dalvikvm( 5466): Could not find method com.somecompany.library.Library.onPause, referenced from method com.alxcyl.plugin.MainActivity.onPause
W/dalvikvm( 5466): VFY: unable to resolve virtual method 276: Lcom/somecompany/library/Library;.onPause()V
I/dalvikvm( 5466): Could not find method com.somecompany.library.Library.onResume, referenced from method com.alxcyl.plugin.MainActivity.onResume
W/dalvikvm( 5466): VFY: unable to resolve virtual method 276: Lcom/somecompany/library/Library;.onResume()V
D/MyPlugin( 5466): connect() was called
I'm not sure what causes it. When you build the plugin project, it builds fine without any errors but when you access it through Unity, it doesn't work. I tried to use the same library.aar into a new Android project and Library.onActivityResult(), Library.onPause(), and Library.onResume() definitely exists and are properly called.
Could it be that Unity can't handle AARs that include AARs? Is there a fix for this?
Looks like the .jar file with all your compiled code is missing in the .aar library.
Unity compiles its own .jar file with all .jar files from all plugins together, into one .dex file.
On Unity forums, you posted "class not found" error; here you mention "method not found". Anyway, something seems to be wrong with your .aar file.

Native application crashes on Android L

I have a native application that always worked on Android KitKat with both Dalivik and ART runtimes, but it now crashes on Android L with the following trace:
E/art(12810): dlopen("/data/app-lib/com.mylib.example", RTLD_LAZY) failed: dlopen failed: cannot locate symbol "issetugid" referenced by "mylib.so"...
D/AndroidRuntime(12810): Shutting down VM
E/AndroidRuntime(12810): FATAL EXCEPTION: main
E/AndroidRuntime(12810): Process: com.mylib.example, PID: 12810
E/AndroidRuntime(12810): java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "issetugid" referenced by "mylib.so"...
E/AndroidRuntime(12810): at java.lang.Runtime.loadLibrary(Runtime.java:364)
E/AndroidRuntime(12810): at java.lang.System.loadLibrary(System.java:610)
Is ART runtime in Android L different from KitKat? There is no new NDK available yet, therefore, how to avoid this crash, because it seems that the function issetugid is no longer supported.
The issue has been fixed in the final Android 5.0 release. There is no need to re-compile existing binaries.
However, if the native lib is compiled with target android-21, it fails on previous Android versions (< 5.0)
I think i may have the answer, please correct me if iam wrong.I had faced similar issue and now its fixed (or i have found a workaround rather)
while registering native method to JNI, there are two ways of doing it.
1) Implement JNI_OnLoad() method in your .cpp file and register your native methods with the
appropriate classes.
Check- http://developer.android.com/training/articles/perf-jni.html#native_libraries
example - https://android.googlesource.com/platform/development/+/master/samples/SimpleJNI/jni/native.cpp
2) there is a particular naming convention to follow for the native methods, where the class path (including package) have to be added.
Check - http://docs.oracle.com/javase/6/docs/technotes/guides/jni/spec/design.html#wp615
Here we need not implement any method. The JVM discovers the native method from the symbol names it self from the binary.
The first method doesn't seem to work in Android ART runtime (ART is Optional in kitkat and it will be the only runtime in Lolipop).I am not not sure why it doesnt work. but i think the reason is because the way ART performs.(The bytecodes are converted and cached during install time itself instead of runtime, so that app runs faster). So since the native libs are not loaded (on_load is not called) the conversion to machine code fails at some point
Use the second method to register natives. it should work.
Only disadvantage is now your function names will be and long and will look horrible (i bet none of the function will fit in 100char limit).bye bye function name readability.
Hope this helps
Cheers,
Shrish

android backup agent and SherlockMapActivity

I try to implement a Backup Agent in my Android app, and I've got a weird issue every times it restore (at first launch) :
Unable to resolve superclass of Lcom/actionbarsherlock/app/SherlockMapActivity; (916)
Link of class 'Lcom/actionbarsherlock/app/SherlockMapActivity;' failed
Unable to resolve superclass of Lnet/myapp/activity/impl/MapActivity; (674)
Link of class 'Lnet/myapp/activity/impl/MapActivity;' failed
Could not find class 'net.myapp.activity.impl.MapActivity', referenced from method net.myapp.helper.SlidingMenuHelper.<clinit>
VFY: unable to resolve const-class 1520 (Lnet/myapp/activity/impl/MapActivity;) in Lnet/myapp/helper/SlidingMenuHelper;
VFY: replacing opcode 0x1c at 0x0081
Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lnet/myapp/helper/SlidingMenuHelper;
Complete log here : https://gist.github.com/romainguefveneu/1acc78cabbed65fba4b7
The restore process works just fine, when I open a second time the app, my data are correctly restored.
It seems to be an issue with the loading of SherlockMapActivity, I use all those libs in my project :
actionbarsherlock-plugin-maps-4.2.0.jar
bugsense-3.0.1.jar
commons-io-2.0.1.jar
gson-2.2.2.jar
joda-time-2.1.jar
ocpsoft-pretty-time-1.0.7.jar
Does someone has an idea ?

Adding ActionBarSherlock as library to project

I have a problem with the new ActionBarSherlock.
I have to link it to my project and use it's features (Fragments, etc), in a project that supports android API level 7 and above.
I have created a module in intelij with my project, and I've linked the ActionBarSherlock library project to it. Everything looks good, the project rebuilds correctly, deploy a valid apk to emulator, but when I'm trying to run the application I got something like this:
WARN/dalvikvm(540): Unable to resolve superclass of Lcom/mobileinsight/common/CustomActivity; (134)
WARN/dalvikvm(540): Link of class 'Lcom/mobileinsight/common/CustomActivity;' failed
WARN/dalvikvm(540): Unable to resolve superclass of Lcom/mobileinsight/ui/SplashActivity; (175)
WARN/dalvikvm(540): Link of class 'Lcom/mobileinsight/ui/SplashActivity;' failed
WARN/dalvikvm(540): threadid=3: thread exiting with uncaught exception (group=0x4001b188)`
ERROR/AndroidRuntime(540): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mobileinsight/com.mobileinsight.ui.SplashActivity}: java.lang.ClassNotFoundException: com.mobileinsight.ui.SplashActivity in loader dalvik.system.PathClassLoader#45f352e8
I get the error when the application tries to instantiate an activity that extends SherlockActivity or FragmentSherlockActivity
Somebody can help me with this?
Thanks,
Ark

Categories

Resources