我的 Kotlin 项目没有在资源中创建导航文件夹

My Kotlin project doesn't create the navigation folder in resources

你好所以我创建了我的 android 工作室项目并且我 select 空白 activity。然后我 select kotlin 作为语言,但我在 res 文件夹下看到导航不存在,生成的 java 文件夹。

应该是这样的...

这是我的Build.gradle...

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

我知道有人可能会回答合乎逻辑的事情,即您需要添加实现“.....” 但我想要的是 android 工作室,一旦我创建了一个新项目,该项目将具有实现 Jetpack 所需的导航和文件。

也许最好的方法就是自己添加导航模式。

这里有一个 link 解释了如何做: How to get started with navigation component 此外,还有一个免费的 udacity 课程和一些解释导航工作原理的代码实验室。

但是,如果您真的想在 android 工作室的新项目中获取它,如果您使用 底部导航 Activity 开始新项目或者导航抽屉Activity,它已经包含了导航。

PS:我不知道是否还有更多包含导航的模板,因为我还没有尝试过,但是 Empty Activity 或者Fragment + ViewModel 不包含它。