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

Execution failed for task ':app:checkDebugAarMetadata'. #1318

Closed
sumanbhattarai opened this issue Nov 15, 2021 · 20 comments · Fixed by OneSignal/OneSignal-Gradle-Plugin#182
Closed

Comments

@sumanbhattarai
Copy link

sumanbhattarai commented Nov 15, 2021

Description:

I created a new react native application and installed react-native-one-signal. I am getting a build error on android as soon as I installed react-native-one-signal.
I am getting following error while building an app on android:

Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
   > The minCompileSdk (31) specified in a
     dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
     is greater than this module's compileSdkVersion (android-30).
     Dependency: androidx.work:work-runtime:2.7.0.
     AAR metadata file: /Users/sumanbhattarai/.gradle/caches/transforms-3/ac32b6abd74d5ceefc471e061744b632/transformed/work-runtime-2.7.0/META-INF/com/android/build/gradle/aar-metadata.properties.

Environment

"react": "17.0.2",
"react-native": "0.66.2",
"react-native-onesignal": "^4.3.2"

Steps to Reproduce Issue:

  1. Create a new project using npx react-native init DempApp --template react-native-template-typescript .
  2. Install one signal using yarn add react-native-onesignal
  3. Run on android phone. npx react-native run-android
@ROG3R-DEV
Copy link

@sumanbhattarai on android/build.gradle

change:

compileSdkVersion = 31

buildscript {
    ext {
        compileSdkVersion = 31
       ....

@sweatherall
Copy link

I can confirm @ROG3R-DEV solution works - I was running into the exact same problem, and updating compileSdkVersion to 31, as the error message suggests, allows for a successful build.

@Ricool06
Copy link

I'm also getting this issue, 4.3.1 builds fine (but ID verification is not working). 4.3.2 is where this issue is introduced.
I can't change build.gradle as @ROG3R-DEV has suggested as I am using expo with a managed workflow.

Does anyone have an alternative workaround so I can use ID verification?

@Summys
Copy link

Summys commented Nov 19, 2021

If you don't want to upgrade to sdk 31, add in android/app/build.gradle

android {
    ...
    defaultConfig {
        ...
        configurations.all {
            resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
        }
    }
}

@nan-li
Copy link
Contributor

nan-li commented Nov 19, 2021

For some background, we made this change for apps that set their compileSdkVersion to 31.

@Ricool06, thanks for bringing up a good point about the managed workflow as it appears the latest Expo SDK targets Android 30.

@Ricool06
Copy link

If you don't want to upgrade to sdk 31, add in android/app/build.gradle

android {
    ...
    defaultConfig {
        ...
        configurations.all {
            resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
        }
    }
}

I can't upgrade to sdk 31 without ejecting, which I also cannot do in my situation.

@nan-li glad to be helping. 😊 Is there a resolution or workaround to this we can think of?

@Saad-Bashar
Copy link

Saad-Bashar commented Nov 23, 2021

Having the same problem with onesignal 4.3.3 :( I am using expo unimodules and when I upgraded to 31 the expo packages can not run.

Update: By using this, I could run the app. However not sure if its a good idea.

android {
    ...
    defaultConfig {
        ...
        configurations.all {
            resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
        }
    }
}

@Svarto
Copy link

Svarto commented Nov 23, 2021

same issue, glad it is identified why it happens. I downgraded for now, but hope it will be addressed when expo SDK 44 comes out...

@jkasten2
Copy link
Member

This issue has been addressed in OneSignal-Gradle-Plugin 0.14.0. This version should automatically be picked up if you do a clean build.

@Saad-Bashar
Copy link

@jkasten2 , I am doing ./gradlw clean and trying back again. Still getting the same error somehow? Am I doing it right?

@Ricool06
Copy link

Ricool06 commented Nov 24, 2021

So for anyone still struggling with this who can't eject or update to the version @jkasten2 mentioned, here is a workaround.
Add this to your app.config.js:

const newResolutionStrategyGradle = `
configurations.all {
    resolutionStrategy {
        force 'androidx.work:work-runtime:2.6.0'
    }
}`;

const withWorkingWorkRuntimeVersion = (config, _props) => {
  return withAppBuildGradle(config, newConfig => {
    newConfig.modResults.contents = `${newResolutionStrategyGradle.trimStart()}\n\n${
      newConfig.modResults.contents
    }`;

    return newConfig;
  });
};

then return your config where you usually would with

return withWorkingWorkRuntimeVersion(config);

EDIT: this assumes you are using expo!

@jkasten2
Copy link
Member

The available version list of the onesignal-gradle-plugin (OneSignal-Gradle-Plugin) hasn't been updated with 0.14.0 yet:

I am not sure exactly when Gradle's plugin portal will refresh the latest version list but I would expect in the next 24 hours.

@huurray
Copy link

huurray commented Dec 17, 2021

If you don't want to upgrade to sdk 31, add in android/app/build.gradle

android {
    ...
    defaultConfig {
        ...
        configurations.all {
            resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
        }
    }
}

this works for me!!

@scooterthedev
Copy link

If you don't want to upgrade to sdk 31, add in android/app/build.gradle

android {
    ...
    defaultConfig {
        ...
        configurations.all {
            resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
        }
    }
}

Thank you so much @Summys! This is just what I needed to fix my problem.

@phamhieu1412
Copy link

If you don't want to upgrade to sdk 31, add in android/app/build.gradle

android {
    ...
    defaultConfig {
        ...
        configurations.all {
            resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
        }
    }
}

worked for me

buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "21.4.7075529"

rn: 0.66.4

@Luxiyaya
Copy link

Luxiyaya commented Sep 26, 2022

@Summys Thank you You solved my problem

android {
    ...
    defaultConfig {
        ...
        configurations.all {
            resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
        }
    }
}

@Dcrosssensei
Copy link

worked for me +

buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30

If you don't want to upgrade to sdk 31, add in android/app/build.gradle

android {
    ...
    defaultConfig {
        ...
        configurations.all {
            resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
        }
    }
}

@itshash01
Copy link

I just had the same issue, so its better to go to build.gradle and check targetSDK and compileSDK then we will notice a kind of warning asking us to update...we are 13th DECEMBER 2022 I update mine to 33 which were from the beginning 32.

@itshash01
Copy link

worked for me +

buildToolsVersion = "29.0.3" minSdkVersion = 21 compileSdkVersion = 30 targetSdkVersion = 30

If you don't want to upgrade to sdk 31, add in android/app/build.gradle

android {
    ...
    defaultConfig {
        ...
        configurations.all {
            resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
        }
    }
}

yeah targetSDK and compileSDK must be upgraded(id did it to 33)

@OFD16
Copy link

OFD16 commented Jun 24, 2023

on this route: android -> build.gradle
add this part androidXBrowser = "1.5.0"

buildscript {
    ext {
        // ...
        androidXBrowser = "1.5.0"

resource1
resource2

this solved my problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet