How to Upgrade
From Version 9.x to 10.x
Dynamsoft Barcode Reader SDK has been refactored to integrate with DynamsoftCaptureVision (DCV)
architecture. To upgrade from version 9.x or earlier to 10.x, we recommend you to follow the User Guide and re-write your codes.
Update the Libraries
The Dynamsoft Barcode Reader SDK has been split into multiple libraries from the previous single library, and the dependency configuration in the app\build.gradle
file needs to be updated accordingly.
Option 1: Add the Library via Maven
-
Open the file
[App Project Root Path]\app\build.gradle
and add the Maven repository:allprojects { repositories { maven { url "https://download2.dynamsoft.com/maven/aar" } } }
-
Add the references in the dependencies:
dependencies { implementation 'com.dynamsoft:dynamsoftbarcodereaderbundle:{version-number}' }
Note: Please view user guide for the correct version number.
-
Click Sync Now. After the synchronization is complete, the SDK is added to the project.
Option 2: Add the Libraries via Local .aar Files
-
Download the SDK package from the Dynamsoft Website. After unzipping, you should find a single aar file can be found in the Dynamsoft\Libs directory:
- 📄 DynamsoftBarcodeReaderBundle.aar
- 📄 DynamsoftCaptureVisionRouter.aar
- 📄 DynamsoftCameraEnhancer.aar
- 📄 DynamsoftBarcodeReader.aar
- 📄 DynamsoftCore.aar
- 📄 DynamsoftLicense.aar
- 📄 DynamsoftImageProcessing.aar
- 📄 DynamsoftUtility.aar
-
Copy the above aar file to the target directory such as
[App Project Root Path]\app\libs
-
Open the file
[App Project Root Path]\app\build.gradle
and add the reference in the dependencies:dependencies { implementation fileTree(dir: 'libs', include: ['*.aar']) def camerax_version = '1.1.0' implementation "androidx.camera:camera-core:$camerax_version" implementation "androidx.camera:camera-camera2:$camerax_version" implementation "androidx.camera:camera-lifecycle:$camerax_version" implementation "androidx.camera:camera-view:$camerax_version" }
Update the Template File
The template system is upgraded. The template you used for the previous version can’t be directly recognized by the new version. Please download the TemplateConverter tool or contact us to upgrade your template.
Update your code
You have 2 Options when updating your code.
- Update to New APIs with the foundational SDK
- Quick start a new project with BarcodeScanner Component
Option 1. Update to New APIs with the foundational SDK
Update the License Activation Code
Starting from 10.0, we have unified the API for setting licenses across different Dynamsoft products.
Old APIs | New APIs |
---|---|
BarcodeReader.initLicense |
LicenseManager.initLicense |
- Java code in 9.x:
BarcodeReader.initLicense("Put your license", new DBRLicenseVerificationListener() {
@Override
public void DBRLicenseVerificationCallback(boolean isSuccess, Exception error) {
if(!isSuccess){
error.printStackTrace();
}
}
});
- Java code in 10.x:
LicenseManager.initLicense("Put your license", this, new LicenseVerificationListener() {
@Override
public void onLicenseVerified(boolean isSuccess, Exception error) {
if(!isSuccess){
error.printStackTrace();
}
}
});
Update Single Image Decoding APIs
The APIs for decoding single image has been adjusted as follows:
Old APIs | New APIs |
---|---|
BarcodeReader.decodeFile |
CaptureVisionRouter.capture(String filePath, String templateName) |
BarcodeReader.decodeFileInMemory |
CaptureVisionRouter.capture(byte[] fileBytes, String templateName) |
BarcodeReader.decodeBuffer |
CaptureVisionRouter.capture(ImageData imageData, String templateName) |
BarcodeReader.decodeBufferedImage |
CaptureVisionRouter.capture(Bitmap bitmap, String templateName) |
class TextResult |
class BarcodeResultItem |
BarcodeReader.decodeBase64String |
Currently not available. |
Update Video Streaming Decoding APIs
The APIs for decoding video frames has been adjusted as follows:
Old APIs | New APIs |
---|---|
BarcodeReader.setImageSource |
CaptureVisionRouter.setInput |
BarcodeReader.startScanning |
CaptureVisionRouter.startCapturing |
BarcodeReader.stopScanning |
CaptureVisionRouter.stopCapturing |
BarcodeReader.setTextResultListener |
CaptureVisionRouter.addResultReceiver |
BarcodeReader.setIntermediateResultListener |
CaptureVisionRouter.IntermediateResultManager.addResultReceiver |
BarcodeReader.set/getMinImageReadingInterval |
SimplifiedCaptureVisionSettings.minImageCaptureInterval |
BarcodeReader.enableResultVerification |
MultiFrameResultCrossFilter.enableResultCrossVerification |
BarcodeReader.enableDuplicateFilter |
MultiFrameResultCrossFilter.enableResultDeduplication |
interface ImageSource |
interface ImageSourceAdapter |
interface TextResultListener |
interface CapturedResultReceiver |
interface IntermediateResultListener |
interface IntermediateResultReceiver |
class TextResult |
class BarcodeResultItem |
Migrate Your Templates
The template-based APIs have been updated as follows:
Old APIs | New APIs |
---|---|
BarcodeReader.initRuntimeSettingsWithFile |
CaptureVisionRouter.initSettingsFromFile |
BarcodeReader.initRuntimeSettingsWithString |
CaptureVisionRouter.initSettings |
BarcodeReader.outputSettingsToFile |
CaptureVisionRouter.outputSettingsToFile |
BarcodeReader.outputSettingsToString |
CaptureVisionRouter.outputSettings |
BarcodeReader.resetRuntimeSettings |
CaptureVisionRouter.resetSettings |
BarcodeReader.appendTplFileToRuntimeSettings |
Not available. |
BarcodeReader.appendTplStringToRuntimeSettings |
Not available. |
Migrate Your PublicRuntimeSettings
The class PublicRuntimeSettings
has been refactored. It retains commonly used properties while removing the previously complex property settings, which are now exclusively supported through templates.
The APIs for accessing and updating PublicRuntimeSettings
has been adjusted as follows:
Old APIs | New APIs |
---|---|
BarcodeReader.getRuntimeSettings |
CaptureVisionRouter.getSimplifiedSettings |
BarcodeReader.updateRuntimeSettings |
CaptureVisionRouter.updateSettings |
Migrate to SimplifiedCaptureVisionSettings
The following properties are replaced by similar properties under SimplifiedCaptureVisionSettings
. They can also be set via a template file(String).
PublicRuntimeSettings Property | SimplifiedCaptureVisionSettings Property | Template File Parameter |
---|---|---|
region |
roi & roiMeasuredInPercentage |
TargetROIDef.Location.Offset |
timeout |
timeout |
CaptureVisionTemplates.Timeout |
Migrate to SimplifiedBarcodeReaderSettings
The following properties are replaced by similar properties under SimplifiedBarcodeReaderSettings
. The majority of them can also be set via a template file(String).
PublicRuntimeSettings Property | SimplifiedBarcodeReaderSettings Property | Template File Parameter |
---|---|---|
minBarcodeTextLength |
minBarcodeTextLength |
BarcodeFormatSpecification.BarcodeTextLengthRangeArray |
minResultConfidence |
minResultConfidence |
BarcodeFormatSpecification.MinResultConfidence |
localizationModes |
localizationModes |
BarcodeReaderTaskSetting.LocationModes |
expectedBarcodesCount |
expectedBarcodesCount |
BarcodeReaderTaskSetting.ExpectedBarcodesCount |
barcodeFormatIds |
barcodeFormatIds |
BarcodeReaderTaskSetting.BarcodeFormatIds |
barcodeFormatIds_2 |
barcodeFormatIds |
BarcodeReaderTaskSetting.BarcodeFormatIds |
deblurModes |
deblurModes |
BarcodeReaderTaskSetting.DeblurModes |
deblurLevel |
deblurModes |
BarcodeReaderTaskSetting.DeblurModes |
maxAlgorithmThreadCount |
maxThreadsInOneTask |
BarcodeReaderTaskSetting.MaxThreadsInOneTask |
Remarks:
- The 2 groups of barcode formats are merged.
DeblurLevel
is deprecated. You can useDeblurModes
instead.
FurtherModes Property | SimplifiedBarcodeReaderSettings Property | Template File Parameter |
---|---|---|
grayscaleTransformationModes |
grayscaleTransformationModes |
ImageParameter.GrayscaleTransformationModes |
imagePreprocessingModes |
grayscaleEnhancementModes |
ImageParameter.GrayscaleEnhancementModes |
scaleDownThreshold |
scaleDownThreshold |
ImageParameter.ScaleDownThreshold |
Remarks: The mode
IPM_MORPHOLOGY
ofimagePreprocessingModes
is migrated toBinarizationModes
. The mode argumentsMorphOperation
,MorphOperationKernelSizeX
,MorphOperationKernelSizeY
,MorphShape
are now available for all modes ofBinarizationModes
.
Migrate to Template File
The following properties can only be set via a template file. Please contact us so that we can help you to transform your current settings to a new template file.
PublicRuntimeSettings Property | Template File Parameter |
---|---|
binarizationModes |
ImageParameter.BinarizationModes |
textResultOrderModes |
BarcodeReaderTaskSetting.TextResultOrderModes |
returnBarcodeZoneClarity |
BarcodeReaderTaskSetting.ReturnBarcodeZoneClarity |
scaleUpModes |
ImageParameter.ScaleUpModes |
barcodeZoneMinDistanceToImageBorders |
BarcodeFormatSpecification.BarcodeZoneMinDistanceToImageBorders |
terminatePhase |
BarcodeReaderTaskSetting.TerminateSettings |
PublicRuntimeSettings.furtherModes Property | Template File Parameter |
---|---|
colourConversionModes |
ImageParameter.ColourConversionModes |
regionPredetectionModes |
ImageParameter.RegionPredetectionModes |
textureDetectionModes |
ImageParameter.TextureDetectionModes |
textFilterModes |
ImageParameter.TextDetectionMode & ImageParameter.IfEraseTextZone |
dpmCodeReadingModes |
BarcodeReaderTaskSetting.DPMCodeReadingModes |
deformationResistingModes |
BarcodeReaderTaskSetting.DeformationResistingModes |
barcodeComplementModes |
BarcodeReaderTaskSetting.BarcodeComplementModes |
barcodeColourModes |
BarcodeReaderTaskSetting.BarcodeColourModes |
Migrate to Other APIs
The Intermediate Result
system is redesigned and the following properties are deprecated.
PublicRuntimeSettings Property |
---|
intermediateResultTypes |
intermediateResultSavingMode |
Removed
The following properties are removed.
PublicRuntimeSettings Property |
---|
resultCoordinateType |
FurtherModes Property |
---|
colourClusteringModes |
Option 2. Quick start a new project with BarcodeScanner Component
BarcodeScanner
is a ready-to-use component that allows developers to quickly set up a barcode scanning app. With the built-in BarcodeScannerActivity
, it streamlines the integration of barcode scanning functionality into any application.