Форум программистов, компьютерный форум, киберфорум
Программирование Android
Войти
Регистрация
Восстановить пароль
 
Рейтинг 4.75/4: Рейтинг темы: голосов - 4, средняя оценка - 4.75
0 / 0 / 0
Регистрация: 20.12.2015
Сообщений: 83
1

Сканер QR - как из превью отправить картинку на анализ

22.01.2020, 18:22. Просмотров 651. Ответов 12

Всем привет. Пытаюсь следуя руководству https://firebase.google.com/do... d-barcodes написать сканер qr, но не могу понять как из превью отправить картинку в анализ.

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package com.barcodescaner
 
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.Manifest
import android.content.pm.PackageManager
import android.util.Size
import android.graphics.Matrix
import android.view.*
import android.widget.Toast
import androidx.camera.core.*
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import com.google.firebase.ml.vision.barcode.FirebaseVisionBarcode
import com.google.firebase.ml.vision.barcode.FirebaseVisionBarcodeDetectorOptions
 
import java.util.concurrent.Executors
 
 
private const val REQUEST_CODE_PERMISSIONS = 10
 
const val FLAGS_FULLSCREEN =
    View.SYSTEM_UI_FLAG_LOW_PROFILE or
            View.SYSTEM_UI_FLAG_FULLSCREEN or
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
            View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or
            View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
            View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
 
// This is an array of all the permission specified in the manifest.
private val REQUIRED_PERMISSIONS = arrayOf(Manifest.permission.CAMERA)
 
val optionsBundle =  FirebaseVisionBarcodeDetectorOptions.Builder().setBarcodeFormats(
    FirebaseVisionBarcode.FORMAT_ALL_FORMATS
)
 
 
val analyser:ImageAnalyser= ImageAnalyser()
 
class LiveScan : AppCompatActivity() {
 
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
                setContentView(R.layout.activity_live_scan)
        viewFinder= findViewById(R.id.view_finder)
        viewFinder.systemUiVisibility= FLAGS_FULLSCREEN
 
 
 
        if (allPermissionsGranted()){
            viewFinder.post(){startCamera()
 
            }
 
            }
        else{ActivityCompat.requestPermissions(this, REQUIRED_PERMISSIONS,
            REQUEST_CODE_PERMISSIONS)}
        viewFinder.addOnLayoutChangeListener{ _, _, _, _, _, _, _, _, _ ->
        updateTransform()}
 
 
 
    }
 
    private val executor = Executors.newSingleThreadExecutor()
    private lateinit var viewFinder: TextureView
 
    private fun startCamera() {
        val previewConfig = PreviewConfig.Builder().apply {
            setTargetResolution(Size(viewFinder.width, viewFinder.height))
        }.build()
 
 
        // Build the viewfinder use case
        val preview = Preview(previewConfig)
 
 
 
        // Every time the viewfinder is updated, recompute layout
        preview.setOnPreviewOutputUpdateListener {
 
            // To update the SurfaceTexture, we have to remove it and re-add it
            val parent = viewFinder.parent as ViewGroup
            parent.removeView(viewFinder)
            parent.addView(viewFinder, 0)
 
            viewFinder.surfaceTexture = it.surfaceTexture
            updateTransform()
        }
        val imageCaptureConfig= ImageCaptureConfig.Builder()
            .apply { setCaptureMode(ImageCapture.CaptureMode.MIN_LATENCY) }.build()
        // Bind use cases to lifecycle
        // If Android Studio complains about "this" being not a LifecycleOwner
        // try rebuilding the project or updating the appcompat dependency to
        // version 1.1.0 or higher.
        CameraX.bindToLifecycle(this, preview)
 
 
 
    }
 
 
 
 
 
    private fun updateTransform() {
        // TODO: Implement camera viewfinder transformations
        val matrix = Matrix()
 
        // Compute the center of the view finder
        val centerX = viewFinder.width / 2f
        val centerY = viewFinder.height / 2f
 
        // Correct preview output to account for display rotation
        val rotationDegrees = when(viewFinder.display.rotation) {
            Surface.ROTATION_0 -> 0
            Surface.ROTATION_90 -> 90
            Surface.ROTATION_180 -> 180
            Surface.ROTATION_270 -> 270
            else -> return
        }
        matrix.postRotate(-rotationDegrees.toFloat(), centerX, centerY)
 
        // Finally, apply transformations to our TextureView
        viewFinder.setTransform(matrix)
    }
 
    /**
     * Process result from permission request dialog box, has the request
     * been granted? If yes, start Camera. Otherwise display a toast
     */
    override fun onRequestPermissionsResult(
        requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
        if (requestCode == REQUEST_CODE_PERMISSIONS) {
            if (allPermissionsGranted()) {
                viewFinder.post { startCamera() }
            } else {
                Toast.makeText(this,
                    "Permissions not granted by the user.",
                    Toast.LENGTH_SHORT).show()
                finish()
            }
        }
    }
 
    /**
     * Check if all permission specified in the manifest have been granted
     */
    private fun allPermissionsGranted() = REQUIRED_PERMISSIONS.all {
        ContextCompat.checkSelfPermission(
            baseContext, it) == PackageManager.PERMISSION_GRANTED
    }
 
 
}
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.barcodescaner
 
