别人的解决方法:

将build.gradle中plugins里的 com.android.application 改为 com.android.library

我的解决方法:

dependencies {
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'e4d
    implementation project(path: ':chapter05')
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

经过和别的module的对比,我发现在build.gradle的依赖节点里多了一个“implementation project(path: ':chapter05')”,意思是本module依赖了另一个module(chapter05),我把这行删掉就可以正常运行了。可能是因为我这个module从上一个module里搬来了好多代码的原因,记录一下。

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