根据构建风格引用不同的资产

编程入门 行业动态 更新时间:2024-10-28 04:27:11
本文介绍了根据构建风格引用不同的资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我能够在debug版本上获得正确的api_key.txt,因为那是buildType.但是,我无法在productFlavor amazon上使用它.

I am able to get the correct api_key.txt on debug builds because that is a buildType. However I am unable to get this working with the productFlavor amazon.

我尝试在已编译的build.gradle文件中执行此操作,但实际上在运行时它不会引用正确的文件:

I’ve tried doing this in my build.gradle file which compiles but it will not actually reference the correct file at run time:

sourceSets { amazon { assets.srcDirs = ['app/src/amazon/assets'] }

这是我的文件夹结构:

当我的商品口味为amazon时,如何在amazon/assets文件夹中引用api_key.txt?

How can I reference api_key.txt in the amazon/assets folder when my product flavor is amazon?

非常感谢所有帮助,谢谢.

All help is greatly appreciated, thank you.

推荐答案

基于此 https ://developer.android/studio/build/build-variants 文档,您需要这种类型的应用程序层次结构. 从所有构建版本中删除assets.srcDirs,您可以尝试使用这种结构.

Based on this developer.android/studio/build/build-variants document you want this type of hierarchy structure of your application. Remove assets.srcDirs from all build flavours and you can try with this kind of structure.

buildTypes { release { // ... the usual stuff here } releaseAlt { // .. the usual stuff here too like signing config etc... } }

文件层次结构,您应该像这样:

file hierarchy You should have like :

project/ - app/ - src/ - main/ - assets/ - logo.png // Generic assets go here - java/ - res/ - ... - flavor1/ - assets/ - logo.png // Specific assets for all the flavor1 Variants - release/ - assets/ - logo.png // Specific assets for all the releaseAlt Variants. - flavor1Release/ - assets/ - logo.png // very specific assets for the flavor1ReleaseAlt Variant - SDK/

更多推荐

根据构建风格引用不同的资产

本文发布于:2023-11-08 09:33:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1569012.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:风格   资产

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!