Android Build failed when we are using gradle system 6.1.1 with android gradle plugin 4.0.0.
Task :react-native-background-fetch:bundleDebugAar FAILED
Execution failed for task ':react-native-background-fetch:bundleDebugAar'.
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)
how's it work with higher gradles? With 6.4.1 it seems to be working for me ?
That said, this came up in some other repo (notifee I think) and this seems pertinent https://stackoverflow.com/a/21450829/9910298
but it works for me with gradle plugin 4.0.0, gradle 6.4.1 and background-fetch 3.0.6
I’ve been working on a solution this week.
I experimented with the “import module” method but it’ll be easier to just go back to the maven url mechanism I’d traditionally used.
I have a branch at fetch ready to merge.
Was supposed to be merged yesterday but the power went out for hours due to high winds breaking trees :)
how's it work with higher gradles? With 6.4.1 it seems to be working for me ?
That said, this came up in some other repo (notifee I think) and this seems pertinent https://stackoverflow.com/a/21450829/9910298
but it works for me with gradle plugin 4.0.0, gradle 6.4.1 and background-fetch 3.0.6
./gradlew assembleDebug is failing for me with the above error.
Of course it fails. Gradle tools 4.0.0 doesn’t allow local aar dependencies.
Either don’t use gradle tools 4.0.0 or wait until the next release.
Of course it fails. Gradle tools 4.0.0 doesn’t allow local aar dependencies.
Either don’t use gradle tools 4.0.0 or wait until the next release.
Thanks @christocracy
3.1.0 is released.
- The Android Setup now requires a custom
maven urlto be added to your app's rootandroid/build.gradle:
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
+ maven {
+ // react-native-background-fetch
+ url("${project(':react-native-background-fetch').projectDir}/libs")
+ }
}
}
@mikehardy background-geolocation will now receive the same treatment.
Thanks for the quick response.
@christocracy I still haven't figured out exactly how it's working, but I'm definitely using gradle plugin 4 (the versions all listed above) and definitely working. I know this is a problem, I've worked with users in other repos on it, but my project works. If I could figure that out it'd be great as it won't require users to modify their build.gradle for each project that contains an .aar but I haven't located what's happening yet
@mikehardy your app is opened in Android Studio? Clean your build? Can you show me all your relevant files?
Thanks @christocracy . Upgrading to 3.1.0 fixed this for us as well.
I had kind of a related-but-opposite problem to that mentioned in this issue, just thought I would write it up as it took me a hot second to figure out and I want to make it easier to google.
We were using gradle 3.5.2 and wanted to upgrade react-native-background-geolocation-android from 3.6.2 to 3.9.0.
After following the instructions to upgrade to react-native-background-geolocation-android: 3.9.0 I couldn't build on Android, I kept getting this error at compile time:
D8: Program type already present: com.transistorsoft.tsbackgroundfetch.BGTask$Error
By chance I noticed something about gradle 4.0.0 in the changelogs and tried upgrading – now it works great.
I'd be happy to submit a pull request updating the documentation about this but not quite sure whether it should be in here or in react-native-background-geolocation (...-android) repo. @christocracy let me know if you think it is worth it.