import android.widget.Toast
import android.app.Activity
import androidx.camera.core.ImageAnalysis
import androidx.camera.core.ImageProxy
import com.google.firebase.ml.vision.FirebaseVision
import com.google.firebase.ml.vision.common.FirebaseVisionImage
import com.google.firebase.ml.vision.common.FirebaseVisionImageMetadata
 
     class ImageAnalyser: ImageAnalysis.Analyzer {
        private fun degreesToFirebaseRotation(degrees: Int): Int = when (degrees) {
            0 -> FirebaseVisionImageMetadata.ROTATION_0
            90 -> FirebaseVisionImageMetadata.ROTATION_90
            180 -> FirebaseVisionImageMetadata.ROTATION_180
            270 -> FirebaseVisionImageMetadata.ROTATION_270
            else -> throw Exception("Rotation must be 0, 90, 180, or 270.")
        }
 
        override fun analyze(imageProxy: ImageProxy?, degrees: Int) {
            val mediaImage = imageProxy?.image
            val imageRotation = degreesToFirebaseRotation(degrees)
 
            if (mediaImage != null) {
 
                val image = FirebaseVisionImage.fromMediaImage(mediaImage, imageRotation)
                val metadata= FirebaseVisionImageMetadata.Builder().setWidth(480)
                    .setHeight(360)
                    .setFormat(FirebaseVisionImageMetadata.IMAGE_FORMAT_NV21)
                    .setRotation(imageRotation).build()
                val detector = FirebaseVision.getInstance().visionBarcodeDetector
 
                val result = detector.detectInImage(image).addOnSuccessListener {barcodes->
                    for (barcode in barcodes){
                        val rawValue = barcode.rawValue
                        Toast.makeText(Activity(),rawValue.toString(),Toast.LENGTH_LONG).show()
                    }
 
                }.addOnFailureListener{
 
                }
 
            }
 
 
        }
    }

XML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".LiveScan"
    android:orientation="vertical">
    <TextureView
        android:id="@+id/view_finder"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent" />
 
</androidx.constraintlayout.widget.ConstraintLayout>

Помогите разобраться пожалуйста.

Добавлено через 3 часа 10 минут
Так, я так понимаю настроить camerax под imageanalasys забыл)
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
22.01.2020, 18:22
Ответы с готовыми решениями:

Как сделать превью товара (картинку) ссылку на товар, а не отображение самой картинки в появляющимся окошке?
Как сделать превью товара (картинку) ссылку на товар, а не отображение самой картинки в...

Как отправить картинку на почту
&lt;?php $title = substr(htmlspecialchars(trim($_POST)), 0, 1000); $mess = ...

Как отправить POST'ом картинку?
понять не могу в каком виде нужно прикреплять картинку к POST запросу. по идее этот пост запрос...

Как отправить на анализ просканированный комп программой AVZ?
Помогите удалить рекламные вирусы, банеры. При открытии какого-нибудь сайта вначале выскакивают...

12
0 / 0 / 0
Регистрация: 20.12.2015
Сообщений: 83
23.01.2020, 14:54  [ТС] 2
Эм, вроде нашел как сконектить, но почему то приложение вываливается при попытке создать detector.
Java
1
val detector = FirebaseVision.getInstance().visionBarcodeDetector
строка 200
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
package com.barcodescaner
 
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.Manifest
import android.app.Application
import android.content.pm.PackageManager
import android.util.Size
import android.graphics.Matrix
import android.view.*
import android.widget.Toast
import androidx.camera.core.*
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import com.google.firebase.ml.vision.FirebaseVision
import com.google.firebase.ml.vision.barcode.FirebaseVisionBarcode
import com.google.firebase.ml.vision.barcode.FirebaseVisionBarcodeDetectorOptions
import com.google.firebase.ml.vision.common.FirebaseVisionImage
import com.google.firebase.ml.vision.common.FirebaseVisionImageMetadata
 
import java.util.concurrent.Executors
 
 
private const val REQUEST_CODE_PERMISSIONS = 10
 
const val FLAGS_FULLSCREEN =
    View.SYSTEM_UI_FLAG_LOW_PROFILE or
            View.SYSTEM_UI_FLAG_FULLSCREEN or
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
            View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or
            View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
            View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
 
// This is an array of all the permission specified in the manifest.
private val REQUIRED_PERMISSIONS = arrayOf(Manifest.permission.CAMERA)
 
val optionsBundle =  FirebaseVisionBarcodeDetectorOptions.Builder().setBarcodeFormats(
    FirebaseVisionBarcode.FORMAT_ALL_FORMATS
)
 
 
 
 
class LiveScan : AppCompatActivity() {
 
 
 
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
                setContentView(R.layout.activity_live_scan)
        viewFinder= findViewById(R.id.view_finder)
        viewFinder.systemUiVisibility= FLAGS_FULLSCREEN
 
 
 
