android 新手, hello world 无法编译。。

2023-05-30 11:13:41 +08:00
 chopin1998519

操作系统是 Linux

android studio 从空模板创建工程后, 均无法编译

显示 Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly

搜索过很多帖子, 装过 Android Studio Flamingo 和电摇, 清过 cache, 重新试过多个版本的 gradle , 还是一样。

还可能是什么错误呢?

12811 次点击
所在节点    Android
67 条回复
cosmain
2023-05-30 11:17:11 +08:00
Gradle project sync failed
是不是网络问题?
githmb
2023-05-30 11:17:11 +08:00
跟你上不了 v2 一样的原因。毕竟安卓姓谷歌。
xloger
2023-05-30 11:17:56 +08:00
网络问题?听着不像是你的 AS 或者 Gradle 出问题,而是 Gradle 没能把你这个项目所需依赖下载下来的问题,你可以按这个思路排查一下。
KT0J
2023-05-30 11:19:16 +08:00
电摇是什么?

不过基本上就是网络问题。
hahastudio
2023-05-30 11:21:57 +08:00
@KT0J 我猜想说的是 Android Studio Electric Eel ,电鳗
chopin1998519
2023-05-30 11:30:02 +08:00
网络问题? 我已经设置好 proxy 了呀。。。
qwwuyu
2023-05-30 11:30:51 +08:00
报错信息应该没看全,如果是网络问题,也会告诉你哪个下载失败了.
在失败窗口左侧多点击下找一下全部信息,在全部信息里翻找一下 Error 信息.
chopin1998519
2023-05-30 11:32:44 +08:00
请问 如果是网络问题的话, 哪里能看到日志?
aapeli
2023-05-30 11:33:06 +08:00
@chopin1998519 报错截图来一张
KT0J
2023-05-30 11:36:01 +08:00
@chopin1998519
终端代理,我记得应该是要设置一下的。

具体日志应该可以在底部栏,点开 Build 窗口里看( Build 窗口中的 Sync 页签)。
chopin1998519
2023-05-30 11:41:58 +08:00
chopin1998519
2023-05-30 11:42:54 +08:00
[Imgur]( )
ExplodingFKL
2023-05-30 11:44:00 +08:00
zhenghuiy
2023-05-30 11:50:04 +08:00
@chopin1998519 网上有相当一部分教程里的 proxy 是错的,之前被坑过。可能不设置 proxy + 开全局梯子 更简单。
chopin1998519
2023-05-30 11:51:54 +08:00
@zhenghuiy 问题是 我看不到现在是否是因为网络的原因, 没有提示。。。
ExplodingFKL
2023-05-30 12:05:49 +08:00
看你的 window 不像是 windows ,试试在 console 运行 ./gradlew clean build 看看错误信息,可以加上 --debug 参数
v2yllhwa
2023-05-30 12:19:42 +08:00
实际上 dl.google.com 国内是有服务器的,可以尝试设置下 hosts
iOCZ
2023-05-30 12:19:54 +08:00
你的安卓开发旅程差不多要结束了
lixuanyy
2023-05-30 12:28:05 +08:00
突然想到了之前的一个笑话,三个 G 的 hello world
chopin1998519
2023-05-30 12:47:46 +08:00
@ExplodingFKL

确实有有一堆错误。。


最后一段这样, 能看出什么吗?

2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] A new daemon was started but could not be connected to: pid=DaemonInfo{pid=261152, address=[0c0205be-28f5-4060-bc75-b4f2fefe660c port:43841, addresses:[/127.0.0.1]], state=Busy, lastBusy=1685421977961, context=DefaultDaemonContext[uid=bd402a2c-565c-485a-845d-febf686b1655,javaHome=/usr/lib/jvm/java-17-oracle,daemonRegistryDir=/home/marco/.gradle/daemon,pid=261152,idleTimeout=10800000,priority=NORMAL,daemonOpts=--add-opens=java.base/java.util=ALL-UNNAMED,--add-opens=java.base/java.lang=ALL-UNNAMED,--add-opens=java.base/java.lang.invoke=ALL-UNNAMED,--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens=java.base/java.nio.charset=ALL-UNNAMED,--add-opens=java.base/java.net=ALL-UNNAMED,--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED,-Xmx2048m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]}, address= [0c0205be-28f5-4060-bc75-b4f2fefe660c port:43841, addresses:[/127.0.0.1]]. See https://docs.gradle.org/8.0/userguide/troubleshooting.html#network_connection for more details.
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Run with --scan to get full insights.
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.launcher.daemon.client.NoUsableDaemonFoundException: A new daemon was started but could not be connected to: pid=DaemonInfo{pid=261152, address=[0c0205be-28f5-4060-bc75-b4f2fefe660c port:43841, addresses:[/127.0.0.1]], state=Busy, lastBusy=1685421977961, context=DefaultDaemonContext[uid=bd402a2c-565c-485a-845d-febf686b1655,javaHome=/usr/lib/jvm/java-17-oracle,daemonRegistryDir=/home/marco/.gradle/daemon,pid=261152,idleTimeout=10800000,priority=NORMAL,daemonOpts=--add-opens=java.base/java.util=ALL-UNNAMED,--add-opens=java.base/java.lang=ALL-UNNAMED,--add-opens=java.base/java.lang.invoke=ALL-UNNAMED,--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens=java.base/java.nio.charset=ALL-UNNAMED,--add-opens=java.base/java.net=ALL-UNNAMED,--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED,-Xmx2048m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]}, address= [0c0205be-28f5-4060-bc75-b4f2fefe660c port:43841, addresses:[/127.0.0.1]]. See https://docs.gradle.org/8.0/userguide/troubleshooting.html#network_connection for more details.
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:172)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:99)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:57)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:167)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.launcher.cli.DefaultCommandLineActionFactory$ParseAndBuildAction.execute(DefaultCommandLineActionFactory.java:259)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.launcher.cli.DefaultCommandLineActionFactory$ParseAndBuildAction.execute(DefaultCommandLineActionFactory.java:230)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.launcher.cli.DebugLoggerWarningAction.execute(DebugLoggerWarningAction.java:82)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.launcher.cli.DebugLoggerWarningAction.execute(DebugLoggerWarningAction.java:30)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.launcher.cli.WelcomeMessageAction.execute(WelcomeMessageAction.java:96)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.launcher.cli.WelcomeMessageAction.execute(WelcomeMessageAction.java:40)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.launcher.cli.NativeServicesInitializingAction.execute(NativeServicesInitializingAction.java:44)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.launcher.cli.NativeServicesInitializingAction.execute(NativeServicesInitializingAction.java:26)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:41)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:26)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.launcher.cli.DefaultCommandLineActionFactory$WithLogging.execute(DefaultCommandLineActionFactory.java:361)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.launcher.Main.doAction(Main.java:35)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:50)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.base/java.lang.reflect.Method.invoke(Method.java:568)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at java.base/java.lang.reflect.Method.invoke(Method.java:568)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.launcher.GradleMain.main(GradleMain.java:34)
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
2023-05-30T12:46:17.979+0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/944131

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX