标签: dynamic-feature-module

动态功能模块的合并测试 apk

有没有办法为仪器测试创建通用 APK?我想在 Firebase 测试实验室上运行整个测试套件,但为每个动态功能模块的测试 APK 上传一个 APK 似乎很乏味。

对于该应用程序,您可以执行以下操作,packageVariantUniversalApk但我似乎找不到用于测试 APK 的任何内容。

任何帮助将不胜感激。

android firebase-test-lab instrumented-test dynamic-feature dynamic-feature-module

5
推荐指数
1
解决办法
128
查看次数

在动态交付模块中使用时应用模块尺寸/颜色的值不正确

我有应用程序模块和一个名为“聊天”的动态模块。我有一个布局和片段驻留在聊天模块中,在布局中有一个android:textSize="@dimen/sp20"书面的。Dimen 是在 app 模块中定义的,因为它在我运行时显示的文本大小不正确。我调试了一下,它等于12sp(xxhdpi设备为36)。

我尝试以编程方式使用 dimen 但结果相同。( landing_page_toolbar_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, resources.getDimension(com.sendbird.R.dimen.sp20))) 。小心使用应用模块包中的“R”。

当我在聊天模块中定义相同的值时,它完美地工作。但这对于我们的场景是不可行的。我有大量的字符串、尺寸、颜色资源,并在 app 模块中编写了多种配置。请分享可行的解决方案。

附上截图以便更好地理解。基于反射的结果比较

android dimension android-resources dynamic-delivery dynamic-feature-module

5
推荐指数
1
解决办法
145
查看次数

即时应用程序,“立即尝试”按钮不会出现在 Play 商店中

我从以下 github 项目开始,但这些示例无法正常工作。我按照文档中的说明添加了缺失的部分。 https://github.com/android/app-bundle-samples/tree/main/InstantApps/urlless https://github.com/googlecodelabs/android-dynamic-features

这是我读过的文档。 https://developer.android.com/topic/google-play-instant/getting-started/instant-enabled-app-bundle https://developer.android.com/topic/google-play-instant/feature-module -迁移 https://developer.android.com/guide/app-bundle/instant-delivery

我尝试实现一个简单的 hello world 即时应用程序。我尝试了很多东西,但“立即尝试”按钮从未出现在游戏商店中。

我的应用程序包含 2 个模块:

  • 应用程序
  • 即时应用程序

应用程序模块的build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 30
    defaultConfig {

        minSdkVersion 21
        targetSdkVersion 30
        versionCode 61
        versionName "61"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            debuggable true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dynamicFeatures = [':instantapp']
}

dependencies {
    ...
    implementation "com.google.android.gms:play-services-instantapps:17.0.0"
    implementation "com.google.android.play:core:1.9.0"
    ...
}
Run Code Online (Sandbox Code Playgroud)

我的即时应用程序模块的 …

android google-play android-instant-apps dynamic-feature-module

5
推荐指数
1
解决办法
1263
查看次数

java.lang.NoSuchMethodError: 没有静态方法 asAttributeSet(Lt/g/a/a;)Landroid/util/AttributeSet; 在类 Landroid/util/Xml 中;

完全错误

java.lang.NoSuchMethodError: 没有静态方法 asAttributeSet(Lt/g/a/a;)Landroid/util/AttributeSet; 在类 Landroid/util/Xml 中;或其超类('android.util.Xml' 的声明出现在 /system/framework/framework.jar!classes2.dex 中)

我已经在 Play 商店上传了 appbundle,每当我在我的设备中从它下载应用程序时,应用程序都会崩溃,日志如下......(日志是从所有 RedMI 设备 android os 9、MIUI 11 和 10 收集的)

