Does an Android Library need a manifest ,app_name,Icon?

此生再无相见时 提交于 2020-01-12 11:58:19

问题


I have an android Library that outputs an aar library. This library will be built into different projectFlavors of Mobile, TV and Wear apps. I think that each of these platforms' should be the ones that set variables like the app name, icon, and permissions through the manifest and productflavors.

Is there any way to build an AAR without requiring an AndroidManifest.xml and therefore drawables(for the icon)?

More information about what I'm doing can be found at my last question on the subject: Android Studio Java Library Module vs. Android Library Module


回答1:


Any android library needs to have an AndroidManifest.xml file, but a name or an icon is not required. It's only needed when there is an activity that is MAIN and LAUNCHER.

You simply could use this manifest and your library will work like a charm.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="[your package]"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="[min supported version]" />

    <application/>

</manifest>



回答2:


You can go with the AndroidManifest.xml below if you don't need to setup any Android component like Activities or Services or add custom properties.

<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.your.library.base.package" />


来源:https://stackoverflow.com/questions/28157981/does-an-android-library-need-a-manifest-app-name-icon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!