Missing Google gradle plugins in Gradle plugin portal? - android

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.

Related

Errrors, when configuring react-native project (building gradle) with android studio. I want to build gradle scripts for using firebase with my app

I ran into this problem after i updated android studio and the gradle version. Here's what i did step by step:
First i got the following error:
Build Gradle Error Could not get unknown property 'compile'
I checked stackoverflow and it said that changing "compile" with "implementation" would solve the problem, and so i did that.
Another issue was that maven was deprecated. So i used, maven-publish instead of maven.
Now i am getting the following error:
12:24 PM Gradle sync failed: Could not find method uploadArchives() for arguments [build_a5ye7ixpcm9qfmol93kt3ucl1$_run_closure4#73b8042a] on project ':expo-application' of type org.gradle.api.Project. (17 s 537 ms)
In this part of code in build.gradle(:expo-application):
uploadArchives {
repositories {
mavenDeployer {
configuration = configurations.deployerJars
repository(url: mavenLocal().url)
}
}
}
I am not really familiar with android studio or java. I just use Android Studio for configuring react native apps for android. Can someone please help me resolve these issues..
Thank you
As of Gradle 7.0, compile has been removed in favor of api. When you changed compile to implementation, you effected the transitive properties of the libraries. I'm not sure where you read that changing compile to implementation was the correct answer, but it isn't. api is a much closer approximation to compile. This chart gives a fairly easy to understand explanation of why this is. You should change the implementation to api and make sure you are using the java-library plugin instead of the java plugin. This should allow gradle to see the UploadArchives method. However, this wil cause a new issue.
As of Gradle 6.0, UploadArchives is also deprecated along with the maven plugin. You should consider using the maven-publish plugin instead. This will ensure your build continues to work in future Gradle releases.
So, to summarize, make sure your plugins look like this
apply plugin: 'java-library'
apply plugin: 'maven-publish'
and update your code to use publishing instead of UploadArchives. More information on this can be found in the current Gradle user guide here.
Alternatively, you can downgrade your gradle version to something before 7.0 and just ignore all the deprecation warnings. The choice is yours.

Clean way to publish Android Library AAR with external dependencies with maven

I am building an Android Library that I am trying to publish to a Nexus Maven Repository. What leaves me puzzled is that there seems to be no clean way of publishing my project through gradle with the maven-publish plugin.
I found a number of answers, which don't really satisfy me:
This plugin only works okay-ish and it is not currently maintained.
Modifying the generated POM in my build.gradle works, I just don't feel like this is the way it should be done - it seems to common of a problem to be solved in each and every android library's build.gradle.
Google even mentions the maven-publish plugin in their documentation but they don't really show how to use it.
Please tell me what I am missing: Is the problem less trivial than I think? I am just trying to publish an AAR with a pom stating it's dependency, I am trying to build the most standard and default solution I can.
Thanks in advance.

Warning:Using incompatible plugins for the annotation processing: android-apt

I have seen this post dotted around on the site, but the answer always appears to be the same "Remove apply plugin android-apt" but i have never and will never (because it's deprecated) use android-apt in my project? I've not included it anywhere nor applied it as a plugin in any files.
Is it possible for third party libs to add it to my gradle build file during the build process? How can i prevent this? It's causing things like ButterKnife to fail when using the new annotationProcessor
OK, i found my own answer! It turns out the issue was my realm plugin was too old, and internally still used android-apt (Realm.io) upgrading that to the latest version (3.0.0 at time of writing) resolved the issue immediately.

Android grade syntax and build tools compatibility issues

I didn’t work full-time with Android in the last couple of years, and now whenever I try to fork someone code on GitHub I get a lot of errors since android tools and Gradle syntax are changing frequently.
I wonder what is the best way to handle these changes, and be able to upgrade other GitHub projects and some of my old projects to work with the latest Android tools. Here are some of the things that I struggle with:
I noticed some of the issues are related to changes in the Gradle syntax. How can I know what Gradle version the build.grade syntax was written with? and then how to upgrade it to the current version (is there a migration guide for Gradle versions?).
Sometimes I get issues related to tools that are not compatible with others, how can I know which version are compatible with which? and whats the easy way to manage that? here are some of these tools:
Gradle
Android Plugin for Gradle
Build Tools
Android Studio
How can I know what Gradle version the build.grade syntax was written with?
If the project contains a gradle/wrapper/gradle-wrapper.properties file, that is the version of Gradle that the developer of the project is using.
is there a migration guide for Gradle versions?
I am not aware of much Gradle syntax that would have changed that would affect Android developers for garden-variety projects. Most of the changes are from the DSL added via the Gradle for Android plugin. You can find the version of the plugin that the project developer was using via the classpath statement in the project's top-level build.gradle file.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
The above snippet is requesting version 1.3.0 of the Gradle for Android plugin.
Migration documentation for the Gradle for Android plugin is minimal. What there is can be found up on http://tools.android.com.
how can I know which version are compatible with which?
Here is Google's statement on the issue, though this has not been updated in a few months.
and whats the easy way to manage that?
If the tools complain, change them to a set that you know is good (e.g., by copying values from a known-working project). If you need something that was introduced in a newer version of the tools, change them to a set that you know is good. Otherwise, don't worry about them.

Dexguard conflicting with other plugins in Android development

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.

Categories

Resources