|
| 1 | +--- |
| 2 | +title: Migrating to v6.0 |
| 3 | +sidebar_label: Migrating to v6.0 |
| 4 | +--- |
| 5 | + |
| 6 | +import Tabs from '@theme/Tabs' |
| 7 | +import TabItem from '@theme/TabItem' |
| 8 | + |
| 9 | + |
| 10 | +This latest release represents a major update to the extension. The scanning algorithm has been completely rewritten to improve performance and accuracy. |
| 11 | +The aging ZBar SDK has been removed in favour of **MLKit** on Android and the **Vision framework** on iOS. |
| 12 | + |
| 13 | +As part of the update we have improved the permission process and broadcast receiver usage to meet the updated android API 34 requirements. |
| 14 | + |
| 15 | +Additionally we have implemented an asynchronous bitmap data scanning process which allows you to scan large images without blocking the main thread. |
| 16 | + |
| 17 | +Overall this update should provide a much better experience for your users and improve the reliability of scanning barcodes in your applications. |
| 18 | + |
| 19 | + |
| 20 | +## Migration |
| 21 | + |
| 22 | +<Tabs |
| 23 | + groupId="packagemanager" |
| 24 | + defaultValue="apm" |
| 25 | + values={[ |
| 26 | + {label: 'APM', value: 'apm'}, |
| 27 | + {label: 'Manual', value: 'manual'}, |
| 28 | + ]}> |
| 29 | + |
| 30 | + <TabItem value="apm" > |
| 31 | + |
| 32 | +If you are using [`apm`](https://github.com/airsdk/apm) all you need to do is update to the latest build and regenerate your application descriptor. `apm` will handle the rest. |
| 33 | + |
| 34 | +``` |
| 35 | +apm update |
| 36 | +apm generate app-descriptor |
| 37 | +``` |
| 38 | + |
| 39 | + </TabItem> |
| 40 | + <TabItem value="manual" > |
| 41 | + |
| 42 | +If you are manually managing your application descriptor (and manifest additions) then you will be required to make some changes to your manifest. Find the activity: |
| 43 | + |
| 44 | +```xml |
| 45 | +<activity |
| 46 | + android:name="com.distriqt.extension.scanner.zbar.ZBarScannerActivity" |
| 47 | + android:exported="false"/> |
| 48 | +``` |
| 49 | + |
| 50 | +And replace it with: |
| 51 | + |
| 52 | +```xml |
| 53 | +<activity |
| 54 | + android:name="com.distriqt.extension.scanner.mlkit.ScannerActivity" |
| 55 | + android:exported="false" |
| 56 | + android:theme="@style/ScannerActivityTheme" |
| 57 | + android:configChanges="orientation|screenSize|screenLayout" /> |
| 58 | +``` |
| 59 | + |
| 60 | + |
| 61 | +Increase the minimum SDK version to 21: |
| 62 | + |
| 63 | +```xml |
| 64 | +<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="34"/> |
| 65 | +``` |
| 66 | + |
| 67 | + |
| 68 | + </TabItem> |
| 69 | + |
| 70 | +</Tabs> |
| 71 | + |
| 72 | + |
| 73 | +:::note New Algorithms |
| 74 | +The new scanning algorithms are significantly different from the previous ZBar implementation. |
| 75 | +You may need to adjust your code to accommodate the new API and behavior. |
| 76 | +In particular the orientation of the scanned results is no longer available and will always be 'unknown'. |
| 77 | +::: |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | +## Android Gradle Version |
| 82 | + |
| 83 | +We have updated the required gradle version used to build your application to be higher than the default AIR currently uses. |
| 84 | + |
| 85 | +To specify a higher version add the following to your android node in your application descriptor: |
| 86 | + |
| 87 | +```xml |
| 88 | +<android> |
| 89 | + <gradleVersion>8.9</gradleVersion> |
| 90 | + <androidGradlePluginVersion>8.7.3</androidGradlePluginVersion> |
| 91 | + |
| 92 | + ... |
| 93 | +</android> |
| 94 | +``` |
| 95 | + |
| 96 | +If you don't do this you will see the following error when building your application: |
| 97 | + |
| 98 | +``` |
| 99 | +Unexpected failure: Unable to run java: com.adobe.air.ADTException: gradle tool failed: |
| 100 | +FAILURE: Build failed with an exception. |
| 101 | +
|
| 102 | +... |
| 103 | +
|
| 104 | + > BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 65 |
| 105 | +``` |
| 106 | + |
| 107 | +:::note |
| 108 | +June 2025: This is not currently automatically handled by `apm` so you will need to add this manually to your application descriptor. |
| 109 | + |
| 110 | +We are working on an update to handle this. |
| 111 | +::: |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | +## Asynchronous Scanning |
| 116 | + |
| 117 | +The new scanning process allows you to scan large images without blocking the main thread. This is particularly useful for applications that need to scan high-resolution images or perform other tasks while scanning. |
| 118 | + |
| 119 | +```actionscript |
| 120 | +Scanner.service.scanBitmapAsync( |
| 121 | + image.bitmapData, |
| 122 | + function ( scanResults:Vector.<ScanResult> ):void |
| 123 | + { |
| 124 | + // Handle the scan results |
| 125 | + for each ( var result:ScanResult in scanResults ) |
| 126 | + { |
| 127 | + trace( "Code found: " + result.data ); |
| 128 | + }, |
| 129 | + function ( error:Error ):void |
| 130 | + { |
| 131 | + // process the error |
| 132 | + } |
| 133 | +); |
| 134 | +``` |
| 135 | + |
0 commit comments