Unity - Gradle Build error : Could not resolve all files for configuration ':releaseCompileClasspath' - android

I am developing a game for Android mobile phones on Unity. I recently updated my facebook SDK , due to merge conflicts when building the app caused by the extra libraries that had to be added to the project by the Play Services Resolver I had to edit my Gradle.properties file to look like below.
org.gradle.jvmargs=-Xmx4096M
android.useAndroidX=true
android.enableJetifier=true
I did this mainly cause some of the support libraries were the cause of the merge conflicts. But now I keep getting the following error and I do not know how to fix it. I have tried reimporting the SDK several times but I still get the same problem. I have also tried asking on the Unity forums but I have received no responses yet. Any help would be appreciated.
* What went wrong:
Execution failed for task ':preReleaseBuild'.
> Could not resolve all files for configuration ':releaseCompileClasspath'.
> Failed to transform artifact 'com.android.support.support-v4-27.0.2.aar (:com.android.support.support-v4-27.0.2:)' to match attributes {artifactType=android-manifest}
> Execution failed for JetifyTransform: D:\Unity\Projects\Mzito-NewBG\2017.3\Mzito - Unity 2018.1.2f1 - GameTrove\Mzito\Temp\gradleOut\libs\com.android.support.support-v4-27.0.2.aar.
> Failed to transform 'D:\Unity\Projects\Mzito-NewBG\2017.3\Mzito - Unity 2018.1.2f1 - GameTrove\Mzito\Temp\gradleOut\libs\com.android.support.support-v4-27.0.2.aar' using Jetifier. Reason: The given artifact contains a string literal with a package reference 'android.support.v4' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.. (Run with --stacktrace for more details.)

go to Assets\Plugins\Android and remove all content then
in unity editor in Assets menu go to Play Service Resolver(or external play resolver) >Android Resolver>Resolve
now everyThing is oK!

I was having the same issue, I've fixed it with :
Assets
Play Service Resolver
Android resolver
force resolve

Right click on assets folder
Select Play Service Resolver
Android resolver
Resolve
It will fix the problem but make sure your java environment variable is setup otherwise it might not work

Related

Flutter - Can't build apk. Execution failed for task ':app:minifyReleaseWithR8'

I'm trying to build the release apk of my project and stumbled on this error today:
R8: Type io.flutter.plugins.webviewflutter.GeneratedAndroidWebView$WebViewClientHostApiCodec is defined multiple times
What went wrong:
Execution failed for task ':app:minifyReleaseWithR8'.
com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: /flutter/.pub-cache/hosted/pub.dartlang.org/webview_pro_android-2.8.3+3/android/build/intermediates/runtime_library_classes_jar/release/classes.jar:io/flutter/plugins/webviewflutter/GeneratedAndroidWebView$WebViewClientHostApiCodec.class
This is related to the flutter_webview_pro plugin. I'm using the 3.0.1+3 version. I've tried to open an issue on the plugin's github page, but can't find the Issue tab. Is there a better alternative to this plugin? Can't use the official one because it doesn't support opening a file chooser on Android. Thanks for the attention in advance.
Sadly I didn't find the answer to solve this problem and decided to use another plugin for the same purpose: https://github.com/pichillilorenzo/flutter_inappwebview
I believe you were probably importing another package that this webview_pro also imports, maybe even the default webview_flutter

Gradle build failing - "A problem was found with the configuration of task ':app:generateSafeArgsDebug' (type 'ArgumentsGenerationTask')."

I'm trying to open and run the android architecture components sample project here: https://github.com/android/architecture-components-samples/tree/main/GithubBrowserSample in Android Studio. One one machine I'm able to get the project built and run just fine, but on my primary machine I'm seeing a build task error:
A problem was found with the configuration of task ':app:generateSafeArgsDebug' (type 'ArgumentsGenerationTask').
> No value has been specified for property 'enableGradleWorkers'.
I've tried the version of gradle and the gradle plugin that the project seems to have been built with, as well as the latest of each. I do have "android.enableGradleWorkers=true" specified in gradle.properties.
I haven't found this message when searching around, but I often see similar-looking errors when opening projects from different sources. I'd love to be able to fix this one, and ideally understand more about what to check when encountering build errors with projects from different sources in the future.

Ignite CLI (React Native) + Facebook SDK = Android Multidex?

