Using module feature as installable library - java

Actually, my app features are split into android library and I choose the feature I want include at the compile time. Is it possible to have a default app with very basic features, and an on-demand installable feature shipped as APK ?
I thought I could use module feature which was made for instant app because they are like android library but can generated APK but when I tried it out, the package name was different so it was impossible to use it.
I know it's the proper way to use android feature but can I use my own tricky way ? Otherwise, is there other possibilities to achieve this ?

Related

How to upload two separate .aab files with different configuration on google play store?

I know a single app bundle is enough to support different kinds of configurations, but one of our module is in react native and recently we've upgraded the Gradle version to 7.0.0. due to which our build machine won't let us use the minimum SDK below 21. This is why I wanted to create separate .aab files(one created on the build machine the other one from android studio) with different API levels(one will support android 19+ and the other one will support android 21+) and I wanted to upload these bundles without changing package name or application id. Any suggestions around this? or is there any better way to do this?
Note:- Two separate .aab are a must. I already have looked into this solution but it is not helpful to me.

Swift and Android - Can I exclude binaries from certain target deployments?

I have an Android and iOS app that can be whitelabeled to several different clients,
This could grow, so I don't want to manage 4 different projects and keep it as singular a codebase as much as possible.
One issue i have, is each client has a different third party provider for Feature X (say, working with a smart-light system).
I am looking into feature toggles, so that I can have a config file that specifies which services should be passed around and what features are activated for each client - but the problem is some of these third party binaries cause things to "happen" even if I don't instantiate a class using them specifically, like registering certain things in the background or requiring permissions from the user etc just because I have the binary included.
Is there a way to programatically ignore binaries for certain deployments of my app?
I am trying to copy the Android 'flavors' system, and I haven't found a solution there either but for now iOS is the priority.
Interested if there's a solution for either system or how others have approached this situation.
Using flavors
Gradle allows you to include dependencies only for certain flavors. You can just write the flavor name in front of your import statement (usually it's implementation and api).
For example, if you have the flavor demo, you can include a certain dependency by importing it with demoImplementation:
android {
...
flavorDimensions "version"
productFlavors {
demo {
dimension "version"
}
full {
dimension "version"
}
}
}
dependencies {
// This will only be included when you build the "demo" flavor
demoImplementation 'com.squareup.retrofit2:retrofit:2.9.0'
}
Using dynamic feature module
Dynamic feature modules are modules which can be downloaded dynamically after an application has been installed or at install time.
For example, if some feature requires NFC, you can extract this code to a dynamic feature module and let android install it only on devices, which have NFC. Devices without NFC won't even download it.
Or you download and install a feature which is not used by most users only after a user presses a button in the app.
An example for this can be found in the On Demand Modules codelab.

How to package a closed-source AAR library with stub java files

I'm using Android Studio 2.3 to create a hardware interface library that we can distribute to partners. I would like the inner workings of the library to be closed-source, but provide documented 'stub' classes and methods that can be viewed in Android Studio.
I tried compiling my library and importing the AAR to another project, and Android Studio lets me use the classes correctly, but it doesn't show any java files or documentation in the new project.
Is there a standard practice for how to achieve this? I'm just moving into Android development from C, so I'm used to being able to provide header files with my libraries. It seems like there should be a way to achieve something similar without too much hacking.

Using part of an Android app in a non-Android Java project

I'm working on a server backend component for an app, and one goal is to log all the messages transmitted through the app (using MQTT). To do this, I wanted to use the app as a library of sorts so that I could use the objects defined within to parse the messages coming through, since none of the messages will be transmitted as standard types. I'm using IntelliJ for the Java development, and Android Studio for the Android development. Is this possible? I was previously able to import the code as a module, which let me use the types defined within, but when I went to build the project it tried to build the Android code as well and failed because IntelliJ hadn't set up Android dependencies. Should I try and set the Android SDK as a dependency in the app module, and then build? Or am I approaching this the wrong way? (if it's even possible) I understand that there are also Library projects which looks like a possible solution, it would just require re-factoring all the applicable code out to a different project and I was hoping that wouldn't be necessary.
Trying to import the entire Android app as a library into a different codebase probably isn't going to work; you don't want a non-Android app to have all that Android code linked in, and with resources and the whole environment it will be tough to get it to compile at all.
A better approach would be to take all of the code that needs to work cross-platform and distill it into a plain Java library that you can include in multiple contexts. On the Android side you could include it as a plain Java library project, or compile it to a jar and include the jar.

Convert android project to java project

I've just finished developing an application for android. I want to have a desktop version that is based on java, too.
I have to convert all layouts to swing and what other conflicts I may face, god knows.
Is there a tool for converting android apps to jar standalone? What is the easiest way to do this?
There is no tool to do this, as Android and Normal Java apps are very different.
The best you could do is move the non platform specific code into a library project, and reference it from both the Java and Android applications. So all code that doesn't use any import with android in it should be movable into the library, while all your swing/android specific code will go into the referencing projects.

Categories

Resources