55

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

Community
  • 1
  • 1
BillHaggerty
  • 6,157
  • 10
  • 35
  • 68

2 Answers2

60

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>
Juampa
  • 2,035
  • 2
  • 25
  • 35
  • Why not using `targetSdkVersion` and `maxSdkVersion`? and what about `uses-feature` and `uses-permission`? – Yousha Aleayoub Aug 27 '16 at 00:51
  • @YoushaAleayoub can't speak for the poster, but I presume his intent was to show a rather unassuming manifest, not to give a complete example (in this regard even the uses-sdk is probably an extra, though who wants a minSdkVersion set to 1 anyway? :) ). You are free to add the frills, like permissions etc – Rick77 Oct 21 '16 at 15:31
  • 1
    Do you ever need to put something in the ? I have an activity in my library module but it does not seem to matter whether I indicate the activity in the library AndroidManifest or not. Also, it seems I can put in any value for the package; it does not need to correspond to the actual java package of the library – Brian Reinhold Jul 21 '17 at 18:31
  • 3
    `` usually generated by the gradle configuration, in modern Android builds. – Anm Jul 29 '17 at 19:32
23

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" />
MatPag
  • 41,742
  • 14
  • 105
  • 114