        if (allPermissionsGranted()){
            viewFinder.post(){startCamera()
 
            }
 
            }
        else{ActivityCompat.requestPermissions(this, REQUIRED_PERMISSIONS,
            REQUEST_CODE_PERMISSIONS)}
        viewFinder.addOnLayoutChangeListener{ _, _, _, _, _, _, _, _, _ ->
        updateTransform()}
 
 
 
    }
 
    private val executor = Executors.newSingleThreadExecutor()
    private lateinit var viewFinder: TextureView
 
    private fun startCamera() {
        val previewConfig = PreviewConfig.Builder().apply {
            setTargetResolution(Size(viewFinder.width, viewFinder.height))
        }.build()
 
 
        // Build the viewfinder use case
        val preview = Preview(previewConfig)
 
 
 
        // Every time the viewfinder is updated, recompute layout
        preview.setOnPreviewOutputUpdateListener {
 
            // To update the SurfaceTexture, we have to remove it and re-add it
            val parent = viewFinder.parent as ViewGroup
            parent.removeView(viewFinder)
            parent.addView(viewFinder, 0)
 
            viewFinder.surfaceTexture = it.surfaceTexture
            updateTransform()
        }
        val imageCaptureConfig= ImageCaptureConfig.Builder()
            .apply { setCaptureMode(ImageCapture.CaptureMode.MIN_LATENCY) }.build()
        // Bind use cases to lifecycle
        // If Android Studio complains about "this" being not a LifecycleOwner
        // try rebuilding the project or updating the appcompat dependency to
        // version 1.1.0 or higher.
 
 
        val analyzerConfig = ImageAnalysisConfig.Builder().apply {
            // In our analysis, we care more about the latest image than
            // analyzing *every* image
            setImageReaderMode(
                ImageAnalysis.ImageReaderMode.ACQUIRE_LATEST_IMAGE)
        }.build()
 
        // Build the image analysis use case and instantiate our analyzer
        val analyzerUseCase = ImageAnalysis(analyzerConfig).apply {
            setAnalyzer(executor, ImageAnalyser())
        }
        CameraX.bindToLifecycle( this, preview, analyzerUseCase)
 
 
 
    }
 
 
    private fun updateTransform() {
        // TODO: Implement camera viewfinder transformations
        val matrix = Matrix()
 
        // Compute the center of the view finder
        val centerX = viewFinder.width / 2f
        val centerY = viewFinder.height / 2f
 
        // Correct preview output to account for display rotation
        val rotationDegrees = when(viewFinder.display.rotation) {
            Surface.ROTATION_0 -> 0
            Surface.ROTATION_90 -> 90
            Surface.ROTATION_180 -> 180
            Surface.ROTATION_270 -> 270
            else -> return
        }
        matrix.postRotate(-rotationDegrees.toFloat(), centerX, centerY)
 
        // Finally, apply transformations to our TextureView
        viewFinder.setTransform(matrix)
    }
 
    /**
     * Process result from permission request dialog box, has the request
     * been granted? If yes, start Camera. Otherwise display a toast
     */
    override fun onRequestPermissionsResult(
        requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
        if (requestCode == REQUEST_CODE_PERMISSIONS) {
            if (allPermissionsGranted()) {
                viewFinder.post { startCamera() }
            } else {
                Toast.makeText(this,
                    "Permissions not granted by the user.",
                    Toast.LENGTH_SHORT).show()
                finish()
            }
        }
    }
 
    /**
     * Check if all permission specified in the manifest have been granted
     */
    private fun allPermissionsGranted() = REQUIRED_PERMISSIONS.all {
        ContextCompat.checkSelfPermission(
            baseContext, it) == PackageManager.PERMISSION_GRANTED
    }
 
 
 
 
 
 
 
 
class ImageAnalyser: ImageAnalysis.Analyzer {
 
 
 
    private fun degreesToFirebaseRotation(degrees: Int): Int = when (degrees) {
        0 -> FirebaseVisionImageMetadata.ROTATION_0
        90 -> FirebaseVisionImageMetadata.ROTATION_90
        180 -> FirebaseVisionImageMetadata.ROTATION_180
        270 -> FirebaseVisionImageMetadata.ROTATION_270
        else -> throw Exception("Rotation must be 0, 90, 180, or 270.")
    }
 
 
 
 
    override fun analyze(imageProxy: ImageProxy?, degrees: Int) {
 
        val mediaImage = imageProxy?.image
        val imageRotation = degreesToFirebaseRotation(degrees)
 
        if (mediaImage != null) {
            val image = FirebaseVisionImage.fromMediaImage(mediaImage, imageRotation)
 
            val detector = FirebaseVision.getInstance().visionBarcodeDetector
            val result = detector.detectInImage(image)
                .addOnSuccessListener { barcodes ->
                    // Task completed successfully
                    // ...
                }
                .addOnFailureListener {
                    // Task failed with an exception
                    // ...
                }
 
 
        }
    }
}
}
Не важно, где я его пытаюсь создать. Уходит в ImageAnalysisNonBlockingAnalyzer, на рисунке
0
Миниатюры
Сканер QR - как из превью отправить картинку на анализ  
1603 / 1335 / 291
Регистрация: 25.10.2009
Сообщений: 3,487
Записей в блоге: 2
24.01.2020, 13:29 3
Цитата Сообщение от killbit Посмотреть сообщение
но почему то приложение вываливается при попытке создать detector
А ошибка какая?
0
0 / 0 / 0
Регистрация: 20.12.2015
Сообщений: 83
24.01.2020, 13:36  [ТС] 4
А нет ошибки. Но приложение закрывается.
0
1603 / 1335 / 291
Регистрация: 25.10.2009
Сообщений: 3,487
Записей в блоге: 2
24.01.2020, 13:47 5
Цитата Сообщение от killbit Посмотреть сообщение
А нет ошибки. Но приложение закрывается.
Откройте ещё раз сразу же и будет ошибка
0
0 / 0 / 0
Регистрация: 20.12.2015
Сообщений: 83
24.01.2020, 13:57  [ТС] 6
Вечером). Есть мысль только пересоздать проект
0
1603 / 1335 / 291
Регистрация: 25.10.2009
Сообщений: 3,487
Записей в блоге: 2
24.01.2020, 14:05 7
А чем это поможет?) Нужно смотреть стектрейс
0
0 / 0 / 0
Регистрация: 20.12.2015
Сообщений: 83
24.01.2020, 18:05  [ТС] 8
Логично. В любом случае только вечером точную информацию смогу дать. Помойму чето на потоки была у него ругань. Смущает что действительно где его не пытался создать- все равно один результат. Может опять по зависимостям чего не так?

