Reputation: 1651
So I've an Android lib that I made, that library has an activity a service and some permissions declared in the lib manifest. I also have a demo app which uses the lib jar. So what I want to do is to use that lib on that demo app or any other app without having to declare the activity, the service and if possible the permissions each time I use the lib. If I don't declare the activity, the service and the permissions in the demo app my demo app crashes on runtime. As far as I know; Android merges the manifests but I don't thinks that its doing it. Here is my lib manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mylib">
<!-- This app records A/V content from camera and stores it to disk -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application>
<activity android:theme="@style/Transparent"
android:name="org.mylib.activities.CheckStoragePermissionsActivity"/>
<service android:theme="@style/Transparent" android:name="org.mylib.services.BackgroundVideoRecorder"/>
</application>
</manifest>
and here is my demo app manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mx.mydemo">
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".activity.LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activity.RegisterUserActivity" />
<activity android:name=".activity.LogGameDataActivity" />
<activity android:name=".activity.GameResultsActivity" />
<activity android:name=".activity.PasswordResetActivity" />
</application>
</manifest>
Is there something wrong in any of my manifest that is not allowing them to be merged? Does the lib manifest package and the demo app manifest package needs to be the same package?
Greetings
Upvotes: 0
Views: 375
Reputation: 1006644
By the way the lib and the demo app are 2 different and separate projects I'am pasting the lib jar in the demo lib folder and then I'm telling android studio to import the jar as a library.
That is not going to work. The JAR is just Java code; it does not contain the manifest, resources, or assets from the library module.
Either:
Move these into one project as separate modules, then use compile project()
syntax in the demo project to pull in the library module, or
Publish the library module as an AAR to an artifact repository (a local one on your development machine, Maven Central, JCenter, whatever), and have the demo app pull it in from there, or
Copy the AAR, not the JAR, from the library project into the demo project
I strongly recommend either of the first two options.
Upvotes: 1