Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.

[SOLVED] Release Build Failure, "Task :notifee_react-native:bundleReleaseAar FAILED" #151

Closed
joebarrero opened this issue Sep 22, 2020 · 11 comments · Fixed by #370
Closed

Comments

@joebarrero
Copy link

joebarrero commented Sep 22, 2020

[EDIT TO ADD SOLUTION: Use ./gradlew :app:assembleRelease not ./gradlew assembleRelease]


I'm using React Native version 0.63.2 with Notifee 0.12.3

When using classpath('com.android.tools.build:gradle:4.0.1') in the build.gradle file, ./gradlew assembleRelease fails with the following error and message:

> Task :notifee_react-native:bundleReleaseAar FAILED
w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':notifee_react-native:bundleReleaseAar'.
> Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :notifee_react-native project caused this error: 

Changng the to build.grade file to, classpath('com.android.tools.build:gradle:3.6.4'), seemed to fix the issue.

I'm not sure if this is a bug, my lack of experience, or a combination of both but I thought it might be important enough to post my experience here.

The error seems to imply that creating a release bundle with the earlier version Grade Tools can lead to a broken bundle. Is there something that I should do to assemble the release build the latest version of the Gradle Tools?

@mikehardy
Copy link
Collaborator

I am using the latest notifee release, gradle 4.0.1, as well as multiple other modules that use kotlin (react-native-apple-authentication, react-native-webview) without issue, so this is unexpected

If you could post a reproduction on github based off a clean project from react-native init that could help

You may want to define kotlinVersion = 1.4.10 in your android/build.gradle ext block https://github.com/facebook/react-native/blob/83777cb4fb5dda89c430b7eff9cd1f28d2577831/template/android/build.gradle#L4-L10 - I have that and can vouch it works at least

@joebarrero
Copy link
Author

@mikehardy

Thank you for your response. I tried again using Gradle 4.0.1 and updating Kotlin to 1.4.10. I received the same error. I created a clean and barebones instance of the project that can be reviewed at https://github.com/joebarrero/notifee-test and this version also produced the same error.

I added all of the relevant information regarding my build in the Readme.md file. I appreciate your help.

@mikehardy
Copy link
Collaborator

How unfortunate! I'll give it a shot and see what I can see. Sorry you've run in to this trouble

@mikehardy
Copy link
Collaborator

🤔

Does not reproduce:

mike@isabela:~/work/Invertase/customers/notifee-test (master *) % npm run android

> notifeetest@0.0.1 android /home/mike/work/Invertase/customers/notifee-test
> react-native run-android

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 974 file(s) to forward-jetify. Using 12 workers...
info JS server already running.
info Installing the app...
Starting a Gradle Daemon (subsequent builds will be faster)

> Configure project :notifee_react-native
:notifee_react-native package.json found at /home/mike/work/Invertase/customers/notifee-test/node_modules/@notifee/react-native/package.json
:notifee_react-native:version set from package.json: 0.12.3 (0,12,3 - 12003)
:notifee_react-native:android.compileSdk using custom value: 29
:notifee_react-native:android.targetSdk using custom value: 29
:notifee_react-native:android.minSdk using custom value: 16
:notifee_react-native:reactNativeAndroidDir /home/mike/work/Invertase/customers/notifee-test/node_modules/react-native/android

> Task :app:compileDebugJavaWithJavac

> Task :app:installDebug
Installing APK 'app-debug.apk' on 'TestingAVD_API-29_TAG-PLAY(AVD) - 10' for app:debug
Installed on 1 device.

BUILD SUCCESSFUL in 26s
41 actionable tasks: 41 executed
info Connecting to the development server...
8081
info Starting the app on "emulator-5554"...
Starting: Intent { cmp=com.notifeetest/.MainActivity }
mike@isabela:~/work/Invertase/customers/notifee-test (master *) % git remote -v
origin  https://github.com/joebarrero/notifee-test.git (fetch)
origin  https://github.com/joebarrero/notifee-test.git (push)

How are you launching it? Via Android Studio or the command line?

@joebarrero
Copy link
Author

@mikehardy

It runs just fine. It's when I try to create the APK that it fails.

cd android
./gradlew assembleRelease

@mikehardy
Copy link
Collaborator

mikehardy commented Sep 22, 2020

