- compile 'com.google.android.gms:play-services-vision:11.0.2'
Now, we are going to include the Barcode Reader library to work correctly. First, we need to build the Gradle codes and Android Hive. Then, add Barcode Reader code to it.
- build.gradle
- dependencies {
-
- implementation 'info.androidhive:barcode-reader:1.1.5'
- implementation 'com.google.android.gms:play-services-vision:11.0.2'
- }
It is time to add Activity fragment to which we can invoke the Camera fragment.
- <fragment
- android:id="@+id/barcode_scanner"
- android:name="info.androidhive.barcode.BarcodeReader"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:auto_focus="true"
- app:use_flash="false" />
- This is code for Camera Actvity
Now, let's add the following code to work our project correctly and name it as BarcodeReader.BarcodeReader.java in class library.