我希望将 Android 项目模块化,以便将来使用时易于维护。我想知道是否有可能将一个 Android 项目用作另一个 Android 项目中的模块?
例如,假设在我的主要 android 项目中,我有三个按钮用于登录、注册、忘记密码。我有三个独立的项目,用于登录、注册和忘记密码,并带有自己的视图、活动和库。如何在主 Android 项目中使用这些单独的 android 项目,以便当我单击主活动视图中的三个选项中的任何一个时,它将从这三个模块项目中加载相关视图?(单击主视图中的登录按钮并从单独的登录项目活动加载登录视图)。我试图摆弄构建文件和库模块导入,但无法做到。帮我说这种方法是否可行?如果可能的话如何实现呢?
我已经尝试了很多事情,从无效缓存/重新启动到干净地重新安装 android studio 多次。似乎没有任何作用。
在我的 build.gradle 中(项目级别)
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
...
Run Code Online (Sandbox Code Playgroud)
build.gradle(应用程序级别)
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
testImplementation "junit:junit:4.13.2"
androidTestImplementation "androidx.test.ext:junit:1.1.3"
androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0"
}
Run Code Online (Sandbox Code Playgroud)
我已经在设置中启用了 corretto-1.8 版本的 gradle jdk,并且启用了 JUint 的插件。我似乎无法找到这个问题的任何解决方案。
PS 我最近已将 Windows 更新到 Windows 11。在此之前,上述问题一直存在。