java.lang.NoSuchMethodError: No static method asAttributeSet(Lt/g/a/a;)Landroid/util/AttributeSet; in class Landroid/util/Xml; or its super classes (declaration of 'android.util.Xml' appears in /system/framework/framework.jar!classes2.dex)
at i.b.k.h.g.inflate(Unknown Source:21)
at xxx.yyyyyy.zzzzzz.qqqqqq.cccc.view.HomeActivity.onCreateOptionsMenu(Unknown Source:12)
at android.app.Activity.onCreatePanelMenu(Activity.java:3456)
at android.support.v4.app.i.onCreatePanelMenu(Unknown Source:2)
at i.b.k.h.i.onCreatePanelMenu(Unknown Source:2)
at android.support.v7.app.h$k.onCreatePanelMenu(Unknown Source:8)
at i.b.k.h.i.onCreatePanelMenu(Unknown Source:2)
at android.support.v7.app.l.p(Unknown Source:25)
at android.support.v7.app.l$a.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:794)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) …
Run Code Online (Sandbox Code Playgroud)

gradle app-bundle android-app-bundle dynamic-feature-module

4
推荐指数
1
解决办法
4644
查看次数

动态功能模块导航 IllegalStateException:包含的 <navigation> 的 id 与目标 id 不同

我有一个应用程序和一个动态功能模块,我希望从中进行导航

应用程序导航图

<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/nav_graph"
    app:startDestination="@id/mainFragment">

    <!-- Main Fragment from App Module -->
    <fragment
        android:id="@+id/mainFragment"
        android:name="com.xyz.MainFragment"
        android:label="MainFragment"
        tools:layout="@layout/fragment_main">
        <action
            android:id="@+id/action_mainFragment_to_nav_graph_home"
            app:destination="@id/nav_graph_home" />
    </fragment>

    <!-- Home Navigation from App Module-->
    <include app:graph="@navigation/nav_graph_home" />

    <include-dynamic
        android:id="@+id/nav_graph_dashboard"
        android:name="com.feature.dashboard"
        app:graphResName="nav_graph_dashboard"
        app:moduleName="dashboard" />

</navigation>
Run Code Online (Sandbox Code Playgroud)

以及功能导航

<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/nav_graph_dashboard"
    app:moduleName="dashboard"
    app:startDestination="@id/dashboardFragment1">

    <fragment
        android:id="@+id/dashboardFragment1"
        android:name="com.feature.DashboardFragment1"
        android:label="DashboardFragment1">
    </fragment>

</navigation>
Run Code Online (Sandbox Code Playgroud)

返回错误

java.lang.IllegalStateException: The included <navigation>'s id com.xyz.dashboard:id/nav_graph_dashboard is different from the destination id com.xyz:id/nav_graph_dashboard. Either remove the <navigation> id …
Run Code Online (Sandbox Code Playgroud)

android android-architecture-navigation dynamic-feature-module

4
推荐指数
1
解决办法
666
查看次数

动态模块功能和 ML Kit 在应用程序打开时崩溃

应用程序具有 ML Kit 功能(翻译)。我试图通过引入动态模块功能、按需加载来减小应用程序的大小。

遵循本指南 将 'com.google.mlkit:playstore-dynamic-feature-support:16.0.0-beta1' 添加到基础 apk 的 build.gradle

com.google.mlkit:translate:16.1.2 在功能模块 build.gradle 中,

一切都会编译并尝试在模拟器上运行,但不幸的是应用程序从日志启动时崩溃

java.lang.RuntimeException: Unable to get provider com.google.mlkit.common.internal.MlKitInitProvider: com.google.firebase.components.MissingDependencyException: Unsatisfied dependency for component Component<[class com.google.android.gms.internal.mlkit_translate.zzxa]>{0, type=0, deps=[Dependency{anInterface=class com.google.mlkit.common.sdkinternal.SharedPrefManager, type=required, injection=direct}, Dependency{anInterface=class com.google.android.gms.internal.mlkit_translate.zzwx, type=required, injection=direct}]}: class com.google.mlkit.common.sdkinternal.SharedPrefManager

 Caused by: com.google.firebase.components.MissingDependencyException: Unsatisfied dependency for component Component<[class com.google.android.gms.internal.mlkit_translate.zzxa]>{0, type=0, deps=[Dependency{anInterface=class com.google.mlkit.common.sdkinternal.SharedPrefManager, type=required, injection=direct}, Dependency{anInterface=class com.google.android.gms.internal.mlkit_translate.zzwx, type=required, injection=direct}]}: class com.google.mlkit.common.sdkinternal.SharedPrefManager
    
