我在我的动态功能模块中使用了一些库。这些库正在向清单中添加一些提供程序。
例如在我的动态模块中的 build.gradle 文件中:
dependencies {
...
implementation 'com.github.esafirm.android-image-picker:imagepicker:1.11.1'
...
}
Run Code Online (Sandbox Code Playgroud)
该库将以下标记添加到清单中:
<provider
android:name="com.esafirm.imagepicker.helper.ImagePickerFileProvider"
android:authorities="{$applicationId}.imagepicker.provider"
android:exported="false"
android:grantUriPermissions="true" >
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/image_picker_provider_paths" />
</provider>
Run Code Online (Sandbox Code Playgroud)
问题是当我构建我的基本模块时,应用程序崩溃了,因为它找不到提供者。我该如何解决这个问题?
正如此处所述:
应用程序基本模块的清单与任何其他应用程序模块的清单相似。请记住,当 Google Play 生成您应用的基础 APK 时,它会将所有模块的清单合并到基础 APK 的清单中。
但为什么只有供应商受到影响?活动是否被忽略?
这是我得到的堆栈跟踪:
java.lang.RuntimeException: Unable to get provider com.esafirm.imagepicker.helper.ImagePickerFileProvider: java.lang.ClassNotFoundException: Didn't find class "com.esafirm.imagepicker.helper.ImagePickerFileProvider" on path: DexPathList[[zip file "/data/app/ir.rashin.mototel-h7B8g42gBcVABkik16vqzw==/base.apk"],nativeLibraryDirectories=[/data/app/ir.rashin.mototel-h7B8g42gBcVABkik16vqzw==/lib/x86, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:6396)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5938)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5853)
at android.app.ActivityThread.access$1100(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: …Run Code Online (Sandbox Code Playgroud) android android-manifest android-app-bundle dynamic-feature dynamic-delivery
我已经阅读了关于使用 Android App Bundles 为每个用户的设备配置生成和提供优化的 APK 的android Dynamic Delivery,因此用户只下载运行您的应用程序所需的代码和资源。
我使用react-native创建了一个应用程序。我们如何启用基于用户所需的特征作为特征交付的动态交付。
例如,应用程序有两个功能,如 Feature-A 和 Feature-B,但并非所有人都需要。因此,用户将从 Google Play 商店下载基础 APK,之后用户将下载他们要求或订阅的功能 APK。
我正在尝试将新的 Android 动态交付功能添加到我的应用程序中,但是我尝试访问动态功能模块的资源一直失败。
基本思想是加载一个没有代码但一堆矢量文件作为可绘制资源的模块。
我能够加载模块,甚至访问给定模块的资产,但我不知道如何访问资源。
val res = context.createPackageContext(context.packageName, 0).also {
SplitCompat.install(it)
}.resources
val assetsStream = res.assets.open("test.txt")
val assetContent = assetsStream.bufferedReader()
.use {
it.readText()
}
var iconResourceId = res.getIdentifier(stringIdentifier, IDENTIFIER_DRAWABLE, context.packageName)
Run Code Online (Sandbox Code Playgroud)
正如我所说,我能够阅读资产 txt 文件中的文本,但我似乎没有在资源中找到任何可绘制对象。
当我尝试获取我知道在动态模块的资源文件夹中的可绘制对象时,我得到一个 ResourcesNotFoundException
我已通读 Google 提供的 Android 文档,但找不到有关如何访问下载的模块资源的详细信息
https://developer.android.com/guide/app-bundle/playcore#access_installed_modules
我正在我正在从事的项目方面试验 Android 的动态功能模块(又名按需模块)。
在我的 PoC(概念验证)项目中,动态功能模块 (DFM) 工作正常,gradle 可以毫无问题地构建项目。在完成我的 PoC 之后,我决定将其应用于现有项目。但是,gradle 无法通过以下方式构建项目:
Could not determine the dependencies of task ':my-app:checkSomeBuildFlavorDebugLibraries'.
> Could not resolve all task dependencies for configuration ':my-app:someBuildFlavorDebugMetadataValues'.
> Could not resolve project :features:myDynamicFeatureModule.
Required by:
project :my-app
> Cannot choose between the following variants of project :features:myDynamicFeatureModule:
- anotherBuildFlavorDebugAndroidTestCompile
- anotherBuildFlavorDebugAndroidTestRuntime
- ...
All of them match the consumer attributes:
- Variant 'anotherBuildFlavorDebugAndroidTestCompile' capability myproject.features:myDynamicFeatureModule:unspecified:
- Unmatched attributes:
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
- Required …Run Code Online (Sandbox Code Playgroud) android gradle android-build-flavors dynamic-feature dynamic-delivery
我有应用程序模块和一个名为“聊天”的动态模块。我有一个布局和片段驻留在聊天模块中,在布局中有一个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
我正在使用 Android 应用程序。到目前为止,我的资产上有一些文件,我可以使用这些文件进行访问
context.getAssets().open(fileName)
Run Code Online (Sandbox Code Playgroud)
现在我正在尝试将动态点播模块与一些应用程序功能集成。我将一些资产文件从应用程序模块移动到动态模块资产文件夹,因为这些仅需要动态功能。使用下载按需模块后,所有功能都可以使用SplitInstallManager
但我没有使用上面的代码获取资产文件。
我们是否需要以相同的方式访问应用程序模块的资产。或者按需模块还有其他选择吗?
当我从 android studio 分析 aab 文件时,我看到资产文件夹和文件包含在按需模块中。我正在使用 google play 的内部应用程序共享进行测试。
提前感谢您的帮助。
我正在我的应用程序上添加一个按需动态功能模块,但我遇到了问题。
当我安装该功能模块时
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
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