0

So, I am trying to implement a QR Scanner into my Android application, and I am using Android Studio. The user simply taps (clicks) a button which calls the QR Scanner onto the screen. At this point, the user can scan the QR code for the embedded URL and will be sent to the that URL. Pretty simple.

I am using the [ZBar][1] library. I used this awesome [tutorial][1].

I pretty much followed his tutorial exactly as he outlined it, copying and pasting. I had no compilation errors and the application built without any problems; however, upon running it, the emulator throws me the following message: "Unfortunately, My Application has stopped."

If you need anymore information please let me know.

Here is what logcat outputs after it crashes:

10-02 16:56:26.732  18271-18271/v1.com.example.ggpcoding.myapplication E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: v1.com.example.ggpcoding.myapplication, PID: 18271
    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/v1.com.example.ggpcoding.myapplication-2/base.apk"],nativeLibraryDirectories=[/data/app/v1.com.example.ggpcoding.myapplication-2/lib/x86, /vendor/lib, /system/lib]]] couldn't find "libzbarjni.so"
            at java.lang.Runtime.loadLibrary(Runtime.java:367)
            at java.lang.System.loadLibrary(System.java:1076)
            at net.sourceforge.zbar.ImageScanner.<clinit>(Unknown Source)
            at v1.com.example.ggpcoding.myapplication.MainActivity.initControls(MainActivity.java:46)
            at v1.com.example.ggpcoding.myapplication.MainActivity.onCreate(MainActivity.java:36)
            at android.app.Activity.performCreate(Activity.java:6237)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
            at android.app.ActivityThread.-wrap11(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Here is onCreate function:

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initControls();
}

2 Answers2

0

You need to load the library yourself. You can use the following code in the first Activity you want to use scanner.

static {
    System.loadLibrary( "iconv" );
}
0

You should build the native library for all CPU architectures to ensure that the application runs on every device and I think you don't have the correct build based on the device that the app is running. I'm not sure but I think you should build for x86. You can build native library using android NDK.

Mohammad Rafigh
  • 757
  • 9
  • 17
Armin Ghoreishi
  • 56
  • 2
  • 12
  • please take a look at this answer http://stackoverflow.com/questions/27186726/java-lang-unsatisfiedlinkerror-dalvik-system-pathclassloader – Armin Ghoreishi Oct 02 '15 at 22:20