Android Studio 3.6
Android 6.0
app/build.gradle :
android {
//viewBinding.enabled = true
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
minSdkVersion 23
targetSdkVersion 29
versionCode 2
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') { transitive = true; }
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-rc01'
implementation 'com.google.android.material:material:1.2.0-alpha01'
implementation 'com.google.zxing:core:3.4.0'
implementation 'org.altbeacon:android-beacon-library:2.16.3'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
implementation 'androidx.viewpager2:viewpager2:1.0.0-beta05'
implementation 'com.journeyapps:zxing-android-embedded:4.0.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation "androidx.core:core-ktx:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
dans mon activité
class QRScanActivity : RootActivity() {
private lateinit var dataBinding: QrScanActivityBinding
private val REQUEST_PERMISSION = "REQUEST_PERMISSION"
private val REQUEST_CODE_CAMERA = 1
private lateinit var beepManager: BeepManager
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
dataBinding =
DataBindingUtil.setContentView<QrScanActivityBinding>(this, R.layout.qr_scan_activity)
dataBinding.setHandler(this)
init()
}
private fun initLogic() {
dataBinding.decoratedBarcodeView.decodeContinuous(object : BarcodeCallback {
override fun barcodeResult(result: BarcodeResult?) {
beepManager.playBeepSoundAndVibrate();
finish();
}
override fun possibleResultPoints(resultPoints: MutableList<ResultPoint>?) {
}
})
}
dans la présentation xml :
<com.journeyapps.barcodescanner.DecoratedBarcodeView
android:id="@+id/decoratedBarcodeView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="@dimen/default_margin"
app:layout_constraintBottom_toTopOf="@+id/qrButtonScan"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolBarContainer" />
Réussir le travail sur Android 9.0 . Bien.
Mais quand je commence à Android 6.0 J'obtiens une erreur :
10-28 16:28:35.145 D/com.myproject.ui.actviity.QRScanActivity( 2405): possibleResultPoints:
10-28 16:28:35.484 E/AndroidRuntime( 2405): FATAL EXCEPTION: DecoderThread
10-28 16:28:35.484 E/AndroidRuntime( 2405): Process: com.myproject.debug, PID: 2405
10-28 16:28:35.484 E/AndroidRuntime( 2405): java.lang.NoSuchMethodError: No interface method sort(Ljava/util/Comparator;)V in class Ljava/util/List; or its super classes (declaration of 'java.util.List' appears in /system/framework/core-libart.jar)
10-28 16:28:35.484 E/AndroidRuntime( 2405): at com.google.zxing.qrcode.detector.FinderPatternFinder.selectBestPatterns(FinderPatternFinder.java:616)
10-28 16:28:35.484 E/AndroidRuntime( 2405): at com.google.zxing.qrcode.detector.FinderPatternFinder.find(FinderPatternFinder.java:164)
10-28 16:28:35.484 E/AndroidRuntime( 2405): at com.google.zxing.qrcode.detector.Detector.detect(Detector.java:81)
10-28 16:28:35.484 E/AndroidRuntime( 2405): at com.google.zxing.qrcode.QRCodeReader.decode(QRCodeReader.java:77)
10-28 16:28:35.484 E/AndroidRuntime( 2405): at com.google.zxing.MultiFormatReader.decodeInternal(MultiFormatReader.java:173)
10-28 16:28:35.484 E/AndroidRuntime( 2405): at com.google.zxing.MultiFormatReader.decodeWithState(MultiFormatReader.java:87)
10-28 16:28:35.484 E/AndroidRuntime( 2405): at com.journeyapps.barcodescanner.Decoder.decode(Decoder.java:75)
10-28 16:28:35.484 E/AndroidRuntime( 2405): at com.journeyapps.barcodescanner.Decoder.decode(Decoder.java:49)
10-28 16:28:35.484 E/AndroidRuntime( 2405): at com.journeyapps.barcodescanner.DecoderThread.decode(DecoderThread.java:146)
10-28 16:28:35.484 E/AndroidRuntime( 2405): at com.journeyapps.barcodescanner.DecoderThread.access$000(DecoderThread.java:22)
10-28 16:28:35.484 E/AndroidRuntime( 2405): at com.journeyapps.barcodescanner.DecoderThread$1.handleMessage(DecoderThread.java:38)
10-28 16:28:35.484 E/AndroidRuntime( 2405): at android.os.Handler.dispatchMessage(Handler.java:98)
10-28 16:28:35.484 E/AndroidRuntime( 2405): at android.os.Looper.loop(Looper.java:148)
10-28 16:28:35.484 E/AndroidRuntime( 2405): at android.os.HandlerThread.run(HandlerThread.java:61)
10-28 16:28:35.486 W/ActivityManager( 780): Force finishing activity com.myproject.debug/com.myproject.ui.actviity.QRScanActivity
10-28 16:28:35.486 E/CrashlyticsCore( 2405): Error occurred sending report com.crashlytics.android.core.SessionReport@451f81a
10-28 16:28:35.487 E/CrashlyticsCore( 2405): Error occurred sending report com.crashlytics.android.core.SessionReport@e9abf4b
10-28 16:28:35.488 E/CrashlyticsCore( 2405): Error occurred sending report com.crashlytics.android.core.SessionReport@d2e7d28
10-28 16:28:35.491 D/CameraPreview( 2405): pause()