- Ошибка «unresolved reference» в Kotlin Android
- 3 ответа
- Похожие вопросы:
- IntelliJ Idea: Unresolved reference: serializer #257
- Comments
- dmexe commented Nov 1, 2018
- sandwwraith commented Nov 1, 2018
- dmexe commented Nov 1, 2018
- sandwwraith commented Nov 2, 2018
- jguerinet commented Nov 14, 2018
- sandwwraith commented Nov 19, 2018
- tromper commented Dec 3, 2018
- grahamcummins-wf commented Dec 8, 2018
- sandwwraith commented Dec 10, 2018
- grahamcummins-wf commented Dec 12, 2018
- sandwwraith commented Dec 13, 2018
- IARI commented Jan 3, 2019
- sandwwraith commented Jan 14, 2019
- IARI commented Jan 24, 2019
- clhols commented Feb 4, 2019
- TorRanfelt commented Feb 8, 2019
- IARI commented Feb 8, 2019
- chrisjenx commented Feb 16, 2019
- rsCtrl commented Feb 18, 2019 •
- ghost commented Feb 25, 2019
- raydenvoldeskine commented Mar 19, 2019
- sandwwraith commented Mar 20, 2019
- danielebart commented Mar 20, 2019
- raydenvoldeskine commented Mar 20, 2019
- ghost commented Jun 13, 2019 •
- natanfudge commented Aug 7, 2019
- sandwwraith commented Aug 13, 2019
- natanfudge commented Aug 13, 2019
- ghost commented Aug 13, 2019 •
- andylamax commented Aug 30, 2019
- Gennady77 commented Sep 26, 2019
- ghost commented Sep 26, 2019 •
- smaudet commented Oct 16, 2019 •
- chrisjenx commented Oct 16, 2019
Ошибка «unresolved reference» в Kotlin Android
У меня есть код:
Когда я запускаю его, я получаю ошибки:
- неразрешенная ссылка setOnClickListener
- неразрешенная ссылка: Текст
- неразрешенная ссылка: ToString
Любой желающий может объяснить мне почему это так и исправить это Спасибо
3 ответа
Я использую версию Android Studio 3.0 Canary 6. Я включил dataBinding в своем классе, и код не показывает никаких ошибок. Но, когда я построить APK, построить не удается, и показывает следующее сообщение об ошибке: Error:(8, 37) Unresolved reference: databinding Error:(22, 26) Unresolved.
Я установил сегодня Kotlin плагин в существующий проект с кинжалом 2. Прежде чем Kotlin был установлен у меня не было проблем с кинжалом. Однако теперь компилятор жалуется : Error:(5, 32) Unresolved reference: DaggerAppComponent Error:Execution failed for task ‘:app:compileDebugKotlinAfterJava’.
Вы импортируете идентификаторы, а не представления. Вместо:
и добавить плагин в файл app gradle:
Вы получили ошибку unresolved , потому что вы не импортировали представление. Вместо представления вы импортировали идентификаторы.
Там импорт Для импорта одного представления
Чтобы импортировать все свойства виджета для определенного макета
Также вам нужно включить плагин Android Extensions Gradle в файле build.gradle вашего модуля:
Похоже, вы пытаетесь использовать расширения Kotlin Android . Для этого импортируйте:
Потратьте несколько минут на чтение того, как KAE работает — это вам очень поможет.
Более того, не существует таких методов, как ToString() и ToInt() . То, что вы ищете, это: toString() и toInt() .
Похожие вопросы:
Я получаю ошибку Unresolved reference to response под номером 5,6 и 7. Можете вы пожалуйста помочь мне разобраться в проблеме? public class GenericCall < public fun.
Я пытаюсь преобразовать свой код Java из HomePage.class в Kotlin. Я следую инструкциям на Kotlin.org : getClass() Чтобы извлечь информацию о типе из объекта, мы используем javaClass свойство.
Я постоянно получаю ошибку unresolved reference: FacebookCallback, когда пытаюсь реализовать код, прикрепленный на картинке. Я пытаюсь настроить логин facebook, как указано в этой ссылке: https:/ /.
Я использую версию Android Studio 3.0 Canary 6. Я включил dataBinding в своем классе, и код не показывает никаких ошибок. Но, когда я построить APK, построить не удается, и показывает следующее.
Я установил сегодня Kotlin плагин в существующий проект с кинжалом 2. Прежде чем Kotlin был установлен у меня не было проблем с кинжалом. Однако теперь компилятор жалуется : Error:(5, 32) Unresolved.
я очень новичок в kotlin, и, возможно, это может быть глупый вопрос, но почему использование переменной, определенной во вторичном параметре, дает ошибку unresolved reference, когда я пытаюсь.
Я работаю над гибридным проектом Kotlin+Java. Версия Gradle и плагин были недавно обновлены до 3.1.3 и 4.4 соответственно. Теперь при компиляции я получаю ошибку ‘unresolved reference’ в нескольких.
Я изо всех сил пытаюсь обновить свой проект для компиляции с помощью плагина Android Gradle 3.0.1. Факты: app проект зависит от местной библиотеки: lib ./gradlew assembleDebug для app не удается.
Имейте уже существующий проект java. Пытаясь добавить к нему новые файлы kotlin. AndroidStudio 3.1 жалуется, что R-это Unresolved reference. Я могу вручную импортировать R, и он строится без ошибок.
Источник
IntelliJ Idea: Unresolved reference: serializer #257
Comments
dmexe commented Nov 1, 2018
Idea doesn’t compile project files with an error: «Kotlin: Unresolved reference: serializer».
I tried various cleanup task and IDE restarting and a project reimport but it doesn’t solve the issue.
Meantime gradle itself works perfectly without any errors.
Idea kotlin plugin version:
The text was updated successfully, but these errors were encountered:
sandwwraith commented Nov 1, 2018
Hi, is it error on a highlighting level ( .serializer() code is shown as red) or only compile error? If latter, delegate build in IDEA to Gradle (Settings — Build, Execution, Deployment — Build Tools — Gradle — Runner — tick Delegate IDE build/run actions to gradle).
dmexe commented Nov 1, 2018
It was a compilation error:
After I turned on «delegate build to gradle» a project compiles without errors. In 1.3 release notes «Serialization support should work out of the box, if you have 1.3 Kotlin plugin installed» is it still not true?
sandwwraith commented Nov 2, 2018
And the next sentence after the one you cited is about delegation to gradle. «Serialization support» was mainly for highlighting generated code. The issue with compilation is known and likely will be fixed in the next release.
jguerinet commented Nov 14, 2018
@sandwwraith is there an issue (on GitHub or YouTrack) to keep track of when this compilation issue will be fixed? I can’t seem to find it, but I may be using the wrong keywords in my search.
sandwwraith commented Nov 19, 2018
@jguerinet I think you can track this one: #265
tromper commented Dec 3, 2018
@sandwwraith I’m having a similar issue with Unresolved reference: serializer being shown in red in IDEA. I’ve updated to latest versions (e.g. have the Kotlin 1.3 plugin installed and latest IDEA), maven compiles ok, I see the generated code, can run it fine, but can’t get rid of the red highlighting.
grahamcummins-wf commented Dec 8, 2018
I have the same issue as @tromper.
My project builds and works as expected using a maven build. With the build delegated to maven, serialization tests also build, run, and pass from IntelliJ. All references to the «.serializer()» method on any @serializable class show up as an error in IntelliJ’s linter (red highlight. File defining them has a red underscore).
It’s not a show stopper, since the build works, but it’s annoying, particularly when a new developer starts on the project (s/he always spends a few hours trying to fix the «Unresolved reference», no matter how much we try to document the linter failure) .
sandwwraith commented Dec 10, 2018
Hm, probably this is a particular Maven import issue, since Gradle projects with serialization are imported into IDE correctly. I’ll check this out.
grahamcummins-wf commented Dec 12, 2018
That sounds right. I haven’t seen this on my personal projects (which are gradle projects). Only on this one at work (where we use maven)
sandwwraith commented Dec 13, 2018
IARI commented Jan 3, 2019
@sandwwraith I have the same Issue, but with a gradle project. I haven’t been able to get rid of the synta highlighting.
sandwwraith commented Jan 14, 2019
@IARI Have you tried reimporting project/deleting .idea folder? Is Kotlin plugin in IDEA higher than 1.3? Does Gradle build passes correctly?
IARI commented Jan 24, 2019
@sandwwraith
Kotlin and IDEA plugin ist 1.3.11, Gradle build passes correctly.
I was able to get rid of it temporarily, I think by reimporting the project. but I’ll have to try that again to be sure.
clhols commented Feb 4, 2019
@sandwwraith I also have the syntax highlighting issue with a Gradle project (Kotlin DSL). I tried deleting the .idea folder. Kotlin plugin version is 1.3.20. And I am using Android Studio 3.4 beta 3.
Try to clone this:
https://github.com/clhols/drchannels
And open AppUpdater.kt on line 77.
TorRanfelt commented Feb 8, 2019
@sandwwraith For me the problem is fixed by deleting the .idea folder, but I have to do it often.
IARI commented Feb 8, 2019
yep it is fixxed temporarily for me by reimporting the gradle project. but that only lasts until i think idea is restarted oder something else changes
chrisjenx commented Feb 16, 2019
Same here, project compiles, but Intellij can’t resolve the serializer() extension.
rsCtrl commented Feb 18, 2019 •
Same. Updating gradle dependencies / deleting the .idea folder fixes the issue until i restart the idea.
ghost commented Feb 25, 2019
Same here, IDEA highlights it in red but all runs.
screenshot
raydenvoldeskine commented Mar 19, 2019
Have same highlighting issue of serializable() in Android Studio. Does not go away even after «Invalidate Caches & Restart»
sandwwraith commented Mar 20, 2019
@fracturizer @coder82 Can you please write versions of your IDEs?
danielebart commented Mar 20, 2019
Same here with a multi module android project
Android studio 3.3.2
raydenvoldeskine commented Mar 20, 2019
Android Studio 3.2.1
Build #AI-181.5540.7.32.5056338, built on October 9, 2018
JRE: 1.8.0_152-release-1136-b06 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.6
BTW. Highlighting problem was gone after deleting .idea folder and clean build.
ghost commented Jun 13, 2019 •
This problem is back:
IntelliJ IDEA 2019.1.3 (Ultimate Edition)
Build #IU-191.7479.19, built on May 28, 2019
JRE: 1.8.0_202-release-1483-b58 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
serializer() function shows unresolved.
I see this intermittently day after day, not all the time, really weird.
Gradle build is all ok. Looks like it’s the IDE.
natanfudge commented Aug 7, 2019
Problem still exists with IDEA 2019.2 and Kotlin plugin 1.3.50-eap-5.
sandwwraith commented Aug 13, 2019
Have you tried to reimport the project?
natanfudge commented Aug 13, 2019
Yes, it fixes it, but i have to do it every time i start the IDE.
ghost commented Aug 13, 2019 •
To me it doesn’t fix it by restarting, I also have to delete the gradle.xml from .idea dir to fix it.
Really annoying because restarting means quite a lot of reload, reindex, reimport etc.
This should be reopened IMO.
andylamax commented Aug 30, 2019
None of the above options worked for me.
Using
IntelliJ IDEA 2019.1.1 (Community Edition)
Build #IC-191.6707.61, built on April 16, 2019
JRE: 1.8.0_202-release-1483-b44 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.15.0-30-generic
gradle would compile well. But IDEA would highlight ClassName.serializer() (the serializer method) and state that it is an «unresolved reference»
Gennady77 commented Sep 26, 2019
I have the same problem in Android Studio.
ghost commented Sep 26, 2019 •
@fracturizer @coder82 Can you please write versions of your IDEs?
It’s long I don’t see this anymore, it was happening with the version I wrote above.
Now this is what I got:
IntelliJ IDEA 2019.2.2 (Ultimate Edition)
Build #IU-192.6603.28, built on September 6, 2019
Licensed to xxx
Subscription is active until July 6, 2020
Runtime version: 11.0.3+12-b304.56 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1979M
Cores: 16
Registry: debugger.watches.in.variables=false
Non-Bundled Plugins: CMD Support, Lombook Plugin, mobi.hsz.idea.gitignore, org.jetbrains.plugins.hocon, org.jetbrains.kotlin, org.jetbrains.debugger.streams.kotlin, com.deadlock.scsyntax, com.dmarcotte.handlebars, com.flageolett.nodeconfig
smaudet commented Oct 16, 2019 •
. Pretty sure this is back. Why is gradle so horrible/indecipherable to use. every time I’ve tried to use kotlin it has just been this massive hacky mess in gradle.
IntelliJ 2019.2.3 does not see the serialization stuff. Only the 1.2 stuff seemed to work.
So I figured out that Kotlin 1.3 plain doesn’t work with JDK 1.8. which seems like a general issue with the platform? I get JDK 11 is great and all that but most java code exists compiled for 8.
chrisjenx commented Oct 16, 2019
This was fixed a long time ago for me, couple of things if you haven’t checked already, make sure gradle is up to date, make sure the serilization dep is up to date, make sure kotlin is up to date (as it’s bundled into the compiler plugin). Make sure you have cleaned and then invalidated caches.
IF after all of that it still doesn’t work, please create a minimum reproduceable example and create a ticket so they can fix it.
Источник