ZBAR barcode scanning library not working when using target sdk version 23 in gradle

我们两清 提交于 2019-12-01 03:25:13

Solution that worked for me is as @Arst has mention in comment of above answer, download jniLibs folder and put it in your application from here. I've also replaced zbar.jar.

Your App is crashing because of following reason :

https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html

This release updates the behavior of the dynamic linker. The dynamic linker now understands the difference between a library’s soname and its path ( public bug 6670), and search by soname is now implemented. Apps which previously worked that have bad DT_NEEDED entries (usually absolute paths on the build machine’s file system) may fail when loaded.

The dlopen(3) RTLD_LOCAL flag is now correctly implemented. Note that RTLD_LOCAL is the default, so calls to dlopen(3) that didn’t explicitly use RTLD_LOCAL will be affected (unless your app explicitly used RTLD_GLOBAL). With RTLD_LOCAL, symbols will not be made available to libraries loaded by later calls to dlopen(3) (as opposed to being referenced by DT_NEEDED entries).

On previous versions of Android, if your app requested the system to load a shared library with text relocations, the system displayed a warning but still allowed the library to be loaded. Beginning in this release, the system rejects this library if your app's target SDK version is 23 or higher. To help you detect if a library failed to load, your app should log the dlopen(3) failure, and include the problem description text that the dlerror(3) call returns. To learn more about handling text relocations, see this guide.

Solution: make a folder lib in your android project inside that make a folder named as armeabi-v7a, put your .so file inside it. then load it via system.load(context.nativeLibraryDir + File.separator + ) , if it fails then use system.loadLibrary().

try this QRCodeReader for android api 23 (6.0 Marshmallow) this works fine. Add Camera permission on request. https://github.com/dlazaro66/QRCodeReaderView

public class DecoderActivity extends Activity implements OnQRCodeReadListener {

private TextView myTextView;
private QRCodeReaderView mydecoderview;

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

    mydecoderview = (QRCodeReaderView) findViewById(R.id.qrdecoderview);
    mydecoderview.setOnQRCodeReadListener(this);

    myTextView = (TextView) findViewById(R.id.exampleTextView);
}


// Called when a QR is decoded
// "text" : the text encoded in QR
// "points" : points where QR control points are placed
@Override
public void onQRCodeRead(String text, PointF[] points) {
    myTextView.setText(text);
}


// Called when your device have no camera
@Override
public void cameraNotFound() {

}

// Called when there's no QR codes in the camera preview image
@Override
public void QRCodeNotFoundOnCamImage() {

}

@Override
protected void onResume() {
    super.onResume();
    mydecoderview.getCameraManager().startPreview();
}

@Override
protected void onPause() {
    super.onPause();
    mydecoderview.getCameraManager().stopPreview();
}

}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!