背景:Android Studio 2022.3.1

1. Unexpected tokens (use ';' to separate expressions on the same line)
无法在同一行声明一个变量并实例化。
解决:分开
(1)
var aaCo:Runoob<String>
aaCo=Runoob("aa" )
(2)点击:Join declaration and assignment(加入声明和分配)

结果:var aaCo:Runoob<String> = Runoob("aa" )
这样子不会报错,若是直接这样子打是不成功的

2.SourceSet with name 'main' not found.
在kotlin项目里面单独运行java文件的main方法时出现这个报错
解决:.idea/gradle.xml下新加
<option name ="delegatedBuild" value ="false" />

3.如何依赖模块
Baselibrary(属于library)、UserCenter(属于library)、App(属于application)
App依赖UserCenter、UserCenter依赖Baselibrary
方法一:要用api,否则BaseLibrary里面写的类UserCenter无法使用
api(project(mapOf("path" to ":BaseLibrary")))
api(project(mapOf("path" to ":UserCenter")))
方法二:操作后手动将implementation改成api
选择模块------》右键------》Open Module Setting------》Dependencies------》选择Modules------》加(+)------》3 Module Dependency


注:在Module里面新增的第三方依赖,想要被其它Module使用,使用api方式引入。比如Baselibrary里面新增retrofit依赖,但是UserCenter、App都需要使用,那么也是需要用api方式引入,如下:
api ("com.squareup.retrofit2:retrofit:2.1.0")
待更新中