Integrate ZXing QR code scanner without installing BarCode Scanner

后端 未结 7 1374
忘掉有多难
忘掉有多难 2020-12-02 13:39

I am trying to Integrate ZXing QR Code into my android app without installing BarCode Scanner app, I have followed the steps as:

1) Firstly I have downloaded ZXing.z

相关标签:
7条回答
  • 2020-12-02 13:58

    For all those Android Studio/Gradle users out there

    Okay guys, as my task today was to integrate ZXING into an Android application and there were no good sources for input all over, I will give you a hint what made my be successful - cause it turned out to be very easy (on version 2.*).

    There is a real handy git repository that provides the zxing android library project as an AAR archive.

    • https://github.com/embarkmobile/zxing-android-minimal

    All you have to do is add this to your build.gradle

    repositories {
        mavenCentral()
    
        maven {
            url "https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven-repository/"
        }
    }
    
    dependencies {
        compile 'com.google.zxing:core:2.2'
        compile 'com.embarkmobile:zxing-android-minimal:1.2.1@aar'
    }
    

    and Gradle does all the magic to compile the code and makes it accessible in your app.

    To start the Scanner afterwards, use this class/method:

    IntentIntegrator.initiateScan(this);    // `this` is the current Activity
    

    If you already visited the link you gonna see that i just copy&pasted the code from there the git readme. If not go there to get some more insight and code examples!

    Hope to be helpful for future readers. Peace :)

    0 讨论(0)
  • 2020-12-02 13:59

    You need to follow step as given by the link

    http://www.androidaz.com/development/zxing-qr-reader-direct-integration

    you can download core.jar from

    http://repo1.maven.org/maven2/com/google/zxing/core/2.2/

    The above is working for me, if your program still just put the core-2.2.jar in libs and clean your project

    0 讨论(0)
  • 2020-12-02 13:59

    MaterialBarcodeScanner: Easy to use barcode reader for your Android Project (Uses Google Mobile Vision API).

    1. Provide gradle dependency

      compile 'com.edwardvanraak:MaterialBarcodeScanner:0.0.6-ALPHA'

    2. Build a MaterialBarcodeScanner

      private void startScan() {
          /**
           * Build a new MaterialBarcodeScanner
           */
          final MaterialBarcodeScanner mBarcodeScanner 
                   = new MaterialBarcodeScannerBuilder()
                  .withActivity(MainActivity.this)
                  .withEnableAutoFocus(true)
                  .withBleepEnabled(true)
                  .withBackfacingCamera()
                  .withText("Scanning...")
                  .withResultListener(new MaterialBarcodeScanner.OnResultListener() {
                      @Override
                      public void onResult(Barcode barcode) {
                          barcodeResult = barcode;
                          result.setText(barcode.rawValue);
                      }
                  })
                  .build();
          mBarcodeScanner.startScan();
      }
      
    3. Hook it up to a button

      fab.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
       startScan();
      }
      });
      
    4. Start scanning!

    0 讨论(0)
  • 2020-12-02 14:02

    Step by step to setup zxing 3.2.1 in eclipse

    1. Download zxing-master.zip from "https://github.com/zxing/zxing"
    2. Unzip zxing-master.zip, Use eclipse to import "android" project in zxing-master
    3. Download core-3.2.1.jar from "http://repo1.maven.org/maven2/com/google/zxing/core/3.2.1/"
    4. Create "libs" folder in "android" project and paste cor-3.2.1.jar into the libs folder
    5. Click on project: choose "properties" -> "Java Compiler" to change level to 1.7. Then click on "Android" change "Project build target" to android 4.4.2+, because using 1.7 requires compiling with Android 4.4
    6. If "CameraConfigurationUtils.java" don't exist in "zxing-master/android/app/src/main/java/com/google/zxing/client/android/camera/". You can copy it from "zxing-master/android-core/src/main/java/com/google/zxing/client/android/camera/" and paste to your project.
    7. Clean and build project. If your project show error about "switch - case", you should change them to "if - else".
    8. Completed. Clean and build project. You can click on "Proprties" > "Android" > click on "Is Libraries" to use for your project
    0 讨论(0)
  • 2020-12-02 14:03

    Finally I got the answer,

    As of ADT 14,the resource fields(such as R.id.decode) are no longer constants when defined in library projects

    So in the ZXing library->android->com.google.zxing.client.android.CaptureActivityHandler.java and DecodeHandler.java

    Replace both of these classes switch case statements with if-else,and then import this ZXing library into your project..

    Rest of the coding of my own project is same...just the problem with the library classes as these are not updated as according to ADT 14..

    Kanika

    0 讨论(0)
  • 2020-12-02 14:04
    1. After importing Zxing as existing project, Properties > Java Buildpath > Check "is library" (check button) and then try to add Zxing as library.

    2. Make sure webclass.class exist in your QRcodesampleActivity.java

    0 讨论(0)
提交回复
热议问题