Добавлено через 3 часа 53 минуты
Кликните здесь для просмотра всего текста
01/24 18:01:31: Launching 'app' on Samsung Galaxy S7 API 26.
$ adb shell am start -n "com.barcodescaner/com.barcodescaner.LiveScan" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: com.barcodescaner.test | com.barcodescaner
Waiting for application to come online: com.barcodescaner.test | com.barcodescaner
Waiting for application to come online: com.barcodescaner.test | com.barcodescaner
Connecting to com.barcodescaner
Connected to the target VM, address: 'localhost:8605', transport: 'socket'
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
W/ActivityThread: Application com.barcodescaner is waiting for the debugger on port 8100...
I/System.out: Sending WAIT chunk
I/zygote: Debugger is active
I/System.out: Debugger has connected
I/System.out: waiting for debugger to settle...
I/chatty: uid=10089(u0_a89) com.barcodescaner identical 6 lines
I/System.out: waiting for debugger to settle...
I/System.out: debugger has settled (1340)
W/FirebaseApp: Default FirebaseApp failed to initialize because no default options were found. This usually means that com.google.gms:google-services was not applied to your gradle project.
I/FirebaseInitProvider: FirebaseApp initialization unsuccessful
D/Camera2Initializer: CameraX initializing with Camera2 ...
I/CameraManagerGlobal: Connecting to camera service
D/CameraRepository: Added camera: 0
D/UseCaseAttachState: Active and online use case: [] for camera: 0
D/CameraRepository: Added camera: 1
D/UseCaseAttachState: Active and online use case: [] for camera: 1
I/zygote: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener (android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2421)
at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor( ) (AppCompatDelegateImpl.java:779)
at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor( ) (AppCompatDelegateImpl.java:659)
at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView( int) (AppCompatDelegateImpl.java:552)
at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:161)
at void com.barcodescaner.LiveScan.onCreate(android.os.Bundle) (LiveScan.kt:51)
at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6975)
at void android.app.Instrumentation.callActivityOnCreate(android.app .Activity, android.os.Bundle) (Instrumentation.java:1213)
at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app .ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2770)
I/zygote: at void android.app.ActivityThread.handleLaunchActivity(android.app. ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
at void android.app.ActivityThread$H.handleMessage(android.os.Messag e) (ActivityThread.java:1593)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
at void android.os.Looper.loop() (Looper.java:164)
at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6541)
at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.barcodescaner-qwjUwCoccksrZf6rz51VUg==/base.apk"],nativeLibraryDirectories=[/data/app/com.barcodescaner-qwjUwCoccksrZf6rz51VUg==/lib/x86, /data/app/com.barcodescaner-qwjUwCoccksrZf6rz51VUg==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:93)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener (android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2421)
at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor( ) (AppCompatDelegateImpl.java:779)
at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor( ) (AppCompatDelegateImpl.java:659)
at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView( int) (AppCompatDelegateImpl.java:552)
at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:161)
at void com.barcodescaner.LiveScan.onCreate(android.os.Bundle) (LiveScan.kt:51)
at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6975)
at void android.app.Instrumentation.callActivityOnCreate(android.app .Activity, android.os.Bundle) (Instrumentation.java:1213)
at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app .ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2770)
at void android.app.ActivityThread.handleLaunchActivity(android.app. ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
at void android.app.ActivityThread$H.handleMessage(android.os.Messag e) (ActivityThread.java:1593)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
at void android.os.Looper.loop() (Looper.java:164)
at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6541)
at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:767)
Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener (android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2421)
at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor( ) (AppCompatDelegateImpl.java:779)
at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor( ) (AppCompatDelegateImpl.java:659)
at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView( int) (AppCompatDelegateImpl.java:552)
I/zygote: at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:161)
at void com.barcodescaner.LiveScan.onCreate(android.os.Bundle) (LiveScan.kt:51)
at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6975)
at void android.app.Instrumentation.callActivityOnCreate(android.app .Activity, android.os.Bundle) (Instrumentation.java:1213)
at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app .ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2770)
at void android.app.ActivityThread.handleLaunchActivity(android.app. ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
at void android.app.ActivityThread$H.handleMessage(android.os.Messag e) (ActivityThread.java:1593)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
at void android.os.Looper.loop() (Looper.java:164)
at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6541)
at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.barcodescaner-qwjUwCoccksrZf6rz51VUg==/base.apk"],nativeLibraryDirectories=[/data/app/com.barcodescaner-qwjUwCoccksrZf6rz51VUg==/lib/x86, /data/app/com.barcodescaner-qwjUwCoccksrZf6rz51VUg==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:93)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener (android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2421)
at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor( ) (AppCompatDelegateImpl.java:779)
at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor( ) (AppCompatDelegateImpl.java:659)
at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView( int) (AppCompatDelegateImpl.java:552)
at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:161)
at void com.barcodescaner.LiveScan.onCreate(android.os.Bundle) (LiveScan.kt:51)
at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6975)
at void android.app.Instrumentation.callActivityOnCreate(android.app .Activity, android.os.Bundle) (Instrumentation.java:1213)
at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app .ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2770)
at void android.app.ActivityThread.handleLaunchActivity(android.app. ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
at void android.app.ActivityThread$H.handleMessage(android.os.Messag e) (ActivityThread.java:1593)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
at void android.os.Looper.loop() (Looper.java:164)
at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6541)
at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:767)
Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener (android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2421)
at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor( ) (AppCompatDelegateImpl.java:779)
at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor( ) (AppCompatDelegateImpl.java:659)
at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView( int) (AppCompatDelegateImpl.java:552)
at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:161)
I/zygote: at void com.barcodescaner.LiveScan.onCreate(android.os.Bundle) (LiveScan.kt:51)
at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6975)
at void android.app.Instrumentation.callActivityOnCreate(android.app .Activity, android.os.Bundle) (Instrumentation.java:1213)
at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app .ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2770)
at void android.app.ActivityThread.handleLaunchActivity(android.app. ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
at void android.app.ActivityThread$H.handleMessage(android.os.Messag e) (ActivityThread.java:1593)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
at void android.os.Looper.loop() (Looper.java:164)
at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6541)
at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.barcodescaner-qwjUwCoccksrZf6rz51VUg==/base.apk"],nativeLibraryDirectories=[/data/app/com.barcodescaner-qwjUwCoccksrZf6rz51VUg==/lib/x86, /data/app/com.barcodescaner-qwjUwCoccksrZf6rz51VUg==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:93)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener (android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2421)
at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor( ) (AppCompatDelegateImpl.java:779)
at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor( ) (AppCompatDelegateImpl.java:659)
at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView( int) (AppCompatDelegateImpl.java:552)
at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:161)
at void com.barcodescaner.LiveScan.onCreate(android.os.Bundle) (LiveScan.kt:51)
at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6975)
at void android.app.Instrumentation.callActivityOnCreate(android.app .Activity, android.os.Bundle) (Instrumentation.java:1213)
at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app .ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2770)
at void android.app.ActivityThread.handleLaunchActivity(android.app. ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
at void android.app.ActivityThread$H.handleMessage(android.os.Messag e) (ActivityThread.java:1593)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
at void android.os.Looper.loop() (Looper.java:164)
at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6541)
at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:767)
D/OpenGLRenderer: HWUI GL Pipeline
D/: HostConnection::get() New Host Connection established 0x99e56e00, tid 2589
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 1
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
D/OpenGLRenderer: Swap behavior 0
D/EGL_emulation: eglCreateContext: 0x9a005480: maj 2 min 0 rcv 2
D/EGL_emulation: eglMakeCurrent: 0x9a005480: ver 2 0 (tinfo 0x9a003280)
I/Camera2CameraInfo: Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY
I/zygote: Do partial code cache collection, code=29KB, data=22KB
After code cache collection, code=29KB, data=22KB
Increasing code cache capacity to 128KB
D/Camera: Use cases [Preview:androidx.camera.core.Preview-a0318658-0b8c-4b02-b555-38d6d1eacd38, ImageAnalysis:androidx.camera.core.ImageAnalysis-23d08e61-5fc3-4061-9d04-b7bfeb825520] ONLINE for camera 0
D/UseCaseAttachState: Active and online use case: [] for camera: 0
D/Camera: Resetting Capture Session
D/EGL_emulation: eglMakeCurrent: 0x9a005480: ver 2 0 (tinfo 0x9a003280)
D/Camera: releasing session in state INITIALIZED
D/Camera: Transitioning camera internal state: INITIALIZED --> OPENING
Opening camera: 0
D/UseCaseAttachState: All use case: [androidx.camera.core.Preview-a0318658-0b8c-4b02-b555-38d6d1eacd38, androidx.camera.core.ImageAnalysis-23d08e61-5fc3-4061-9d04-b7bfeb825520] for camera: 0
I/zygote: Do partial code cache collection, code=54KB, data=41KB
After code cache collection, code=54KB, data=41KB
Increasing code cache capacity to 256KB
I/CameraManager: Using legacy camera HAL.
D/Camera: Use case Preview:androidx.camera.core.Preview-a0318658-0b8c-4b02-b555-38d6d1eacd38 ACTIVE for camera 0
D/UseCaseAttachState: Active and online use case: [androidx.camera.core.Preview-a0318658-0b8c-4b02-b555-38d6d1eacd38] for camera: 0
D/Camera: Use case ImageAnalysis:androidx.camera.core.ImageAnalysis-23d08e61-5fc3-4061-9d04-b7bfeb825520 ACTIVE for camera 0
D/UseCaseAttachState: Active and online use case: [androidx.camera.core.Preview-a0318658-0b8c-4b02-b555-38d6d1eacd38, androidx.camera.core.ImageAnalysis-23d08e61-5fc3-4061-9d04-b7bfeb825520] for camera: 0
D/Camera: CameraDevice.onOpened(): 0
Transitioning camera internal state: OPENING --> OPENED
D/UseCaseAttachState: All use case: [androidx.camera.core.Preview-a0318658-0b8c-4b02-b555-38d6d1eacd38, androidx.camera.core.ImageAnalysis-23d08e61-5fc3-4061-9d04-b7bfeb825520] for camera: 0
D/CaptureSession: Opening capture session.
I/CameraDeviceState: Legacy camera service transitioning to state CONFIGURING
I/RequestThread-0: Configure outputs: 2 surfaces configured.
D/Camera: app passed NULL surface
D/: HostConnection::get() New Host Connection established 0x99e6c7c0, tid 2607
D/EGL_emulation: eglCreateContext: 0x84ea14c0: maj 2 min 0 rcv 2
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
E/EGL_emulation: eglQueryContext 32c0 EGL_BAD_ATTRIBUTE
tid 2607: eglQueryContext(1873): error 0x3004 (EGL_BAD_ATTRIBUTE)
I/CameraDeviceState: Legacy camera service transitioning to state IDLE
D/CaptureSession: Attempting to send capture request onConfigured
Issuing request for session.
I/RequestQueue: Repeating capture request set.
W/LegacyRequestMapper: convertRequestMetadata - control.awbRegions setting is not supported, ignoring value
D/CaptureSession: CameraCaptureSession.onConfigured() mState=OPENED
CameraCaptureSession.onReady() OPENED
W/LegacyRequestMapper: convertRequestToMetadata - Ignoring android.lens.focusDistance false, only 0.0f is supported
D/: HostConnection::get() New Host Connection established 0x99e6c440, tid 2593
I/CameraDeviceState: Legacy camera service transitioning to state CAPTURING
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
D/: HostConnection::get() New Host Connection established 0x99e6cc00, tid 2540
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
D/: HostConnection::get() New Host Connection established 0x9a01fb40, tid 2610
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
I/chatty: uid=10089(u0_a89) CameraDeviceGLT identical 200 lines
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
I/zygote: Do full code cache collection, code=122KB, data=97KB
I/zygote: After code cache collection, code=121KB, data=79KB
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
I/chatty: uid=10089(u0_a89) CameraDeviceGLT identical 48 lines
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
I/chatty: uid=10089(u0_a89) CameraDeviceGLT identical 54 lines
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
I/zygote: Do partial code cache collection, code=122KB, data=84KB
I/zygote: After code cache collection, code=122KB, data=84KB
Increasing code cache capacity to 512KB
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
I/chatty: uid=10089(u0_a89) CameraDeviceGLT identical 152 lines
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
I/chatty: uid=10089(u0_a89) CameraDeviceGLT identical 58 lines
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
I/chatty: uid=10089(u0_a89) CameraDeviceGLT identical 779 lines
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
I/zygote: Do full code cache collection, code=244KB, data=156KB
After code cache collection, code=190KB, data=121KB
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
I/chatty: uid=10089(u0_a89) CameraDeviceGLT identical 21 lines
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
I/chatty: uid=10089(u0_a89) CameraDeviceGLT identical 318 lines
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
I/chatty: uid=10089(u0_a89) CameraDeviceGLT identical 829 lines
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
D/: HostConnection::get() New Host Connection established 0x9a01fdc0, tid 2611
D/EGL_emulation: eglMakeCurrent: 0x84ea14c0: ver 2 0 (tinfo 0x87f64500)
A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0xc in tid 2611 (pool-1-thread-1)
Disconnected from the target VM, address: 'localhost:8605', transport: 'socket'


