Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ZBar - QR Code Scanner, crashing in Android Studio

I have downloaded from git latest zBar QR Code Scanner (SDK 0.2). I am trying to implement it in my application. I work on Android Studio.

What have I done:

  1. I have copied zBar.jar to libs folder of my Project.
  2. I have created *.jar files from "amerabi", "amerabi-v7a", "x86" by zip'ing them and changing their format to *.jar.
  3. I have copied amerabi.jar, amerabi-v7a.jar and x86.jar to libs folder of my Project.
  4. There is no need to change anything in gradle because it is already configured to import every jar file from libs projects. See below:

    dependencies {
        compile 'com.android.support:support-v4:18.0.+'
        compile 'com.crashlytics.android:crashlytics:1.+'
    
        compile fileTree(dir: 'libs', include: '*.jar')
    
        compile project(':FacebookSDK')
        compile project(':actionbarsherlock')
        compile project(':Aviary-SDK')
    }
    
  5. Every class form zBar lib can be seen so I have configured everything. I run my ScannerActivity and in onCreate I get error in this line:

    scanner = new ImageScanner();  // this line shows an error
    scanner.setConfig(0, Config.X_DENSITY, 3);
    scanner.setConfig(0, Config.Y_DENSITY, 3);
    

So implementation is 1:1 the same as in example.

My error log:

java.lang.UnsatisfiedLinkError: Couldn't load zbarjni from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/pl.toptof.android.debug-2.apk"],nativeLibraryDirectories=[/data/app-lib/pl.toptof.android.debug-2, /vendor/lib, /system/lib]]]: findLibrary returned null

Please help me with that problem. I don't know why my Android Studio can see lib but can't use it in the same way it's used in example.

like image 474
F1sher Avatar asked Dec 11 '13 16:12

F1sher


2 Answers

I think, you made mistake in your jars structures. If you want to make jar package from *.so libs you should use that kind of structure:

/lib/armeabi/*.so

It is directory structure example for your library:

lib/
---/armeabi
------/libiconv.so
------/libzbarjni.so

and of course you should rename final package from lib.zip to armeabi.jar. In your case you should repeat this process for armeabi-v7a and x86.

like image 91
froger_mcs Avatar answered Oct 05 '22 13:10

froger_mcs


The solution is too complicated. What I did to get it working, was to use the jar files already compiled in the example solution from this example. Copy them to your lib folder and make sure to also add them in the gradle file. However, your line compile fileTree(dir: 'libs', include: '*.jar') should do the trick.

like image 38
7heViking Avatar answered Oct 05 '22 11:10

7heViking