I'm a bit of a noob when it comes to Android development, and I'm accustomed to native Windows development in Visual Studio, and I'd like to port over a stdout console based test application from Windows to Android. I have a Java APK project that references a Shared Object project, which itself references another shared object. This nested shared object referencing apparently causes a crash before I can enter any of my native code, like so:
Exception thrown: java.lang.UnsatisfiedLinkError
Call stack:
> android.app.NativeActivity.onCreate(android.os.Bundle savedInstanceState) Line 182 Java
android.app.Activity.performCreate(android.os.Bundle icicle) Line 6679 Java
android.app.Instrumentation.callActivityOnCreate(android.app.Activity activity, android.os.Bundle icicle) Line 1118 Java
android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord r, android.content.Intent customIntent) Line 2618 Java
android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord r, android.content.Intent customIntent, java.lang.String reason) Line 2726 Java
android.app.ActivityThread.-wrap12(android.app.ActivityThread , android.app.ActivityThread$ActivityClientRecord r, android.content.Intent customIntent, java.lang.String reason) Java
android.app.ActivityThread$H.handleMessage(android.os.Message msg) Line 1477 Java
android.os.Handler.dispatchMessage(android.os.Message msg) Line 102 Java
android.os.Looper.loop Line 154 Java
android.app.ActivityThread.main(java.lang.String[] args) Line 6119 Java
java.lang.reflect.Method.invoke Java
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() Line 886 Java
com.android.internal.os.ZygoteInit.main(java.lang.String[] argv) Line 776 Java
I've implemented a ANativeActivity_onCreate function in my native section like so:
void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_t savedStateSize)
{
printf("hello?");
}
The crash occurs in Java before this native function can be entered. That said, the function will be entered just fine if I remove its dependency reference on the other shared object project within the solution, but of course, the problem is that I need to use this shared object project if I'm to have it do anything more useful than that.
I've added no Java code at all in the APK project, so it's just a bare-bones template from Visual Studio.
It's a good idea to familiarise yourself with Android first before attempting to build native applications. At least you'll familiarise yourself with the SDK, frameworks, Android states, transitions and lifecycle events. It'll also help you debug where issues lie, if it's inside the SDK or inside your native code.
Have you done any standard C#/C++/C to Java? That's a better place to start than Android if you haven't done so yet, at least you'll understand how the native method hookups and linking is performed. That's something I can't help with, but I do strongly recommend that you create basic Hello World with console logging app in Android. It'll take you a few hours to make and answer a lot of questions.