是否有利于Android Studio项目中的多个模块只有一个大的应用程序 -模块?
我一般都了解Android模块和SOLID的优点,所以我的重点是特别考虑构建性能.gradle可以进行增量构建,如果只有一个模块发生变化,那么其他模块不需要处理吗?
这是显而易见的还是有相当大的开销?
performance android android-studio android-gradle-plugin android-module
我正在尝试创建一个新模块。这个模块的元素应该对第一个模块可见。这就是我添加的原因implementation project(":messanger"),Build.gradle(:app)但它给出了以下错误:
Dependent features configured but no package ID was set.
Execution failed for task ':app:processDebugResources'.
A failure occurred while executing
com.android.build.gradle.internal.tasks.Workers$ActionFacade
AAPT2 aapt2-4.0.0-beta01-6051327-linux Daemon #0: Unexpected error during link, attempting
to
stop daemon.
This should not happen under normal circumstances, please file an issue if it does.
Run Code Online (Sandbox Code Playgroud) 我想创建一个单独的模块,以便我可以在项目之间共享它.该模块将有Android组件.因此,在创建新模块时,选项包括手机和平板电脑模块和Android库.我想知道两者之间有什么区别.谢谢
我在发布到 Play 商店时在下载的功能模块中启动活动时遇到问题。它总是在下载的模块活动中的 setContentView() 上崩溃。
java.lang.RuntimeException: Unable to start activity ComponentInfo{xxx/xxxActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7e080000
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7e080000
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:227)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2149)
at android.content.res.Resources.getLayout(Resources.java:1158)
at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
Run Code Online (Sandbox Code Playgroud)
真正奇怪的部分是,如果我发布应用程序的新版本(唯一的变化是 versionCode)来播放商店和更新应用程序,一切正常。
当我卸载应用程序并再次安装时,崩溃又回来了。
我的应用程序继承了 SplitCompatApplication() 并且只是为了确保我已经尝试添加:
override fun attachBaseContext(newBase: Context?) {
super.attachBaseContext(newBase)
SplitCompat.install(this)
}
Run Code Online (Sandbox Code Playgroud)
到功能模块中的活动并禁用 proguard 以确保在缩小期间没有删除任何内容
我的 SplitInstallStateUpdatedListener
private val listener = SplitInstallStateUpdatedListener { state ->
val multiInstall = state.moduleNames().size > 1
state.moduleNames().forEach { name ->
// Handle changes in state.
when (state.status()) { …Run Code Online (Sandbox Code Playgroud) 我有一个扩展方法:
fun StoresClientFragment?.onClickButtonBack(){
this?.listener?.onStoresFragmentClickBtnMenu()
}
Run Code Online (Sandbox Code Playgroud)
应用程序安装没有任何错误;但是当在运行时调用该方法时,它会给出以下错误:
java.lang.NoSuchMethodError:类 Lcom/app/common_client/commons/CommonsAppTypeGroupKt 中没有静态方法 onClickButtonBack (Lcom/app/common_client/ui/fragment /stores/StoresClientFragment;) V;或其超类(“com.app.common_client.commons.CommonsAppTypeGroupKt”的声明出现在 /data/app/com.myapp.client-DWp0y3iNC3tsmBZkowlpfw==/base.apk!classes2.dex 中)。
我启用了多重索引
在 build.gradle 中
android {
defaultConfig {
multiDexEnabled = true
}
}
dependencies {
implementation 'androidx.multidex:multidex:2.0.1'
}
Run Code Online (Sandbox Code Playgroud)
在应用程序类中
class ApplicationClient : MultiDexApplication(){
}
Run Code Online (Sandbox Code Playgroud)
在清单中
<application
android:name=".commons.application.ApplicationClient"
Run Code Online (Sandbox Code Playgroud)
注意:我正在使用产品风格和模块,该方法位于某些产品风格共享的 src 中
sourceSets {
flavorA {
java.srcDirs + = "src/sharedFolder/java" //here is 'onClickButtonBack' method
}
flavorB {
java.srcDirs + = "src/sharedFolder/java"
}
}
Run Code Online (Sandbox Code Playgroud) android kotlin android-studio android-productflavors android-module
我正在为基本对话框创建一个 Android 库。现在,我所拥有的只是一个basic-dialogs模块和一个app模块。我basic-dialogs从模块Activity中调用模块中的可组合项,当我尝试运行应用程序时,app我不断收到下面有关 a 的异常错误消息。No static method代码可能有什么问题?
java.lang.NoSuchMethodError: No static method BasicDialog(Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V in class Lcom/<domain>/basic_dialogs/BasicDialogKt; or its super classes (declaration of 'com.<domain>.basic_dialogs.BasicDialogKt' appears in /data/app/~~DOqVbMGsnzDWFS7_YdNgtw==/com.<domain>.composedialogs-_5IuirMOFh5F8pL884Urnw==/base.apk!classes2.dex)
Run Code Online (Sandbox Code Playgroud)
活动
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
ComposeDialogsTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background
) {
BasicDialog(onDismiss = { }, onConfirmClick = { …Run Code Online (Sandbox Code Playgroud) android android-gradle-plugin android-module android-jetpack-compose
我正在尝试实现动态投放类型的应用。首先,我创建了一个新项目,之后创建了用于此动态步骤的模块
从菜单栏中选择“文件”>“新建”>“新模块”,然后在“创建新模块”对话框中选择“动态功能模块”,然后单击“下一步”。
文件夹的结构
我创建了类,想要访问用于布局,可绘制文件夹的资源文件夹。
同样在主模块gradle中实现
实现'com.google.android.play:core:1.2.0'和dynamicFeatures = [“:dynamic_feature”]
但是获取动态模块 错误显示错误
错误:找不到符号变量activity_main
错误:找不到符号变量iv_forward
错误:找不到符号变量seekBar
https://developer.android.com/studio/projects/dynamic-delivery https://proandroiddev.com/dynamic-feature-module-android-ondemand-module-android-app-bundle-ea0d872b32d
android app-bundle android-layout android-module android-app-bundle
创建了一个新的动态特征模块:动态,构建失败,但具有以下异常:任务':dynamic:processDebugManifest'的执行失败.
预期的配置':dynamic:debugCompileClasspath'只包含一个文件,但它不包含任何文件.
尝试将baseFeature添加到应用程序gradle并获取错误:
无法在com.android.build.gradle.internal.dsl.BaseAppModuleExtension类型的对象上找到参数[true]的方法baseFeature().
我的 Android 应用程序中有 2 个模块。核心模块和一个功能模块。目前,我有这 2 个模块共有的 3 个依赖项,我将其添加到两个模块的 gradle 文件中(这会导致更多的应用程序大小和冗余)。如何与 android 中的多个模块共享这些依赖关系。
核心模块依赖
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
api 'com.github.bumptech.glide:glide:4.9.0'
}
Run Code Online (Sandbox Code Playgroud)
功能模块依赖关系
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
//implementation project(':testmodule')
api project(path:':coreModule',configuration: 'default')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
}
Run Code Online (Sandbox Code Playgroud)
在核心模块中使用api,并在功能模块中使用 api project(path:':coreModule',configuration: 'default')
我有一个巨大的Android项目,由几个模块组成。
理想情况下,我想要一种完全自动化的方法来从所有子模块和所有资源限定符中提取所有当前的 strings.xml 文件 - 将其放入单独的文件夹中,但保留在其文件夹结构下。
我想将此结果(提取的字符串文件)提供给翻译 - 然后当我收到返回的结果时,自动将所有更新文件重新定位到项目中。
例如,如果我的项目中有:
ModuleA:
src/main/res/value/strings.xml
src/main/res/value-fr/strings.xml
src/main/res/value-es/strings.xml
ModuleB:
src/main/res/value/strings.xml
src/main/res/value-fr/strings.xml
src/main/res/value-es/strings.xml
Run Code Online (Sandbox Code Playgroud)
那么结果应该是相同文件夹结构中的相同 string.xml 文件 - 但重新定位到一个新文件夹中,而没有项目的其余部分。
是否有任何已知/现有的方法来操作复杂的项目及其 strings.xml 文件,或者我是否必须从头开始编写自己的脚本?
android android-resources android-studio android-gradle-plugin android-module