Run Code Online (Sandbox Code Playgroud)

哪一种没有意义。因为我添加了 playstore-dynamic-feature-support。

android firebase-mlkit dynamic-feature-module google-mlkit

4
推荐指数
2
解决办法
1564
查看次数

Android动态功能模块依赖关系

所以我有几个共享通用代码的功能 - 让我们称它们为“feature1”和“feature2”。我无法将共享代码添加为“feature1”和“feature2”的依赖项 - Android studio 抛出以下错误:

多个 APK 打包同一库可能会导致运行时错误。将上述库添加为基本模块的依赖项将通过将库与基本 APK 一起打包来解决此问题。

所以我想我只是创建另一个动态功能模块 - 让我们称之为“核心” - 在那里传递共享依赖项。这也有效,有点。我可以从“feature1”和“feature2”内的“core”访问所有java类,但是一旦我想访问资源,我就会得到一个ResourceNotFoundException。这些功能是传递调用SplitCompat.install(context)onAttach()函数的片段。

所以我的问题是 - 是否有可能有一个存储公共代码的动态功能模块,或者这一切都应该放在应用程序中?

感谢和问候, 罗曼斯基

android android-app-bundle dynamic-feature-module

3
推荐指数
1
解决办法
4624
查看次数

动态功能模块未安装

我正在我的应用程序上添加一个按需动态功能模块,但我遇到了问题。

当我安装该功能模块时

val request = SplitInstallRequest.newBuilder()
    .addModule("ondemandfeature")
    .build()
splitInstallManager.startInstall(request)
Run Code Online (Sandbox Code Playgroud)

打印以下日志

12:54:42.301/? I/PlayCore: UID: [11113]  PID: [30056] SplitInstallService : startInstall([ondemandfeature],[])
12:54:42.807/? I/Finsky: [2] mvr.a(112): Installer: Request install. package=com.package.my, version=16081, mods=[ondemandfeature], priority=2, reason=SplitInstallService
12:54:43.239/? I/Finsky: [2] myc.a(325): IT: Required downloads: [..split.ondemandfeature.config.xxhdpi, ..split.ondemandfeature, ..split.ondemandfeature.config.pt]
12:54:43.263/? I/Finsky: [2] mpw.a(3): Downloading full file for com.package.my (..split.ondemandfeature.config.xxhdpi)
12:54:43.282/? I/Finsky: [2] mxo.a(2): IT: Send Resource Request for com.package.my downloadid: ..split.ondemandfeature.config.xxhdpi).
12:54:43.287/? I/Finsky: [2] mxc.a(8): IT: Sent download request for com.package.my, adid: ..split.ondemandfeature.config.xxhdpi, isid: 21FGah5gQD6I6P4uDfGY32
12:54:43.379/? D/DownloadManager: [6235] …
Run Code Online (Sandbox Code Playgroud)

android android-app-bundle dynamic-feature dynamic-delivery dynamic-feature-module

3
推荐指数
1
解决办法
2360
查看次数

收到此错误“模块‘base’和‘moduleA’包含具有不同内容的条目‘res/drawable/xyz.xml’。”

moduleA 是一个具有依赖关系的动态功能模块,它是一个 aar lib。

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation project(':app')
    implementation(name:'lib', ext:'aar')
}
Run Code Online (Sandbox Code Playgroud)

它构建成功并安装在模拟器上,但每当我想创建应用程序包时,都会收到以下错误:

Modules 'base' and 'moduleA' contain entry 'res/drawable/xyz.xml' with different content.
Run Code Online (Sandbox Code Playgroud)

如果我应该在应用程序模块中重命名 xyz.xml,则会收到错误:

../moduleA/build/intermediates/metadata_feature_manifest/fullDebug/processFullDebugManifest/metadata-feature/AndroidManifest.xml:61:13-63:50: AAPT: error: resource drawable/xyz (aka my.app.main.drawable/xyz) not found.
Run Code Online (Sandbox Code Playgroud)

