Sunday, December 8, 2019

Eclipse Android Manifest merger

The Android manifest merger is available starting with SDK Tools, Revision 20 (June 2012) and it merges your application AndroidManifest.xml with the AndroidManifest.xml's defined in the libraries added to your application.
General notes:
  • Build system
    • Added automatic merging of library project manifest files into the including project's manifest. Enable this feature with the manifestmerger.enabled property.

Also checkout the Google I/O 2012 - What's New in Android Developers' Tools starting at 48:59




Here is an example with dandar3/android-google-play-services-ads 18.3.0 library added to your application.

1. Your application.properties:
...
target=android-28
manifestmerger.enabled=true
android.library.reference.1=../google-play-services-ads

2. Your AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    package="com.example.googleplayservices.ads"
    android:versioncode="1"
    android:versionname="1.0">

    <uses-sdk
        android:minsdkversion="15"
        android:targetsdkversion="29">

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE">
    <uses-permission android:name="android.permission.INTERNET">

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name">
        <activity
            android:label="@string/app_name"
            android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-3940256099942544~3347511713" />

    </application>   

</manifest>

3. Check out the resulting bin\AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.example.googleplayservices.ads">

    <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="29"/>

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>

    <application android:allowBackup="false" android:icon="@drawable/ic_launcher" android:label="@string/app_name">
        <activity android:label="@string/app_name" android:name="com.example.googleplayservices.ads.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
        <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-3940256099942544~3347511713"/>

        <!-- Include the AdActivity and InAppPurchaseActivity configChanges and themes. -->
        <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:exported="false" android:name="com.google.android.gms.ads.AdActivity" android:theme="@android:style/Theme.Translucent"/>

        <provider android:authorities="com.example.googleplayservicesads.mobileadsinitprovider" android:exported="false" android:initOrder="100" android:name="com.google.android.gms.ads.MobileAdsInitProvider"/>
        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>

    </application>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>    

</manifest>

No comments :

Post a Comment