Scandit无法在Android Studio中工作(仅适用于Eclipse)
作者:互联网
我正在尝试让Scandit在Android Studio中工作 – 我使用eclipse,但是当我在android studio中尝试时,我得到了一个UnsatisfiedLinkError.
我使用的版本是scandit SDK社区android 3.5.2.用android studio 0.3.7和android 4.4 kitkat.
我在android studio(最新版本)中按照我用于eclipse测试用例的相同步骤尝试了它,但我的应用程序崩溃了. logcat显示:
java.lang.UnsatisfiedLinkError: Couldn't load scanditsdk-android-3.5.2 from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.zipier.qr_scanner_scandit-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.zipier.qr_scanner_scandit-1, /vendor/lib, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at com.mirasense.scanditsdk.ScanditSDKBarcodePicker.initializeRecognitionEngine(ScanditSDKBarcodePicker.java:1298)
at com.mirasense.scanditsdk.ScanditSDKBarcodePicker.<init>(ScanditSDKBarcodePicker.java:330)
at com.mirasense.scanditsdk.ScanditSDKAutoAdjustingBarcodePicker.<init>(ScanditSDKAutoAdjustingBarcodePicker.java:59)
at com.zipier.qr_scanner_scandit.MainActivity.initializeAndStartBarcodeScanning(MainActivity.java:41)
at com.zipier.qr_scanner_scandit.MainActivity.onCreate(MainActivity.java:21)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
这是我的源代码:
public class MainActivity extends Activity implements ScanditSDKListener {
private ScanditSDK mBarcodePicker;
public static final String sScanditSdkAppKey = "pQqIxjG4EeOA8nxhinmFTJUHoJZP168Vn1rCM65paHw";
static {
System.loadLibrary("libscanditsdk-android-3.5.2");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initializeAndStartBarcodeScanning();
}
@Override
protected void onPause() {
mBarcodePicker.stopScanning();
super.onPause();
}
@Override
protected void onResume() {
mBarcodePicker.startScanning();
super.onResume();
}
public void initializeAndStartBarcodeScanning() {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
ScanditSDKAutoAdjustingBarcodePicker picker = new ScanditSDKAutoAdjustingBarcodePicker(this, sScanditSdkAppKey, ScanditSDKAutoAdjustingBarcodePicker.CAMERA_FACING_FRONT);
setContentView(picker);
mBarcodePicker = picker;
mBarcodePicker.getOverlayView().addListener(this);
}
public void didScanBarcode(String barcode, String symbology) {
String cleanedBarcode = "";
for (int i = 0; i < barcode.length(); i++) {
if (barcode.charAt(i) > 30) {
cleanedBarcode += barcode.charAt(i);
}
}
if (symbology.equals("QR")) {
Toast.makeText(this, cleanedBarcode, Toast.LENGTH_LONG).show();
}
}
@Override
public void didCancel() {
mBarcodePicker.stopScanning();
finish();
}
@Override
public void onBackPressed() {
mBarcodePicker.stopScanning();
finish();
}
@Override
public void didManualSearch(String arg0) {
// TODO Auto-generated method stub
}
}
解决方法:
它现在正在运作.莫里茨对Scandit团队的帮助很大.他给我发了这个链接:https://stackoverflow.com/a/17730219.
这是修复:
>将.so放在lib / armeabi文件夹结构中(lib不是libs)
>拉链
>将其添加到项目的libs文件夹中
>更改build.gradle文件以进行编译
在我的测试中,Scandit比其他qr代码阅读器(如zxing)工作得更好,更快.
标签:barcode-scanner,android,android-studio 来源: https://codeday.me/bug/20190831/1774322.html