Весь лог)). Предпоследняя строка ошибка.
0
1603 / 1335 / 291
Регистрация: 25.10.2009
Сообщений: 3,487
Записей в блоге: 2
24.01.2020, 18:51 9
Цитата Сообщение от killbit Посмотреть сообщение
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
Тут ошибка)
0
0 / 0 / 0
Регистрация: 20.12.2015
Сообщений: 83
24.01.2020, 19:12  [ТС] 10
Тож не плохо. Чет я только не понимаю. Зависимости надо все- таки править?
0
1603 / 1335 / 291
Регистрация: 25.10.2009
Сообщений: 3,487
Записей в блоге: 2
24.01.2020, 19:26 11
Скорее всего. Покажите compileSdkVersion и targetSdkVersion, а так же версии support/androidx либ
0
0 / 0 / 0
Регистрация: 20.12.2015
Сообщений: 83
24.01.2020, 21:59  [ТС] 12
Вообщем весь greadle(app) на всякий

apply plugin: 'com.android.application'
Код
apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.barcodescaner"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    def camerax_version = '1.0.0-alpha06'
    implementation "androidx.camera:camera-core:${camerax_version}"
    implementation "androidx.camera:camera-camera2:${camerax_version}"
    implementation 'com.google.firebase:firebase-ml-vision:24.0.1'
    implementation 'com.google.firebase:firebase-ml-vision-barcode-model:16.0.2'

}
Добавлено через 18 минут
Сейчас добавил

