Dexguard conflicting with other plugins in Android development - android

I have been using Dexguard for my Android project, and it's been working fine until recently I had to use a another plugin. Because the way the other plugin is built, it is required that the project applies either "com.android.application" or "com.android.library". but since the dexguard plugin is an extension of the com.android.application which got replaced by dexguard, I can't use the other plugins that requires the "android" plugin.
//apply plugin: 'android'
apply plugin: 'dexguard'
Does anyone know if there's a way to get around this? I have contacted the authors of the plugin but it won't be practical to bother every plugin author for a solution.
Reference to my problem:
Dexguard plugin specification
And here's the plugin (android-apt) I'm trying to use that requires plugin: Android and only Android not dexguard.

The latest DexGuard plugin (6.1.03) works alongside the Android plugin (1.0.0), instead of extending it. This should improve its compatibility with other third-party plugins.

Related

Missing Google gradle plugins in Gradle plugin portal?

I was trying to migrate build.gradle files to use Kotlin DSL. Using the plugins block instead of apply (legacy, apparently) doesn't seem to be as straightforward as suggested. Since "com.google.firebase.appdistribution", "com.google.firebase.crashlytics", and "com.google.gms.google-services" are missing in the Gradle plugin portal (?). Can I not use them in the plugin block? I tried this but it didn't seem to work. Also, why are they missing? I still don't quite understand how this works so please bear with me.

Disable Google Services Gradle plugin for specific flavour

The usage of Google Services requires the use of this Gradle plugin:
apply plugin: 'com.google.gms.google-services'
This thread on the Gradle forum has lead me to conclude that you can't selectively enable or disable a plugin, meaning that is not an option. I've tried a number of solutions offered by older threads involving conditionals surrounding the apply plugin statement and none of them work now.
The plugin itself is configured by a google-services.json that Google generates and is placed into the project directory. I'm aware that you can have different configurations for each flavour by having multiple google-services.json files, but what are we meant to do for build flavours that we explicitly want to not use Google Services (e.g. for targeting devices that do not have Play Services installed)? Blank files or dummy JSON files don't work as the plugin will refuse to accept it.
So the only solution that I can think of would be to manually disable the plugin (comment out that line) each time I want to test/build my flavour. Surely there has to be a better way to control how the plugin works?
I finally got a version to work. Tested with gradle 4.6, build tools 3.0.1, google-services plugin 3.1.1
apply plugin: 'com.google.gms.google-services'
android.applicationVariants.all { variant ->
if (variant.name == 'someVariantNameYouDontwantFirebase') {
project.tasks.getByName('process' + variant.name.capitalize() + 'GoogleServices').enabled = false
}
}

Gradle: "apply plugin" at the top or at the bottom

Has the same effect add the "apply plugin" at the beginning or end of the file build.gradle in Android Studio projects?
For example to add the 'com.google.gms.google-services' plugin, Firebase official documentation recommends adding at the end, but I've seen other codes add it at the beginning.
I know the question seems irrelevant, but I'm developing a plugin for Android Studio to manage dependencies and have this doubt.
Thanks in advance
Gradle scripts are interpreted top to bottom so order can be important. Keep in mind that gradle has a configuration phase and an execution phase so sometimes order isn't important. It's common to apply your plugins at the top of the script since plugins often add extension objects and tasks to the gradle model which can then be configured lower down in the build script.
For example, you can't do the following because the test task is added by the java plugin:
test {
include 'org/foo/**'
}
apply plugin: 'java'

How to Create a SDK in Android Studio form the app

I have a Android app and now I have to make a SDK form the app. So other apps can use my SDK by just putting a compile time dependency I dont find many sources in Internet can some one please help me in this regard.I am using Andorid Studio
I want to build a SDK similar to MobiHelp SDK see this link : https://github.com/freshdesk/mobihelp-android
If your SDK is an Android-Library, declare
apply plugin: 'com.android.library'
instead of
apply plugin: 'com.android.application'
in the corresponding build.gradle. You will get an .aar-File (Android ARchive) that would need to be refereced from others in order to use your SDK.
If your SDK is a plain-old-java-Library (no Android resources) you also can use Maven to package it as jar.

Java-Module using Android API with Gradle

I am currently migrating an Android project from classic IntelliJ IDEA format to Gradle. In my project, there are modules that are using the Android SDK without being Android modules. They are plain Java modules that use the Android SDK instead of a JDK.
How can I achieve that with Gradle?
The approach I can think of is to apply plugin: 'java' and somehow configure the Android SDK as the used JDK or as a dependency. But I don't know how to do it exactly...
I have just revisited Eugen's first hint and "suddenly" it works.
So, basically you need to apply the Java plugin and add Android as a provided dependency.
apply plugin: 'java'
configurations {
provided
}
dependencies {
provided 'com.google.android:android:2.2.1'
}
#Eugen: Maybe you'd like to repost this to receive your credits.

Categories

Resources