Alright, so really just posting as a sanity check, and making sure I'm not doing my android all wrong. Essentially, it seems needing to use multiDexEnabled true is not best practice, as it means the app is getting "big", aka bloated. But it takes very little to get there with the tools I'm using, which I'll outline below.
TL;DR: Using multidex seems to be bad practice, is there a different solution?
Starting with a vanilla Ignite CLI Bowser project, a template engine for React Native, and adding the React Native Facebook SDK according to the official guide, results in a build error for the android application.
ignite new TestApp
cd TestApp && yarn add react-native-fbsdk && npx react-native link react-native-fbsdk
Following Android Guide, make relevant changes to
TestApp/android/app/src/main/java/com/testapp/MainApplication.java and TestApp/android/settings.gradle
Then, following the linked Facebook SDK guide (auth wall), made the relevant changes to TestApp/android/app/build.gradle, TestApp/android/app/src/main/res/values/strings.xml and TestApp/android/app/src/main/AndroidManifest.xml
Then, running npx react-native run-android, results in the following build error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDexDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
More searches point to a fix of adding multiDexEnabled true to defaultConfig within the module build.gradle, which does fix the error. The issue, is most of those solutions also lead to others pointing out poor library management, importing too much, etc.
So, am I doing something wrong, or is this just the result of using Facebook SDK and Ignite CLI and there's nothing I can do about it? I just worry, as I was hoping to add more than one provider's OAuth to the application, but don't want a bloated application that never loads.
It's not related to libraries used in your project but to the number of methods used.
When your app and the libraries it references exceed 65,536 methods, you encounter a build error that indicates your app has reached the limit of the Android build architecture and you have to turn on multidex to be able to support more methods.
https://developer.android.com/studio/build/multidex

Unity 2018.3 android dex merging issue

Before you decide to dismiss this post as "duplicate" without even reading it, understand that I have looked at a TON of posts related to this topic and I can't find a solution for my instance, including all of the ones that StackOverflow suggested. Most of the posts are for Android Studio instead of unity.
My error is given in Unity when trying to build to android, it crashes here.
CommandInvokationFailure: Gradle build failed.
C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\OpenJDK\Windows\bin\java.exe -classpath "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.6.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleDebug"
stderr[
D8: Program type already present: com.unity3d.ads.BuildConfig
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':transformDexArchiveWithExternalLibsDexMergerForDebug'.
I've tried changing stuff with a build.gradle file like a lot of posts suggest, but I can't get anything to work.
The error didn't exist in Unity 2018.2. I checked right before I updated, but the update is now throwing this issue.
Does anyone have any UNITY specific ideas what to do here? I've tried so many things and nobody's post has been able to help me yet.
Thanks for any help
You can open the PackageManage under Window in the menu bar and remove Advertisement or you can delete the com.unity.ads file of Library/PackageCache in the project directory to resolve this issue.
This error probably happens when you add a library which is not compatible with your compileSdkVersion.
In your case you can have libs that were not imported by default by unity (and now are)
or there can be a problem with the Build Tools version. (You can try updating them)
I had similar problem a few versions ago, but I don't remember how I fixed it.
I didn't have time to upgrade to unity 2018.3 yet. (So the tips are more like guesses, but it may help you solve the issue.)
My settings (Mac):
- Android Studio 2.3
- Unity 2019.1.5f1:
- Player Settings -> Other Settings –> Scripting Runtime Version = .Net 4
- Package Manager -> Advertisement: Uninstalled
- Preferences -> External Tools -> Android: checked Installed with Unity (everything)
My solution:
- delete GoogleMobileAds from project
- delete PlayServicesResolver from project
- delete Plugins from project
- Import Package -> Custom Package -> GoogleMobileAds.unitypackage (3.15.1 in my case)
Dex Errors generally occur when you have too many methods imported in a project, not because of a specific package. I assume upgrading to new version made you import new stuff to your project.
You need to enable ProGuard.
Cause: http://twinkfed.homedns.org/Android///tools/building/multidex.html
Fix: https://www.youtube.com/watch?v=va0FQNlBUX0

How to solve the Dalvik error in adding libs to another project to make a Lite version of my Android app?

In my app, I have to have two version: Full and Lite.
I am following these tutorials:
http://bitowl.wordpress.com/2011/07/06/tutorial-how-to-make-full-and-lite-versions/
http://blog.donnfelker.com/2010/08/05/howto-android-full-and-lite-versions/
So, I build my full version, and make it a library. This full version uses some other libs, needed to some components.
Then, I create a new project and added the lib created. The problem is when I try to run my lite version, eclipse gives this error:
[2012-12-13 13:58:13 - <app> Lite] Dx
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lnet/simonvt/timepicker/R$attr;
Conversion to Dalvik format failed with error 1
The simonvt/timepicker is one of the libs that I use in my full version.
How can I fix this?
Thank you!
Do the following:
Right-click on your project and choose Build Path -> Configure Build Path,
then go to order and export section
If simonvt/timepicker has a checkmark against it, then deselect it.
I believe that the problem is that the library project is already added and you might be trying to add it again.

Categories

Resources