My apologies - you noted that in the first line (or so) of your report. I was moving too quickly while attempting to diagnose. I have reproduced the problem! Which is bad (there's a problem...) but also great because now I see it.

@mikehardy
Copy link
Collaborator

mikehardy commented Sep 22, 2020

I knew this reminded me of something!

Use ./gradlew :app:assembleRelease

#68 (comment)

Can you confirm this works @joebarrero ? (it worked for me when I did that command in your repro repo)

@joebarrero
Copy link
Author

That worked! Thank you.

@mikehardy
Copy link
Collaborator

I am still baffled why :app:<target> is needed vs <target> but we have no other reported problems from folks using this. It feels like it should be called out in a document somewhere, I'll open a separate issue for that

Glad you're moving forward!

@mikehardy mikehardy changed the title Release Build Failure, "Task :notifee_react-native:bundleReleaseAar FAILED" [SOLVED] Release Build Failure, "Task :notifee_react-native:bundleReleaseAar FAILED" Jan 12, 2021
@mikehardy mikehardy pinned this issue Jan 12, 2021
mikehardy added a commit that referenced this issue Aug 26, 2021
Fixes #151
Fixes notifee/documentation#8

BREAKING CHANGE: add "maven { url "$rootDir/../node_modules/@notifee/react-native/android/libs" }" to "repositories" in "android/build.gradle"
mikehardy added a commit to invertase/notifee that referenced this issue Aug 26, 2021
depending on it as a direct file is anti-gradle, this is the right way to do it

Fixes Fixes invertase/react-native-notifee#151
Fixes notifee/documentation#8

BREAKING CHANGE: this requires users to add a new maven repository definition to their build.gradle
mikehardy added a commit that referenced this issue Aug 27, 2021
Fixes #151
Fixes notifee/documentation#8

BREAKING CHANGE: add "maven { url "$rootDir/../node_modules/@notifee/react-native/android/libs" }" to "repositories" in "android/build.gradle"
mikehardy added a commit to invertase/notifee that referenced this issue Aug 27, 2021
depending on it as a direct file is anti-gradle, this is the right way to do it

Fixes Fixes invertase/react-native-notifee#151
Fixes notifee/documentation#8

BREAKING CHANGE: this requires users to add a new maven repository definition to their build.gradle
mikehardy added a commit that referenced this issue Aug 27, 2021
Fixes #151
Fixes notifee/documentation#8

BREAKING CHANGE: add "maven { url "$rootDir/../node_modules/@notifee/react-native/android/libs" }" to "repositories" in "android/build.gradle"
mikehardy added a commit to invertase/notifee that referenced this issue Aug 27, 2021
depending on it as a direct file is anti-gradle, this is the right way to do it

Fixes Fixes invertase/react-native-notifee#151
Fixes notifee/documentation#8

BREAKING CHANGE: this requires users to add a new maven repository definition to their build.gradle
mikehardy added a commit that referenced this issue Aug 27, 2021
Fixes #151
Fixes notifee/documentation#8

BREAKING CHANGE: add "maven { url "$rootDir/../node_modules/@notifee/react-native/android/libs" }" to "repositories" in "android/build.gradle"
mikehardy added a commit that referenced this issue Aug 27, 2021
Fixes #151
Fixes notifee/documentation#8

BREAKING CHANGE: add "maven { url "$rootDir/../node_modules/@notifee/react-native/android/libs" }" to "repositories" in "android/build.gradle"
helenaford added a commit that referenced this issue Sep 12, 2021
)

* fix(deps, android)!: switch to local maven repo for aar dependency

Fixes #151
Fixes notifee/documentation#8

BREAKING CHANGE: add "maven { url "$rootDir/../node_modules/@notifee/react-native/android/libs" }" to "repositories" in "android/build.gradle"

* docs(example): add new local maven repo for notifee to example config

Co-authored-by: Helena Ford <helenaellieford@gmail.com>
helenaford added a commit to invertase/notifee that referenced this issue Sep 12, 2021
…107)

* docs(README): explain how to test local react-native changes in e2e

* build(deps): update gradle to 7.2 + wrapper re-generation

* build(deps): update native android dependencies

* fix(deps, android)!: generate aar into react-native local maven repo

depending on it as a direct file is anti-gradle, this is the right way to do it

Fixes Fixes invertase/react-native-notifee#151
Fixes notifee/documentation#8

BREAKING CHANGE: this requires users to add a new maven repository definition to their build.gradle

Co-authored-by: Helena Ford <helenaellieford@gmail.com>
@helenaford
Copy link
Member

Fixed in release v2.0.0 (https://notifee.app/react-native/docs/release-notes#200)

@mikehardy
Copy link
Collaborator

Should be noted this became mandatory with the move to android targetSdkVersion 30, not sure why? But this should keep everyone moving along as they move those targets up

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

Successfully merging a pull request may close this issue.

3 participants