Код
 implementation 'com.google.firebase:firebase-ml-vision:24.0.1'
    implementation 'com.google.firebase:firebase-ml-vision-barcode-model:16.0.2'
    implementation 'com.google.firebase:firebase-analytics:17.2.2'
    implementation 'com.google.firebase:firebase-auth:19.2.0'
    implementation 'com.google.firebase:firebase-firestore:21.3.1'
подключил к firebase. Ничего не дало. Попробовал на api 28, выдал лог


Кликните здесь для просмотра всего текста
01/24 19:55:46: Launching 'app' on Samsung Galaxy S7 API 28.
$ adb shell am start -n "com.barcodescaner/com.barcodescaner.LiveScan" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: com.barcodescaner.test | com.barcodescaner
Waiting for application to come online: com.barcodescaner.test | com.barcodescaner
Waiting for application to come online: com.barcodescaner.test | com.barcodescaner
Connecting to com.barcodescaner
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
W/ActivityThread: Application com.barcodescaner is waiting for the debugger on port 8100...
I/System.out: Sending WAIT chunk
Connected to the target VM, address: 'localhost:8658', transport: 'socket'
I/System.out: Debugger has connected
waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/chatty: uid=10085(com.barcodescaner) identical 1 line
I/System.out: waiting for debugger to settle...
I/System.out: debugger has settled (1461)
W/FirebaseApp: Default FirebaseApp failed to initialize because no default options were found. This usually means that com.google.gms:google-services was not applied to your gradle project.
I/FirebaseInitProvider: FirebaseApp initialization unsuccessful
D/Camera2Initializer: CameraX initializing with Camera2 ...
I/CameraManagerGlobal: Connecting to camera service
D/CameraRepository: Added camera: 0
D/UseCaseAttachState: Active and online use case: [] for camera: 0
D/CameraRepository: Added camera: 1
D/UseCaseAttachState: Active and online use case: [] for camera: 1
W/m.barcodescane: Accessing hidden method Landroid/graphics/drawable/Drawable;->getOpticalInsets()Landroid/graphics/Insets; (light greylist, linking)
Accessing hidden field Landroid/graphics/Insets;->left:I (light greylist, linking)
Accessing hidden field Landroid/graphics/Insets;->right:I (light greylist, linking)
W/m.barcodescane: Accessing hidden field Landroid/graphics/Insets;->top:I (light greylist, linking)
Accessing hidden field Landroid/graphics/Insets;->bottom:I (light greylist, linking)
W/m.barcodescane: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/RectZ (light greylist, reflection)
W/m.barcodescane: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
D/OpenGLRenderer: HWUI GL Pipeline
D/HostConnection: HostConnection::get() New Host Connection established 0xdd7728e0, tid 7241
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2
I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs ::hasWideColorDisplay retrieved: 0
I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs ::hasHDRDisplay retrieved: 0
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 1
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
D/OpenGLRenderer: Swap behavior 0
D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 0 0
D/EGL_emulation: eglCreateContext: 0xe4db5040: maj 2 min 0 rcv 2
D/EGL_emulation: eglMakeCurrent: 0xe4db5040: ver 2 0 (tinfo 0xcc5633e0)
D/HostConnection: createUnique: call
I/Camera2CameraInfo: Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED
D/HostConnection: HostConnection::get() New Host Connection established 0xcc41a280, tid 7241
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2
E/eglCodecCommon: GoldfishAddressSpaceHostMemoryAllocator: ioctl_ping failed for device_type=5, ret=-1
D/Camera: Use cases [ImageAnalysis:androidx.camera.core.ImageAnalysis-627e23f5-8983-4abe-8f69-59d1ff16a544, Preview:androidx.camera.core.Preview-4d33a9f8-68c6-48b6-aeff-daec60a7a1ae] ONLINE for camera 0
D/UseCaseAttachState: Active and online use case: [] for camera: 0
D/Camera: Resetting Capture Session
D/EGL_emulation: eglMakeCurrent: 0xe4db5040: ver 2 0 (tinfo 0xcc5633e0)
D/Camera: releasing session in state INITIALIZED
D/Camera: Transitioning camera internal state: INITIALIZED --> OPENING
D/Camera: Opening camera: 0
D/UseCaseAttachState: All use case: [androidx.camera.core.ImageAnalysis-627e23f5-8983-4abe-8f69-59d1ff16a544, androidx.camera.core.Preview-4d33a9f8-68c6-48b6-aeff-daec60a7a1ae] for camera: 0
D/Camera: Use case ImageAnalysis:androidx.camera.core.ImageAnalysis-627e23f5-8983-4abe-8f69-59d1ff16a544 ACTIVE for camera 0
D/UseCaseAttachState: Active and online use case: [androidx.camera.core.ImageAnalysis-627e23f5-8983-4abe-8f69-59d1ff16a544] for camera: 0
D/Camera: Use case Preview:androidx.camera.core.Preview-4d33a9f8-68c6-48b6-aeff-daec60a7a1ae ACTIVE for camera 0
D/UseCaseAttachState: Active and online use case: [androidx.camera.core.ImageAnalysis-627e23f5-8983-4abe-8f69-59d1ff16a544, androidx.camera.core.Preview-4d33a9f8-68c6-48b6-aeff-daec60a7a1ae] for camera: 0
D/Camera: CameraDevice.onOpened(): 0
Transitioning camera internal state: OPENING --> OPENED
D/UseCaseAttachState: All use case: [androidx.camera.core.ImageAnalysis-627e23f5-8983-4abe-8f69-59d1ff16a544, androidx.camera.core.Preview-4d33a9f8-68c6-48b6-aeff-daec60a7a1ae] for camera: 0
D/CaptureSession: Opening capture session.
D/CaptureSession: Attempting to send capture request onConfigured
Issuing request for session.
D/CaptureSession: CameraCaptureSession.onConfigured() mState=OPENED
D/CaptureSession: CameraCaptureSession.onReady() OPENED
D/HostConnection: HostConnection::get() New Host Connection established 0xdd770400, tid 6966
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2
D/HostConnection: HostConnection::get() New Host Connection established 0xdf0aa0f0, tid 6970
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2
D/HostConnection: HostConnection::get() New Host Connection established 0xcc928aa0, tid 7247
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2
W/m.barcodescane: Long monitor contention with owner CameraX- (7239) at android.os.Message android.os.MessageQueue.next()(MessageQueue.java:328) waiters=0 in boolean android.os.MessageQueue.enqueueMessage(android.os.Message, long) for 311ms
I/Choreographer: Skipped 37 frames! The application may be doing too much work on its main thread.
I/OpenGLRenderer: Davey! duration=735ms; Flags=0, IntendedVsync=1300868077710, Vsync=1300934744374, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=1300937801500, AnimationStart=1300938259000, PerformTraversalsStart=1300938316600, DrawStart=1300939321400, SyncQueued=1301597504500, SyncStart=1301598975800, IssueDrawCommandsStart=1301599089000, SwapBuffers=1301600954300, FrameCompleted=1301604865700, DequeueBufferDuration=63000, QueueBufferDuration=1296000,
I/OpenGLRenderer: Davey! duration=969ms; Flags=0, IntendedVsync=1313544021254, Vsync=1313860687908, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=1313874992800, AnimationStart=1313875283000, PerformTraversalsStart=1313875341500, DrawStart=1313877085400, SyncQueued=1313877815800, SyncStart=1313878977800, IssueDrawCommandsStart=1313879036400, SwapBuffers=1313880364800, FrameCompleted=1314514981300, DequeueBufferDuration=2956000, QueueBufferDuration=629057000,
W/m.barcodescane: Verification of com.google.firebase.ml.vision.document.FirebaseVisionCloudDo cumentRecognizerOptions com.google.firebase.ml.vision.document.FirebaseVisionCloudDo cumentRecognizerOptions$Builder.build() took 306.059ms
W/m.barcodescane: Long monitor contention with owner Binder:6946_1 (6966) at boolean android.os.MessageQueue.enqueueMessage(android.os.Message, long)(MessageQueue.java:544) waiters=0 in android.os.Message android.os.MessageQueue.next() for 308ms
W/m.barcodescane: Long monitor contention with owner Binder:6946_1 (6966) at boolean android.os.MessageQueue.enqueueMessage(android.os.Message, long)(MessageQueue.java:544) waiters=0 in android.os.Message android.os.MessageQueue.next() for 285ms
I/OpenGLRenderer: Davey! duration=975ms; Flags=0, IntendedVsync=1331610033642, Vsync=1331926700296, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=1331941937000, AnimationStart=1331942082200, PerformTraversalsStart=1331942127800, DrawStart=1332232065000, SyncQueued=1332233124300, SyncStart=1332233684700, IssueDrawCommandsStart=1332233719300, SwapBuffers=1332234784400, FrameCompleted=1332585995300, DequeueBufferDuration=904000, QueueBufferDuration=37149000,
W/m.barcodescane: Suspending all threads took: 309.821ms
D/HostConnection: HostConnection::get() New Host Connection established 0xcc41a190, tid 7256
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2
W/m.barcodescane: Suspending all threads took: 298.162ms
E/AndroidRuntime: FATAL EXCEPTION: pool-2-thread-1
Process: com.barcodescaner, PID: 6946
java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.barcodescaner. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(com.google.fireb ase:firebase-common@@19.3.0:184)
at com.google.firebase.ml.vision.FirebaseVision.getInstance(com .google.firebase:firebase-ml-vision@@24.0.1:1)
at com.barcodescaner.ImageAnalyser.analyze(LiveScan.kt:208)
at androidx.camera.core.ImageAnalysisAbstractAnalyzer.analyzeIm age(ImageAnalysisAbstractAnalyzer.java:56)
at androidx.camera.core.ImageAnalysisNonBlockingAnalyzer$1.run( ImageAnalysisNonBlockingAnalyzer.java:138)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPool Executor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo lExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
I/Process: Sending signal. PID: 6946 SIG: 9
Disconnected from the target VM, address: 'localhost:8658', transport: 'socket'


