Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Attempting to add Google Code Scanner to simple android app. Only example I've seen is ML Kit sample

Attempting dev of simple (personal use) Android/Kotlin app. ie. enter single data field, then send to mobile printer as simple label. Novice to Android programming however programmer in previous life and tinkerer (Im 81 so prior to object oriented). Have my very simple XML UI looking fine. Now attempting to develop Kotlin code. In addition to user typing into single EditText field, I wish to implement barcode scanning of the data. Google Code Scanner seems to be the suggested approach so following the only example I could find (ML Kit example), I get to this point (see attached screen shot) with odd error. What am I missing? Also noted that targetSDK = 34 is highlighted in yellowenter image description here

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Replace:

implementation 'com.google.android.gms:play-services-code-scanner:16.0.1'

with:

implementation("com.google.android.gms:play-services-code-scanner:16.0.1")

This adds the parentheses and replaces the single quote delimiters with double quotes.

My guess is that you copied and pasted the first implementation line from somewhere. That example was for Gradle scripts written in Groovy (build.gradle). Your Gradle script is written in Kotlin (build.gradle.kts). Your script is the more modern approach, but it does mean that from time to time you will need to convert Groovy syntax in examples to Kotlin syntax.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading