问题:在使用Android Studio运行最简单的Hello World时出现运行按钮一直为灰色的情况,运行按钮图标如图1

【Android】Android Studio运行Hello World无法运行
图1 运行按钮

相对应的,点击运行按钮左边的下拉菜单中的Edit Configurations按钮后出现如下的窗口,窗口中的Module一项无法选择app,如图2

【Android】Android Studio运行Hello World无法运行
图2 Edit Configurations窗口

解决方法:点击sync project with gradles files按钮,按钮如图3所示

【Android】Android Studio运行Hello World无法运行
图3 sync project with gradles files按钮

重新编译之后,就能够在如图2所示的Module菜单中选择app选项,运行按钮可以正常使用,最终运行结果如图4

【Android】Android Studio运行Hello World无法运行
图4 Hello World

补充:若在运行时仍报错:Could not identify launch activity: Default Activity not found,则可在图2所示的界面中的launch option 中设置好指定的activity即可。

参考资料:《第一行代码Android》郭霖

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-09
  • 2021-12-18
  • 2021-07-31
  • 2021-06-16
  • 2021-07-23
猜你喜欢
  • 2022-12-23
  • 2021-11-08
  • 2021-04-27
  • 2021-09-14
  • 2022-01-23
  • 2021-09-17
  • 2022-12-23
相关资源
相似解决方案