I am making an AAR for licensing functionality. I plan to use it in multiple applications.
As per documentation, licensing implementation needs a permission in manifest file: "com.android.vending.CHECK_LICENSE"
I am not sure where should this permission be kept,in application's manifest file or library project's manifest file.
All your library related permissions/metadata/activities relevant info should be declared in your library manifest file
Related
In my project, I have an app module with instrumentation tests.
They use code from a library module which needs additional permissions that should normally not be included in the app. (WRITE_EXTERNAL_STORAGE)
I have put the permission in the libraries manifest and included it in the apps build.gradle using androidTestImplementation.
Unfortunately when I run the test it fails because the manifest of the installed application does not contain the required permission.
I also tried writing to context.filesDir since that should not require any permission, but it also fails with "Permission denied"
How can my library code write to the file system without the app module manifest having to include the permission?
In this page: https://developer.android.com/studio/projects/android-library.html#Considerations
It states that:
You can develop a library module that depends on an external library. (for example, the Maps external library). In this case, the dependent app must build against a target that includes the external library (for example, the Google APIs Add-On). Note also that both the library module and the dependent app must declare the external library in their manifest files, in a element.
So I tried to do what the paragraph says above.
1- I created a module that has this in its gradle:
compile 'com.twitter.sdk.android:twitter-core:3.0.0'
compile 'com.twitter.sdk.android:tweet-ui:3.0.0'
2- and I added this in my manifest.xml
<uses-library
android:name="com.twitter.sdk"
android:required="true"/>
3- I imported my .aar file to my main app.
4- I added the same code into my main app manifest.xml
<uses-library
android:name="com.twitter.sdk"
android:required="true"/>
But of-course it shows an error:
Delete <uses-library> from your manifest. It it only for cases where you are trying to use a "library" that is part of a device's firmware. The "Maps" example that they cite is from the long-obsolete Google Maps V1 for Android implementation.
I am not aware of any device manufacturer that has advised its developers to add <uses-library> elements to their manifest for com.twitter.sdk.
Does External Android Library have their Android Manifest merged with the main app?
Thanks
Actually it depends on the API you are using. Suppose you are using external API that doesn't require any hardware or network permission from OS than you don't need to add anything new in the manifest file. And if you are using external API that requires such permissions, then you must have to add them in your manifest file.
Only if you specify manifestmerger.enabled=true in your project.properties file if you are using eclipse.
With android studio i think it's the default behaviour
I have a project in Android Studio with two modules, say it Module1 and Module2 with dinamic generation a lot of product flavors using configuration files. Module2 is library linked to Module1. Also I have compiled third-party library (AltBeacons). 3rd-party lib declares permissions for BLUETOOTH and BLUETOOTH_ADMIN, but I d't want to use features that need these permissions in every flavor (only for one exactly) and can't move out lib from depenencies because of my Application inheritor uses it and appear as parent for another class that used in all flavors. So, I can fetch permissions from configuration files and declare them in Module2 manifest to merge later, but 3rd party library provides its permissions in all cases. I tried merge attributes but no luck. Here's my main manifest part where I tried to resolve the problem:
<uses-permission
android:name="android.permission.BLUETOOTH"
tools:node="remove"
tools:selector="org.altbeacon.beacon" />
<uses-permission
android:name="android.permission.BLUETOOTH_ADMIN"
tools:node="remove"
tools:selector="org.altbeacon.beacon" />
, where 'org.altbeacon.beacon' is 3-rd party package.
Resulting manifest includes permissions in all cases. If remove 'tools:selector' declaration, then specified permissions not came from all libs, but I need they if fetched from my Module2. Please, help me!
I'm developing an application, with another project as my library.
What properties are merged in the manifest files?
Example - If the permissions are already specified in the Library's manifest file, do they need to be specified again in the applications manifest?
Also, if there is a service in the Library project, do I need to specify again manually in the Applications manifest too (additional to library's manifest).
Thanks
There is a section of this page: http://developer.android.com/tools/projects/projects-eclipse.html#SettingUpLibraryProject that says you must (re)declare all of the bits of the library project that your application will be using in the manifest file.
Declaring library components in the manifest file
In the manifest file of the application project, you must add
declarations of all components that the application will use that are
imported from a library project. For example, you must declare activity, service, receiver, provider, and so on, as well as permission, uses-library, and similar elements.
Declarations should reference the library components by their
fully-qualified package names, where appropriate.
Personally, this seems redundant, but it may be because the app doesn't need to use all of the components of the library project, and the app shouldn't assume it will.