Android/開発環境/AndroidStudio/ライブラリのAndroidManifest指定
提供: 初心者エンジニアの簡易メモ
ライブラリのbuild.gradleに以下を記述
android {
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
}
}
}
そのファイルがあるdirのsrc/main/AndroidManifest.xmlにAndroidManifestを記述すると、
元々のAndroidManifestは無効になって、置き換わってるっぽい。
マージされたAndroidManifest.xml
以下にマージされたAndroidManifest.xmlが出力される
app/build/intermediates/bundle_manifest/debug/bundle-manifest/AndroidManifest.xml app/build/intermediates/merged_manifests/debug/AndroidManifest.xml /app/build/intermediates/instant_app_manifest/debug/AndroidManifest.xml
mylibrary のsrc/main/AndroidManifest.xmlに以下を追加
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mylibrary">
<meta-data
android:name="hoge"
android:value="mylibrary" />
</manifest>
mainのsrc/main/AndroidManifest.xmlに以下を追加
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="hoge"
android:value="main" />
<meta-data
android:name="hoge2"
android:value="mainmain" />
</application>
</manifest>
