Why there is no task generateXXXSource in instant app module? - android

For a project include installable, instant, and other modules, I can see there are gradle tasks of :installable:generateGoogleReleaseSources, :<module_name>:generateReleaseSources but I only see :instant:dummyGoogleRelease and there is no :instant:generateGoogleReleseSources (or any variant of it)
You can see it in action inside Android studio (this one is debug variant):
Executing tasks: [:instant:dummyDebug, :main:generateDebugSources, :detail:generateDebugSources, :base:generateDebugSources, :installed:generateDebugSources]
Is that supported? Cause I want to generate BuildConfig for instant app. The app module and the base module has it, instant module doesn't has it.
I tried put java sources, manifest, etc and same result.
(My android project has installable, instant, core (base feature), and many other library modules, as suggested by Google.)

Related

How can I share a Module's androidTest "Robots" with another module?

I am a big fan of the Robot pattern for keeping UI tests clean. But how can I reuse Robot classes across multiple modules?
:lib-with-ui . // has Robot classes in `src/androidTest`
:app
I fully test my lib-with-ui with the Robot classes, however I want to reuse those same Robot classes in the :app module for some quick smoke testing.
For why the smoke testing is useful, it's because we want to test the integration of all our components as well as catch any possible proguarding issue that may occur (we have a special flavor of our sample app that utilizes proguarded AARs of our libraries).
We've tried a variety of approaches to get this to work, but it has all lead to weird resource issues.
Robot classes are defined in module 'lib-with-ui' and you want to use this in module 'app'?
Add lib-with-ui android library module as dependency to app module. Any code and resources in the Android library is now accessible to your app module, and the library AAR file is bundled into your APK at build time.
https://developer.android.com/studio/projects/android-library.html#AddDependency

Android Studio 3.0.0 Beta 4 doesn't complain at compile time but fail the build while running assemble for R file

I have multiple feature modules in my instant app project structure. All of my resources which are being used in the multiple features are residing in my core module.
Assume my core module package name is com.andorid.myapp.core.
And I have a feature1 module with package name com.android.myapp.feature1.
Now If I am using any resources from core module into the feature1 module, I am referencing it with simply R.string.something_from_core and studio doesn't complain anything even I have imported com.andorid.myapp.feature1.R not com.android.myapp.core.R it just works fine. But when I run ./gradlew assemble, It doesn't build successfully and throws an error which says the R.string.something_from_core doesn't exist.
Now my 100s of my project files are using resources from core and I am not able to find which resources are coming from core and which are from feature1 because studio is not complaining anything while writing code it just works. And also the build is only breaking when it tries to run build variants like assmbleFlavourFeature, rest everything is working fine.
So confused with no solution, would be great if someone can help.
Seems there is a problem with cache.
Try my answer here :
My answer
Hope this helps.

Android Studio 3 difference between library module and feature module

In Android Studio 3 there are at least two new module types. First is Instant app module and the second one is feature module. With Instant App module it's quite obvious but feature module from my perspective is the same as the library module. So what is the real difference between library and feature modules and when I should use library module and when feature module?
I would complete Marcin Orlowski scheme like this.
You could picture library module in the same way as dependencies of a given feature or base module.
Hence the library modules will not be packaged in Instant APP APK.
A feature module is a module that applies com.android.feature plugin.
This module type has a dual nature:
When consumed by an application (com.android.application) during build, it produces an aar and works just like a library
When consumed by an Instant App APK (com.android.instantapp), it generates an Instant App APK
Developers should write feature modules just like library modules. The tools provided are responsible for applying the correct nature when used during a build.
In the simplest case an Instant app can have a single feature module.
If there is more than one feature module, these feature-to-feature
dependencies can be defined through the api configuration. In any
case, there must only be a single base feature which is marked with a
baseFeature attribute.
Main source: https://codelabs.developers.google.com/codelabs/android-instant-apps/#3
This all for Instant Apps so you only need it if you are making your app supporting instant app feature
See https://developer.android.com/topic/instant-apps/getting-started/structure.html#basic-app
Android SDK is the core features and software tools that allow you to create an app for the Android Platform. An SDK contains lots of libraries and tools which you will use to develop your application.
A Library is a collection of pre-built compiled code which you can use to extend your application's features. For example, you may need to show some graphics in your application. Instead of creating this from scratch, you may choose to use a pre-built library someone else has developed which will give you the features you need thus saving you some time.
A module is a small part of the application which can be tested and debugged on its own without needing the whole application. This is same for any programming language. Suppose you are building an app with Login feature. To test if the login feature works, you don't need the whole app. Thus the Login part is a module of your application.
The app module builds an app. A library module builds a library.
An app is what a user uses. The output of an app module is an APK, the package of an Android application.
A library is a collection of code that represents something that you want to use in multiple applications or otherwise want to keep in a separate "container" than the rest of the app code. The output of a library module is an AAR And Jar.
Use Feature for linked feature of your instant app (to launch it with deeplink).
Use Library for code dependency in your app or in your Feature modules.

ProGuard in AndroidStudio: How to get obfuscated library .aar files out of a multi-module project release build?

I have the following situation:
I have a project in Android Studio 1.4, which has 3 modules. The main module is the one for the app, the other 2 are library modules/subprojects. So when I build the whole project (using gradle), I get the app as .apk with all dependencies (the 2 library modules), and everything works as intended. I can also enable the minify option for ProGuard in the build.gradle file of the app module, which shrinks the app.
The 2 library modules additionally produce .aar files that I can use in other app projects (when running a release build for the whole project). Now I want to distribute the libraries, and I want to have them obfuscated (not shrinked) via ProGuard.
I want to have them automatically obfuscated during the release build of my app (preserving public APIs of course) without breaking the build process of my app because of missing classes etc. I tried to get this working using 'consumerProguardFiles' entries within the build.gradle files of the libraries, but with no success.
So how can I achieve that?

Android Studio / Gradle : force some modules to be built and copied to a directory before building the main app

I have an Android studio project that is made of several sub-projects, which are all android apps. It is setup like this:
Project
|---- Main app
|---- Other app 1
|---- Other app 2
|---- Other app 3
|---- etc.
The point is that all the "other app" sub-projects need to be included in the Main app final APK (they are plugins that the Main App can install on-demand when/if the user requests them).
So what I need is to setup the project so that:
Every time "Other app X" is built its APK is copied to Main App's
/assets/ directory
Every time "Main App" is built, it triggers a
build of all the "Other apps" that need building
Now, I'm used to Visual Studio, and there I can just set up project dependencies so that building one project triggers a build of the other projects, and I can set a post-build command that copies the generated binary to another folder quite easily.
With Android Studio and Gradle however I'm getting extremely confused.
First of all: even if I setup the project so that Main App depends on all the Other Apps this doesn't build the Other Apps' APKs, it only compiles their sourcecode (which is useless in my case, I need the final APK of the Other Apps).
Secondly, assuming I've been able to generate such APKs, I can't find a place where to setup a post-apk-generation command to copy those apks to another directory. I've been reading about gradle tasks and the "dependsOn" feature, however from what I understand the task that generates the actual APK ("assemble") is the last one in the build chain, so using dependsOn is no use to me, I would need something like "whenFinishedRun(myTaskThatCopiesTheAPKs)"
Any easy way to do this? Maybe it's because I'm a Gradle noobie, but this build system seems extremely convoluted to me, I'm actually thinking of writing an external program to run mamually to accomplish these tasks...
Rather than operating on the APK, gradle dependencies let you config an AAR dependency that can help with your issue.
Example dependency on aar here - see "amlcurran"

Categories

Resources