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

Attempting dev of simple (personal use) AndroidKotlin app. ie. enter single data field, then send to m

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 yellow

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 yellow

Share Improve this question asked Nov 20, 2024 at 20:23 BruceBruce 175 bronze badges 1
  • 1 In the future, please post text as text, not as screenshots. – CommonsWare Commented Nov 20, 2024 at 20:25
Add a comment  | 

1 Answer 1

Reset to default 2

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742331103a4423737.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信