Android get top level module details in base module in android project - java

I have two different app in one android project, as they both use similar components. One is client app and other is admin app. I also have an base module which constis of common util classes, ui components and other shared code.
Let say App1, App2 and BaseModule. Now I want to access BuildConfig.VERSION_CODE of App1 or App2 depending on which app is build, in base module. How to access it. Do I need some gradle script to transfer current app version_code to base mode?
I am trying to use shared preferances to share version code. But is there any to use it like BuildConfig.VERSION_CODE

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 use the function passed in different android library module in the logger class

I have an android application, this android application has various separate android library module. Each module has a code which performs various activities related to the application like login, logout, specific activity related to application etc. Now I have created a separate android library module to log the various activities performed by the user in the application. But I don't know how to specify/pass the function name or parameter name that belong to other android library modules in logger class to just log the activities that happen in the application.So can anyone help me to do this?

How do I set up Google App Engine project that uses Task Queues and GWT? [duplicate]

This question already has answers here:
Google App Engine Task Queue on GWT
(2 answers)
Closed 8 years ago.
A lot of work I want to do involves long-running processes that I want to run on a hosted environment and provide a web interface for users to see the results of the long-running jobs.
I believe Google App Engine with its "modules" feature (https://cloud.google.com/appengine/docs/java/modules/) is a great service for this but I have been struggling to figure out how to set it up for this purpose (see App Engine Modules with GWT, Possible to use Google Modules with Google Plugin for Eclipse?, How use Eclipse to develop Google Modules for Google Cloud?). Someone may have been trying to do the same thing (see: how to create gwt gae with app engine modules using google eclipse plugin) but there's no accepted answer and I'm looking for a more comprehensive set of instructions.
Could someone provide a step-by-step set of instructions to set up the following Hello World project involving the following project architecture?
Requirements
User visits web page and types in a job name, e.g. "Hello World" and their email address where they will receive the results.
Google App Engine then performs a long-running computation (e.g. 10 hours, i.e. much longer than the 10 minute time limit for a module of Scaling Type "Automatic" as described here https://cloud.google.com/appengine/docs/java/modules/).
Google App Engine then sends an email to the user stating that the "Hello World" computation is finished and provides the result in the body of the email message.
Project Architecture
Web front-end (ideally GWT but propose any suitable alternative since it may be a problem as described here: App Engine Modules with GWT)
Module 1 (Scaling Type = Automatic): Responds to web front-end requests by putting a job on a Google Task Queue with the name provided by the user. The email address is recorded in the Google Datastore with a primary key equal to the job name (the purpose is I want to see how to make two modules share the same datastore; it's alluded to here: Serving multiple GAE modules from one development server? but I'd like to see more detail).
Module 2 (Scaling Type = Basic Scaling): Picks up the job from the Google Task Queue, performs the long-running computation, and emails the result. Note the email address is obtained by looking it up in the datastore using the job name.
Development Environment
Google App Engine
Java
Google Modules (https://cloud.google.com/appengine/docs/java/modules/)
Google Task Queues (https://cloud.google.com/appengine/docs/java/config/queue)
GWT
Google Data Store (https://cloud.google.com/datastore/)
Eclipse (Juno)
Maven (via m2Eclipse plugin)
Mac
Your first module is a GWT app. It provides a user interface.
When a user initiates a request, you make a standard RPC call to one of your services within the same module. Within this service you crate a task using Task API. This task includes a target parameter which points to your second module.
Alternatively, you can make a REST call directly to your second module.
Your second module is plain Java. It does not need GWT, and it's not a separate application in App Engine sense. It executes a task and emails the results to a user using App Engine Mail API.
You do not need anything special in Eclipse to create this setup. You simply create a new directory called EAR in your existing project and create/copy a bunch of configuration files. Modules Configuration provides detailed instructions on how to do it. If you are familiar with Backends, it may be easier to understand the process by reading Converting backends to Modules.
You can create two separate Eclipse projects - one per module, but it's not necessary. You can simply use a separate source directory for each module. For example, if you name your modules "gwtapp" and "backend" you can create the following packages in your project:
gwtapp.src.com.myproject...
backend.src.com.myproject...
Then open a build path (project Properties > Java Build Path), click on Source tab, then Add Folder. Add two folders:
gwtapp/src
backend/src
to your project. For each project select a different output folder: gwtapp/src will point to MyProject/ear/gwtapp/war/WEB-INF/classes, and backend/src will point to MyProject/ear/backend/war/WEB-INF/classes. You have to create these folders (ear/gwtapp/war/WEB-INF and ear/backend/war/WEB-INF respectively) before you do this step, of course.

Making a pluggable Android messaging app

I'm making a messaging app and I want to be able to extend it by using plugins.
The plugin might, for example, replace :) with a smiley image.
I've written some test code which uses intent filters to find the plugins, but I can't find a way to create an instance of the that plugin class.
Is it possible to do this, and if not, what would be the best approach/best alternative to this?
Thanks.
Because applications in android each run in their own VM, I don't think the classloader of your application will have access to the classes defined in the plugin. What you can do, however, is to pass the data between your main application and the plugin via Intents. If the plugin needs data from the main application, create a ContentProvider to make the data available.

Categories

Resources