Updating gradle wrapper in Unity3D - android

I'm using Unity3D to build an Android game, but it looks like Unity is using old versions of Gradle. For example it's using Gradle Wrapper 4.6 instead of the latest one 5.0, or at least the previous latest 4.10.2.
I've tried replacing the gradle lib folder in Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib with a gradle version from Android Studio, Unity started saying invalid gradle installation
P.S: I've asked this on Unity, but either that place is dead, or not much support

Related

Unity crash on Android on startup: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/startup/R$string

We have a plugin for Unity to be used by games on Android. The plugin is built on macOS with gradle 7.1.1, multidex enabled, fat-aar, and grease 0.3.0
Building with Unity 2021.3.3f1 on macOS Monterey, deploying to device running Android 11.
Targeting Android SDK 32. Multidex is enabled, minify/jetifier/R8 all turned off in Unity's gradle build scripts. AndroidManifest.xml is set up properly to use multidex. I've checked spelling and class names, and since it's targeting SDK 32, we don't need to use the android.support package.
We're building a Unity project that only includes our plugin and some code that calls into it, so the project is already as barebones as it can get while still using the plugin. The Unity app was building and running just fine until we introduced fat-aar and grease. Also, Unity builds with a pretty old version of gradle, 4.6.
Our plugin also builds a test app APK, and that test app APK contains R$string.class as well as other R$* classes generated by multidex (found via dex2jar). Our plugin AAR contains R.txt that references androidx_startup.
It seems like a dependency isn't having it's string resources propagated forward to the final app, but I'm not even sure that's the problem.

Do all my dependencies (libraries that I am using) for my android studios project have to be using a Gradle version equal to or less than mine?

So let's say I have an application on android studios using Gradle version 4.1 with Gradle plugin version of 3.0. I have added implementation 'com.facebook.android:facebook-login:8.2.1' to my build.gradle file. However com.facebook.android:facebook-login:8.2.1 is using Gradle version 4.4.
So the only way for me to use this library (and that version) is if my project is on Gradle version 4.4 or greater?
Or is there a way for me to use that library (and that version) without changing my Gradle version?
Thanks.
Update: More Info
So specifically I am talking about using the stripe API. I was on version 6.1.2 but because of some new EU law, I need to update the version I am using to at least 9.1.1.
I noticed the only time I get this error 'apptransformClasseswithdesugarfordebug' when trying to run my app, is after they update there Gradle to use version 3.4.1 from 3.4.0 (not the Gradle plugin). On version of Stripe 9.0.0, my app is able to run, however, after switching to version 9.1.1, I get that error.
Note, my project is on Gradle version 3.1.4 and when it's on Stripe version of Gradle 3.4.0, my app is able to run.
So to wrap it up, I need to know if I need to be on the same version, although I doubt it because my app works with 9.0.0 of Stripe, which is using a different version of Gradle.

Android studio keeps asking to upgrade Gradle when importing sample projects

Downloaded AndroidStudio for Windows and importing sample projects from within the AndroidStudio GUI.
Everytime I import a project, it asks me to upgrade Gradle
To take advantage of all the latest features (such as Instant Run),
improvements and security fixes, we strongly recommend that you update
the Android Gradle plugin to version 2.3.0 and Gradle to version 3.3.
You can learn more about this version of the plugin from the release
notes.
Is this normal?
AndroidStudio 2.3
Yes this is normal if the projects you are importing are more than a few weeks old. The latest version of Android Studio and Gradle are pretty new at this point, so it will ask you to update older projects.

purpose of com.android.tools.build

I am a newbie to Android programming. I am using Android Studio 1.1.0
I have following query regarding building an app using gradle.
What is the purpose of specifying buildscript dependencies 'com.android.tools.build:gradle:1.1.0' in build.gradle
What does this build statement actually do.
I have searched the forum but could not find anything specific on this.
However from some of the google search it seems to suggest that this statement might be required for the gradle script to download Android Plugin for gradle.
I find it surprising that though I am using Android Studio I still need to download Android Plugin for gradle. Should it not be coming in-built.
Appreciate your time and help
As the name suggest, "Android Build Tools" is a command line tools for building your Java source code (along with all the related assets) into executable APK file. It's located at your Android SDK directory (usually at $ANDROID_HOME) and can be updated using Android SDK manager (accessible via Android Studio IDE).
What is the purpose of specifying buildscript dependencies com.android.tools.build:gradle:1.1.0 in build.gradle
Android is using Gradle build system. That build script dependency is Gradle plugin to interact (compile, test, etc) with the Android Build Tools. That line declares that your project require Android's Gradle plugin version 1.1.0.
I find it surprising that though I am using Android Studio I still need to download Android Plugin for gradle. Should it not be coming in-built.
Android Studio (AS) is just an IDE, you can actually use any IDE that support Gradle build system. Android Build Tools and its Gradle plugin (it's not AS plugin) is constantly updated by the devs separated from Android Studio project (although it's pretty closely related). Moreover, different projects can requires different version of build tools and its Gradle plugins. So it's just make sense that Android Studio requires them to be downloaded independently from the IDE.

Open project in Android Studio 1.0+ using gradle plugin 0.*.*

I am trying to open a Android Project in Android Studio 1.0.2 which uses
classpath 'com.android.tools.build:gradle:0.12.+'
as its dependency. On opening the project with above dependency I get the following error message.
The project is using an unsupported version of the Android Gradle plug-in (0.12.2). The recommended version is 1.0.0.
Is there a way to run such projects in Android Studio 1.0.+ without upgrading the Gradle plug-in version
Note:
I can upgrade the gradle version and plugin to get it to work OR simply use older version of Android Studio to open the project.
First approach is not desirable since this being a community project I will prefer to leave majority of files unchanged and changing gradle version will also hinder me from testing the build with 0.12.
To successfully build Android project using Android Studion and Gradle you need to use the AS, Gradle and Android Gradle Plugin with versions which are compatible with each other. Check out this page, it's said here, that you can use Android Gradle Plugin 0.12 with Android Studio 0.8.0 - 0.8.11 and there is no way to use it under Android Studio 1.0.
I suggest you convince other people to switch to the newest version of Android Gradle Plugin because 1.0.0 is the stable one and doesn't contain some bugs which were out there in the 0.12.+.

Categories

Resources