Uma*_*Uma 11 android android-manifest
如果我们在清单中设置android:debuggable = true并且如果我们在iOS中设置android:debuggable = false,是否可以为应用程序设置单独的图标?
Ale*_*kov 17
我派对有点迟了,但无论如何.目前我在16年发布了这个,你实际上可以设置不同的启动图标,只需将它们放到各自的目录中,但不确定它是如何在13年回来的.要实现这一点,您需要在app/src下创建debug/res目录,并将mipmap或drawable目录放在那里.所以你将拥有app/src/main/res /和app/src/debug/res / paths.Android将与构建相关的资源目录 - 主目录具有更高的优先级.将调试和释放资源放到适当的路径上,您就可以拥有所需的资源.考虑到您必须使用Gradle构建系统,请执行以上所有操作.
在这里你可以阅读更多关于这样的东西:http://tools.android.com/tech-docs/new-build-system/resource-merging
有点晚了(实际上大约8年了),但是当我今天浏览DuckDuckGo的Android源代码时,我发现他们是这样做的:
在你的app/build.gradle(DuckDuckGo 的app/build.gradle)
android {
...
buildTypes {
debug {
...
manifestPlaceholders = [
appIcon: "@mipmap/ic_launcher_blue",
appIconRound: "@mipmap/ic_launcher_blue_round"
]
}
release {
...
manifestPlaceholders = [
appIcon: "@mipmap/ic_launcher_red",
appIconRound: "@mipmap/ic_launcher_red_round"
]
}
}
...
}
Run Code Online (Sandbox Code Playgroud)
并且在您AndroidManifest.xml刚刚使用时(DuckDuckGo 的AndroidManifest.xml)
<application
...
android:icon="${appIcon}"
android:roundIcon="${appIconRound}"
...
/>
...
</application>
Run Code Online (Sandbox Code Playgroud)
有点晚了,但我会为正在寻找相同答案的人留下我的解决方案。
在定义buildTypes的build.gradle上,我为 debug_test 构建类型添加了一个后缀,以便在我的设备上安装不同的 apk。
buildTypes {
release {
...
}
debug_test {
debuggable true
applicationIdSuffix '.debug'
...
}
}
Run Code Online (Sandbox Code Playgroud)
之后,转到 File > New > Android Resource Directory 并为您的 debug_test 构建类型创建一个新的 mipmap 资源目录(如您在 Source set 上看到的):
我创建了 mipmap 文件夹,因为它是仅用于放置应用程序/启动器图标的文件夹。所有其他图像应放置在可绘制文件夹中。
将 ic_launcher 图标添加到创建的文件夹(app > src > res > mipmap > ic_launcher.png)。
现在,只需在您的 AndroidManifest 上引用您的图标,如下所示:
<application
android:name=".MyApplication"
android:icon="@mipmap/ic_launcher"
...
</application>
Run Code Online (Sandbox Code Playgroud)
魔术就完成了!
据我所知,应用程序图标仅依赖于它们所在的可绘制文件夹,并且没有-debug 的文件夹限定符,并且您无法根据清单更改更改图标
| 归档时间: |
|
| 查看次数: |
5482 次 |
| 最近记录: |