这是Plaid 的模块化文章中强调的问题之一。

为了解决这个问题,我必须在应用程序模块中创建一个空的 xyz.xml,但是在创建应用程序包时,我收到错误:

Modules 'base' and 'moduleA' contain entry 'res/drawable/xyz.xml' with different content.
Run Code Online (Sandbox Code Playgroud)

问题是什么以及如何解决?

android android-app-bundle dynamic-delivery dynamic-feature-module

2
推荐指数
1
解决办法
3237
查看次数

在基本(应用程序)模块中显示来自动态功能模块的片段?

在我的基本模块(应用程序)中,我有一些片段。我想将其中一个放在动态功能模块中,该模块将按需安装。在用户决定安装这个模块之前,我只会显示一个空的占位符而不是那个 Fragment。我知道如果它是来自动态功能模块的活动很容易,但我真的需要在我的基本模块活动中显示这个片段。

这可能吗?

android android-app-bundle dynamic-feature-module

2
推荐指数
1
解决办法
578
查看次数

Resources$NotFoundException 包含动态导航图

我有一个动态功能模块,它有自己的嵌套导航图。我还有一个动态功能模块,它只是一个片段。如果您有一个带有自己的导航图的动态功能模块,我知道您需要使用include-dynamic标签。当我构建应用程序并将应用程序部署到 Play 商店进行内部测试时,动态模块下载正确。但是,如果我在本地构建/运行 - 当我尝试导航到包含导航图的动态功能模块时,应用程序会崩溃。我以为在本地运行时一切都被捆绑了?有什么我想念的吗?

我得到的错误是 android.content.res.Resources$NotFoundException: com.xyz.app_name.two:navigation/two_navigation

main_navigation_graph

<!-- this works locally. module does not contain a nav graph -->
<fragment
    android:id="@+id/OneFragment"
    android:name="com.xyz.app_name.one.OneFragment"
    android:label="{nickname}"
    app:moduleName="one"
    tools:layout="@layout/one_fragment">
    <argument
        android:name="nickname"
        app:argType="string" />
</fragment>

<!-- this doesn't work locally -->
<include-dynamic
    android:id="@+id/two_graph"
    app:graphPackage="com.xyz.app_name.two"
    app:graphResName="two_navigation"
    app:moduleName="two" />
Run Code Online (Sandbox Code Playgroud)

feature_two_graph

<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@id/two_graph"
    app:moduleName="two"
    app:startDestination="@id/twoFragment">

    <fragment
        android:id="@+id/twoFragment"
        android:name="com.xyz.app_name.two.TwoFragment"
        android:label="{nickname}"
        tools:layout="@layout/two_fragment">
        <argument
            android:name="nickname"
            app:argType="string" />
        <action
            android:id="@+id/action_twoFragment_to_dialogFragment"
            app:destination="@id/dialogFragment" />
    </fragment>

    <dialog
        android:id="@+id/dialogFragment"
        android:name="com.xyz.app_name.two.ui.DialogFragment"
        android:label="bottom_sheet"
        tools:layout="@layout/bottom_sheet" />

</navigation>
Run Code Online (Sandbox Code Playgroud)

android android-jetpack android-architecture-navigation android-jetpack-navigation dynamic-feature-module

2
推荐指数
1
解决办法
336
查看次数

资源收缩器不能用于多 apk 应用程序

所以今天我决定尝试制作一个动态功能模块。我启用了 R8,并将 minifyEnabled 和 ShrinkResources 设置为 true。尝试编译时出现以下错误。

Resource shrinker cannot be used for multi-apk applications
Affected Modules: app
Run Code Online (Sandbox Code Playgroud)

还有其他人看过这个吗?关于堆栈也有类似的问题,但与 DFM 没有直接关系。

我希望保持此标志处于启用状态以避免库膨胀

摇篮插件:4.0.0

Gradle 包装器:6.1.1

android android-gradle-plugin android-r8 dynamic-feature-module

2
推荐指数
1
解决办法
4163
查看次数