react-native-background-fetch icon indicating copy to clipboard operation
react-native-background-fetch copied to clipboard

Android Build failed when we are using gradle system 6.1.1 with android gradle plugin 4.0.0.

Open mathankumarinspirisys opened this issue 6 years ago • 13 comments

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)

mathankumarinspirisys avatar Jun 12 '20 08:06 mathankumarinspirisys

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

mikehardy avatar Jun 12 '20 09:06 mikehardy

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.

christocracy avatar Jun 12 '20 10:06 christocracy

Was supposed to be merged yesterday but the power went out for hours due to high winds breaking trees :)

christocracy avatar Jun 12 '20 10:06 christocracy

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.

mathankumarinspirisys avatar Jun 12 '20 12:06 mathankumarinspirisys

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.

christocracy avatar Jun 12 '20 13:06 christocracy

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

mathankumarinspirisys avatar Jun 12 '20 13:06 mathankumarinspirisys

3.1.0 is released.

  • The Android Setup now requires a custom maven url to be added to your app's root android/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")
+       }
    }
}

christocracy avatar Jun 12 '20 13:06 christocracy

@mikehardy background-geolocation will now receive the same treatment.

christocracy avatar Jun 12 '20 14:06 christocracy

Thanks for the quick response.

mathankumarinspirisys avatar Jun 12 '20 14:06 mathankumarinspirisys

@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 avatar Jun 12 '20 17:06 mikehardy

@mikehardy your app is opened in Android Studio? Clean your build? Can you show me all your relevant files?

christocracy avatar Jun 12 '20 17:06 christocracy

Thanks @christocracy . Upgrading to 3.1.0 fixed this for us as well.

scarlac avatar Jun 15 '20 19:06 scarlac

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.

omnikron avatar Sep 02 '20 15:09 omnikron