Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot change resolution strategy of dependency configuration ':unityLibrary:aarArtifacts' after it has been resolved. #3042

Closed
kushG opened this issue Nov 29, 2023 · 29 comments
Assignees
Labels
P2 Issue. Plugin Issue with the Unity plugin.

Comments

@kushG
Copy link

kushG commented Nov 29, 2023

[REQUIRED] Step 1: Describe your environment

  • Unity version: 2020.3.37f1
  • Google Mobile Ads Unity plugin version: 8.6.0
  • Platform: Android
  • Platform OS version: Android 13
  • Any specific devices issue occurs on: N/A
  • Mediation ad networks used, and their versions: _____

[REQUIRED] Step 2: Describe the problem

Steps to reproduce:

When targeting API 34 in Unity, I'm seeing the the following error while making a build. I have enabled both the options as mentioned here #2930 (comment)


FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':unityLibrary'.
> Cannot change resolution strategy of dependency configuration ':unityLibrary:aarArtifacts' after it has been resolved.
@Heathclliff
Copy link

I was getting a similar problem. There are 2 solutions:

  1. many rebuilds of native Android libraries inside the Admob plugin;
  2. upgrade Unity to version 2022.3.

@thiagolr
Copy link

I also have the same problem, any idea how to solve it?

@SuperUnityCoder
Copy link

You can easily fix this issue by adding these lines to your mainTemplate.gradle:

gradle.projectsEvaluated {
    apply from: 'GoogleMobileAdsPlugin.androidlib/validate_dependencies.gradle'
}

@NVentimiglia
Copy link
Member

This should be included in GoogleMobileAds v 8.6.0.

You may also try clearing your gradle cache.

@lhchi
Copy link

lhchi commented Dec 5, 2023

This should be included in GoogleMobileAds v 8.6.0.

You may also try clearing your gradle cache.

Got the same issue when implemented Google Admob version 8.6.0 and com.google.android.gms:play-services-ads:22.5.0 on Unity 2021.3.18. Any way to fix it

@davutint
Copy link

You can easily fix this issue by adding these lines to your mainTemplate.gradle:

gradle.projectsEvaluated {
    apply from: 'GoogleMobileAdsPlugin.androidlib/validate_dependencies.gradle'
}

this is work for me, thanks a lot <3

@tonismogames
Copy link

You can easily fix this issue by adding these lines to your mainTemplate.gradle:

gradle.projectsEvaluated {
    apply from: 'GoogleMobileAdsPlugin.androidlib/validate_dependencies.gradle'
}

Thank You o great wizard this fixed the problem

@Suraj-SPG
Copy link

Suraj-SPG commented Dec 14, 2023

This should be included in GoogleMobileAds v 8.6.0.
You may also try clearing your gradle cache.

Got the same issue when implemented Google Admob version 8.6.0 and com.google.android.gms:play-services-ads:22.5.0 on Unity 2021.3.18. Any way to fix it

I'm also facing same issue. Any update ? Not using custom mainTempate.gradle

Google Mobile Ads Unity plugin version: 8.6.0

@Watcher3056
Copy link

Watcher3056 commented Dec 15, 2023

+1 get this issue. This fix does not help me.
Sometimes it lets me to make one build and then stops me from building again with that error.

You can easily fix this issue by adding these lines to your mainTemplate.gradle:

gradle.projectsEvaluated {
    apply from: 'GoogleMobileAdsPlugin.androidlib/validate_dependencies.gradle'
}

Unity 2021.3.29f1

UPD: It lets me build once when I change gradle to external or back to internal

@LeonardoDemartino
Copy link

I'm having this issue as well.
Unity 2021.3.27f1
Google Mobile Ads Unity 8.6.0

@vincent-savysoda
Copy link

You can easily fix this issue by adding these lines to your mainTemplate.gradle:

gradle.projectsEvaluated {
    apply from: 'GoogleMobileAdsPlugin.androidlib/validate_dependencies.gradle'
}

I can't update the mainTemplate.gradle as its currently disabled for me as i use a custom gradleTemplate. Is there something i need to do to replicate the same thing in this scenario?

@NVentimiglia NVentimiglia self-assigned this Dec 20, 2023
@NVentimiglia NVentimiglia added P2 Issue. Plugin Issue with the Unity plugin. labels Dec 20, 2023
@NVentimiglia
Copy link
Member

Hi,

We are looking into this issue.

@gheatgheat
Copy link

You can easily fix this issue by adding these lines to your mainTemplate.gradle:

gradle.projectsEvaluated {
    apply from: 'GoogleMobileAdsPlugin.androidlib/validate_dependencies.gradle'
}

OMG thanks you so much. It works for me.

@shefich
Copy link

shefich commented Jan 4, 2024

After this workaround I still have this errors in console:
`stderr[
Note: E:\xxx\xxx\Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

  • What went wrong:
    Execution failed for task ':launcher:processReleaseResources'.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
AAPT2 aapt2-4.0.1-6197926-windows Daemon #1: Unexpected error during link, attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    ==============================================================================

2: Task failed with an exception.

  • What went wrong:
    Execution failed for task ':launcher:bundleReleaseResources'.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
AAPT2 aapt2-4.0.1-6197926-windows Daemon #0: Unexpected error during link, attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.`

Can you help me to fix them?
Unity 2021.
Unity 2022 fix the issues, but it's not an option.

@NVentimiglia
Copy link
Member

Hi everyone,

Confirming this is an issue and we are looking into a fix.

@ga0357r
Copy link

ga0357r commented Jan 17, 2024

I managed to solve the issue by upgrading unity to 2022.3. See Google documentation

@Ckuruuzum
Copy link

You can easily fix this issue by adding these lines to your mainTemplate.gradle:

gradle.projectsEvaluated {
    apply from: 'GoogleMobileAdsPlugin.androidlib/validate_dependencies.gradle'
}

He is a magician

@dungpt14083
Copy link

You can easily fix this issue by adding these lines to your mainTemplate.gradle:

gradle.projectsEvaluated {
    apply from: 'GoogleMobileAdsPlugin.androidlib/validate_dependencies.gradle'
}

Thank you so much, it took me 3 days to fix it

@shefich
Copy link

shefich commented Jan 24, 2024

@NVentimiglia it isn't fixed. I have the same issue with the proposed workaround:
`FAILURE: Build failed with an exception.

  • Where:
    Script 'E:\UnityProjects\project\Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary\GoogleMobileAdsPlugin.androidlib\validate_dependencies.gradle' line: 23

  • What went wrong:
    A problem occurred evaluating script.

Cannot change dependencies of dependency configuration ':unityLibrary:aarArtifacts' after it has been resolved.`

Unity 2021.3.34
Target API Level 34 - gives error upon build.
Target API Level 33 - builds w/o errors.

@Abulero
Copy link

Abulero commented Jan 27, 2024

You can easily fix this issue by adding these lines to your mainTemplate.gradle:

gradle.projectsEvaluated {
    apply from: 'GoogleMobileAdsPlugin.androidlib/validate_dependencies.gradle'
}

Where?? I'm anxious seeing so many people get their issue solved by adding this, but I have no idea where to put this in my mainTemplate.gradle file. Below everything? In an android backet? In the dependencies section? Where?? 😢

I tried in many places but the problem persists. Maybe I'm putting it in the wrong spot.

@SuperUnityCoder
Copy link

SuperUnityCoder commented Jan 28, 2024

I have it here:

// Android Resolver Exclusions Start
android {
  packagingOptions {
      ...
  }
}

// GMA
gradle.projectsEvaluated {
    apply from: 'GoogleMobileAdsPlugin.androidlib/validate_dependencies.gradle'
}

// Android Resolver Exclusions End
android {
    compileSdkVersion **APIVERSION**
    buildToolsVersion '**BUILDTOOLS**'
    ...
}**REPOSITORIES**
**IL_CPP_BUILD_SETUP**
**SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**

@vincent-savysoda
Copy link

vincent-savysoda commented Jan 29, 2024

I'm still having this issue in the latest update :/

Unity 2021.3.33f1

@evolutionsofgame
Copy link

gradle.projectsEvaluated {
apply from: 'GoogleMobileAdsPlugin.androidlib/validate_dependencies.gradle'
}

it work in google mobile ads 8.6, but in version 8.7, it can not fix. how to fix?

@raft75
Copy link

raft75 commented Jan 30, 2024

Unity 2020.3.48f1

Same here, the following workaround was working in 8.60 but does not work in 8.70

gradle.projectsEvaluated {
apply from: 'GoogleMobileAdsPlugin.androidlib/validate_dependencies.gradle'
}

@AlirezaTabasi7
Copy link

AlirezaTabasi7 commented Jan 31, 2024

I had same problem as you guys and fixed it by steps below:

Unity version is 2021.3.26f1
GoogleMobileAds 8.7
Chartboost mediation 9.6.0.
Min Api android 22 (5.1)
Target API 34

Follow google document linked below like this:
https://developers.google.com/admob/unity/gradle

1- download gradle version 6.7.1 binary file here:
https://gradle.org/next-steps/?version=6.7.1&format=bin

2- Extract it anywhere and make unity use this one instead of default gradle installed with the editor.

3- In android player settings check custom "base" gradle template and not "main" gradle temple nor custom gradle properties.

4- Open the Assets/Plugins/Android/baseProjectTemplate.gradle file and set the dependencies to use Gradle build tools 4.2.0.
buildscript { dependencies { classpath 'com.android.tools.build:gradle:4.2.0' **BUILD_SCRIPT_DEPS** } }

5- Force resolve your project using External dependency manager 1.2.177 and it should resolve successfully.

6- Make sure to check Use R8 in minify code section if needed and to not check release which causes other errors.

7- lastly from build menu press clean build which is under build button itself.

Hope this helps.

@raft75
Copy link

raft75 commented Jan 31, 2024

Thank you @AlirezaTabasi7, it works.
Unity 2020.3.48f1
Plugin 8.7.0
Api level min 21
Target 33
It didn't work until I unchecked custom main gradle temple and custom gradle properties
I don't use R8 minify, if I do the app shows only a black screen on my tablet (android 6.0)

https://developers.google.com/admob/unity/gradle

@kevinhtt
Copy link

kevinhtt commented Mar 9, 2024

I was getting this error after updating from a very old version of Unity Google Mobile Ads to 8.7.0.

I fixed it by deleting the Assets\GoogleMobileAds\ folder and deleting all the googlemobileads files and folders (upper and lower case) in \Assets\Plugins\Android.

I then reinstalled the 8.7.0 package, force resolved all Android dependencies, and Android builds succeeded again.

Perhaps some old Google Ads settings or files from prior versions were still in the project and were breaking the build, but this fixed it for me.

@raulseixasbr
Copy link

You can easily fix this issue by adding these lines to your mainTemplate.gradle:

gradle.projectsEvaluated {
    apply from: 'GoogleMobileAdsPlugin.androidlib/validate_dependencies.gradle'
}

Worked like a charm, but only after downgrading to 8.6.0. Couldn`t make 8.7.0 work...

@2345678910JQKA
Copy link

#3042 (comment)
I updated the android sdk to 34 and solved the problem with this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Issue. Plugin Issue with the Unity plugin.
Projects
None yet
Development

No branches or pull requests