最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论