gpt4 book ai didi

Gradle project sync failed due to unresolved references(由于引用未解析,Gradle项目同步失败)

转载 作者:bug小助手 更新时间:2023-10-25 12:04:43 27 4
gpt4 key购买 nike



Learning about Navigation between screens with Compose from developer.android.com. After downloading the starter code I get the following errors.

了解如何使用来自Developer.android.com的Compose在屏幕之间导航。下载启动代码后,我得到以下错误。


Usually changing the gradle versions fixes all my sync fails but today my luck has run out. I'm sure there is a ez fix that i dont know about. Hope that i can get some help.

通常改变gradle版本修复我所有的同步失败,但今天我的运气已经耗尽。我相信有一个我不知道的ez修复。希望我能得到一些帮助。


git clone https://github.com/google-developer-training/basic-android-kotlin-compose-training-cupcake.git

> Configure project :app
e: file:///C:/Users/Marco/AndroidStudioProjects/basic-android-kotlin-compose-training-cupcake/app/build.gradle.kts:61:5: Unresolved reference: packaging
e: file:///C:/Users/Marco/AndroidStudioProjects/basic-android-kotlin-compose-training-cupcake/app/build.gradle.kts:62:9: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: ...

e: file:///C:/Users/Marco/AndroidStudioProjects/basic-android-kotlin-compose-training-cupcake/app/build.gradle.kts:63:13: Unresolved reference: excludes
e: file:///C:/Users/Marco/AndroidStudioProjects/basic-android-kotlin-compose-training-cupcake/app/build.gradle.kts:63:22: Unresolved reference: +=

> Task :prepareKotlinBuildScriptModel UP-TO-DATE

FAILURE: Build failed with an exception.
`your text`
* What went wrong:
Failed to calculate the value of property 'namespace'.
Package Name not found in C:\Users\Marco\AndroidStudioProjects\basic-android-kotlin-compose-training-cupcake\app\src\main\AndroidManifest.xml, and namespace not specified. Please specify a namespace for the generated R and BuildConfig classes via android.namespace in the module's build.gradle file like so:

更多回答

is there a package name specified in your AndroidManifest.xml ?

您的androidManifest.xml中有指定的包名吗?

Hi Eliza thanks for the swift response. I don't see anything in the AndroidManifest.xml that looks like a package name being specified. I don't know if the problem is on my side or if its the starter code that was provided in the navigation part of the Compose course. I do not have a another system to test it on thats why I provided the git hub clone to see if other people have the same problem.

你好,伊莱扎,谢谢你的迅速回复。我在androidManifest.xml中没有看到任何看起来像是指定了包名的内容。我不知道问题出在我这一边,还是作文课程导航部分提供的入门代码。我没有另一个系统来测试它,这就是为什么我提供了Git Hub克隆,看看其他人是否有同样的问题。

But its not the end of the world if I can't find a solution. I can still learn the content and just apply it to another test app. Would just be nice to know what the cause is so that i dont feel as defeated (: . I only started coding 3 months ago so im still very new to everything.

但如果我找不到解决办法,那也不是世界末日。我仍然可以学习内容,只需将其应用于另一款测试应用程序。如果知道原因是什么就好了,这样我就不会觉得失败了。我3个月前才开始编程,所以我对每件事都是非常陌生的。

I downloaded without a problem. Sometimes build just go wrong without an actual reason (welcome to Android xD). I'd suggest File -> Invalidate caches -> Restart. If that doesn't fix your problem try to re-import it (File -> New -> Import project). Hope it works!

我下载的时候没有任何问题。有时,构建只是在没有实际原因的情况下出错(欢迎使用Android xD)。我建议使用文件->无效缓存->重新启动。如果这不能解决您的问题,请尝试重新导入它(文件->新建->导入项目)。希望它能奏效!

I've also found this issue when using Navigation 2.5+ with Gradle 8+. Did you find a solution for this?

我在使用带有Gradle 8+的导航2.5+时也发现了这个问题。你找到解决这个问题的办法了吗?

优秀答案推荐

I have encountered same problem. follow these steps :-

我也遇到过同样的问题。请遵循以下步骤:



  1. In the error see there is a build.gradle.kts file. please Open it.



  2. Now in build.gradle.kts file you will see a large script. In the script remove the packaging block (as it is not a recognized configuration block in the Android Gradle Plugin).



  3. Hit try again and refresh.


    I hope it helps.




更多回答

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com