Добавлено через 2 часа 1 минуту
Смотрел по ошибке, чего умного только не пишут, но ничего не помогает. Похоже баг, фикс которого ждать надо.
0
0 / 0 / 0
Регистрация: 20.12.2015
Сообщений: 83
25.01.2020, 12:08  [ТС] 13
Посмотрел в примере как детектор создают.
Java
1
 val detector: FirebaseVisionBarcodeDetector by lazy{FirebaseVision.getInstance().visionBarcodeDetector}
Хотябы идут шаги после создания детектора. Но немного покурутившись в
Java
1
2
3
4
5
6
7
8
9
10
 val result = detectInImage(image)
                .addOnSuccessListener { //barcodes ->
 
                }
                .addOnFailureListener {
 
                }
 
 
        }
опять уходит тудаже куда я писал выше. Я так понимаю, потому что понимает, что крутиться там можно бесконечно.

Добавлено через 2 часа 12 минут
Не. Тоже не помогает. Как только пытается создаться детектор все крашится
0
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
25.01.2020, 12:08

Заказываю контрольные, курсовые, дипломные и любые другие студенческие работы здесь.

Как и куда можно отправить подозрительные файлы на анализ?
Если когда-нибудь вам &quot;повезет&quot; поймать какого-нибудь паразита, который еще не детектируется вашим...

Как отправить картинку POST запросом?
Здравствуйте, мне нужно в пост запросе отправить картинку которая находиться на C:\\1.jpg Как это...

Нужно отцентрировать картинку в превью к новости
В каждой новости у меня есть картинка. В превью она её есть с помощью этого. &lt;a...

Как отправить и отобразить картинку из базы данных
Здравствуйте! Хочю сделать загрузку изображений в бд, но не как не получается :( вот код. База...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
13
Ответ Создать тему
Опции темы

КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2021, vBulletin Solutions, Inc.