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

Fail on Android debug build / :react-native-community_datetimepicker:packageDebugResources FAILED #810

Open
crisbal opened this issue Sep 9, 2023 · 10 comments

Comments

@crisbal
Copy link

crisbal commented Sep 9, 2023

Bug report

Summary

I am trying to run a debug release of my react-native app. It is a freshly created app with react-native 0.72.4 and gradle 8.

I have never used Gradle so I am not fully sure if the issue is on me and my Gradle setup or something on your side.

I am on Windows, I have installed your library via npm and then followed the manual-installation procedure

I have no idea why it complains about this task dependency and if that is the real problem.

Note (but I guess off-topic): I have had the library build successfully with gradle 7 (by setting distributionUrl in android\gradle\wrapper\gradle-wrapper.properties to gradle 7), but the "production" build would fail.

 ❯❯❯ cat android/settings.gradle
rootProject.name = 'TimeSince'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
include ':@react-native-community_datetimepicker'
project(':@react-native-community_datetimepicker').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/datetimepicker/android')


 ❯❯❯ cat android/app/src/main/java/com/timesince/MainApplication.java | grep "Picker"
import com.reactcommunity.rndatetimepicker.RNDateTimePickerPackage;
          packages.add(new RNDateTimePickerPackage());

 ❯❯❯ cat android/app/build.gradle
[omitted]
dependencies {
    // The version of react-native is set by the React Native Gradle Plugin
    implementation("com.facebook.react:react-android")
    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }
    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }
    implementation project(':@react-native-community_datetimepicker')
}
[omitted]

Output of the build process

> Task :gradle-plugin:compileKotlin UP-TO-DATE
> Task :gradle-plugin:compileJava NO-SOURCE
> Task :gradle-plugin:pluginDescriptors UP-TO-DATE
> Task :gradle-plugin:processResources UP-TO-DATE
> Task :gradle-plugin:classes UP-TO-DATE
> Task :gradle-plugin:jar UP-TO-DATE
> Task :gradle-plugin:inspectClassesForKotlinIC UP-TO-DATE
> Task :@react-native-community_datetimepicker:preBuild UP-TO-DATE
> Task :@react-native-community_datetimepicker:preDebugBuild UP-TO-DATE
> Task :@react-native-community_datetimepicker:compileDebugAidl NO-SOURCE
> Task :@react-native-community_datetimepicker:compileDebugRenderscript NO-SOURCE
> Task :@react-native-community_datetimepicker:generateDebugBuildConfig UP-TO-DATE
> Task :@react-native-community_datetimepicker:generateDebugResValues UP-TO-DATE
> Task :@react-native-community_datetimepicker:generateDebugResources UP-TO-DATE
> Task :@react-native-community_datetimepicker:packageDebugResources UP-TO-DATE
> Task :@react-native-community_datetimepicker:parseDebugLocalResources UP-TO-DATE
> Task :@react-native-community_datetimepicker:processDebugManifest UP-TO-DATE
> Task :@react-native-community_datetimepicker:generateDebugRFile UP-TO-DATE
> Task :@react-native-community_datetimepicker:javaPreCompileDebug UP-TO-DATE

> Task :@react-native-community_datetimepicker:compileDebugJavaWithJavac

> Task :app:buildCodegenCLI SKIPPED
> Task :app:generateCodegenSchemaFromJavaScript SKIPPED
> Task :app:generateCodegenArtifactsFromSchema SKIPPED
> Task :app:generatePackageList
> Task :app:preBuild
> Task :app:preDebugBuild
> Task :react-native-community_datetimepicker:preBuild UP-TO-DATE
> Task :react-native-community_datetimepicker:preDebugBuild UP-TO-DATE
> Task :react-native-community_datetimepicker:compileDebugAidl NO-SOURCE
> Task :react-native-safe-area-context:preBuild UP-TO-DATE
> Task :react-native-safe-area-context:preDebugBuild UP-TO-DATE
> Task :react-native-safe-area-context:compileDebugAidl NO-SOURCE
> Task :react-native-screens:preBuild UP-TO-DATE
> Task :react-native-screens:preDebugBuild UP-TO-DATE
> Task :react-native-screens:compileDebugAidl NO-SOURCE
> Task :app:compileDebugAidl NO-SOURCE
> Task :@react-native-community_datetimepicker:packageDebugRenderscript NO-SOURCE
> Task :react-native-community_datetimepicker:packageDebugRenderscript NO-SOURCE
> Task :react-native-safe-area-context:packageDebugRenderscript NO-SOURCE
> Task :react-native-screens:packageDebugRenderscript NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:javaPreCompileDebug UP-TO-DATE
> Task :@react-native-community_datetimepicker:compileDebugLibraryResources UP-TO-DATE
> Task :@react-native-community_datetimepicker:writeDebugAarMetadata UP-TO-DATE
> Task :react-native-community_datetimepicker:writeDebugAarMetadata UP-TO-DATE
> Task :react-native-safe-area-context:writeDebugAarMetadata UP-TO-DATE
> Task :react-native-screens:writeDebugAarMetadata UP-TO-DATE
> Task :@react-native-community_datetimepicker:bundleLibCompileToJarDebug
> Task :app:checkDebugAarMetadata UP-TO-DATE
> Task :app:generateDebugResValues UP-TO-DATE
> Task :react-native-community_datetimepicker:compileDebugRenderscript NO-SOURCE
> Task :react-native-community_datetimepicker:generateDebugResValues UP-TO-DATE
> Task :react-native-community_datetimepicker:generateDebugResources UP-TO-DATE
> Task :react-native-community_datetimepicker:packageDebugResources FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/8.0.1/userguide/command_line_interface.html#sec:command_line_warnings
26 actionable tasks: 4 executed, 22 up-to-date

info 💡 Tip: Make sure that you have set up your development environment correctly, by running react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor

Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

* What went wrong:
Some problems were found with the configuration of task ':react-native-community_datetimepicker:packageDebugResources' (type 'MergeResources').
  - Gradle detected a problem with the following location: 'C:\Users\bldcr\Desktop\projects\TimeSince\node_modules\@react-native-community\datetimepicker\android\build\generated\res\rs\debug'.

    Reason: Task ':react-native-community_datetimepicker:packageDebugResources' uses this output of task ':@react-native-community_datetimepicker:compileDebugRenderscript' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

    Possible solutions:
      1. Declare task ':@react-native-community_datetimepicker:compileDebugRenderscript' as an input of ':react-native-community_datetimepicker:packageDebugResources'.        
      2. Declare an explicit dependency on ':@react-native-community_datetimepicker:compileDebugRenderscript' from ':react-native-community_datetimepicker:packageDebugResources' using Task#dependsOn.
      3. Declare an explicit dependency on ':@react-native-community_datetimepicker:compileDebugRenderscript' from ':react-native-community_datetimepicker:packageDebugResources' using Task#mustRunAfter.

    Please refer to https://docs.gradle.org/8.0.1/userguide/validation_problems.html#implicit_dependency for more details about this problem.
  - Gradle detected a problem with the following location: 'C:\Users\bldcr\Desktop\projects\TimeSince\node_modules\@react-native-community\datetimepicker\android\build\generated\res\resValues\debug'.

    Reason: Task ':react-native-community_datetimepicker:packageDebugResources' uses this output of task ':@react-native-community_datetimepicker:generateDebugResValues' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

    Possible solutions:
      1. Declare task ':@react-native-community_datetimepicker:generateDebugResValues' as an input of ':react-native-community_datetimepicker:packageDebugResources'.
      2. Declare an explicit dependency on ':@react-native-community_datetimepicker:generateDebugResValues' from ':react-native-community_datetimepicker:packageDebugResources' using Task#dependsOn.
      3. Declare an explicit dependency on ':@react-native-community_datetimepicker:generateDebugResValues' from ':react-native-community_datetimepicker:packageDebugResources' using Task#mustRunAfter.

    Please refer to https://docs.gradle.org/8.0.1/userguide/validation_problems.html#implicit_dependency for more details about this problem.

* 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.

* Get more help at https://help.gradle.org

BUILD FAILED in 8s

Environment info

Please ignore the NoSDK thing. I can compile without react-native-datetimepicker/datetimepicker just fine.

npx react-native info output:

>>> .\node_modules\.bin\react-native info
info Fetching system and libraries information...
System:
  OS: Windows 10 10.0.19045
  CPU: "(12) x64 AMD Ryzen 5 3600 6-Core Processor              "
  Memory: 3.54 GB / 15.93 GB
Binaries:
  Node:
    version: 18.17.1
    path: C:\Program Files\nodejs\node.EXE
  Yarn: Not Found
  npm:
    version: 9.6.7
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: AI-223.8836.35.2231.10671973
  Visual Studio: Not Found
Languages:
  Java: 11.0.20
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.4
    wanted: 0.72.4
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

react-native doctor

> .\node_modules\.bin\react-native doctor
Common
 ✓ Node.js - Required to execute JavaScript code
 ✓ npm - Required to install NPM dependencies

Android
 ✓ Adb - Required to verify if the android device is attached correctly
 ✓ JDK - Required to compile Java code
 ✓ Android Studio - Required for building and installing your app on Android
 ✖ Android SDK - Required for building and installing your app on Android
   - Versions found: N/A
   - Version supported: 33.0.0
 ✓ ANDROID_HOME - Environment variable that points to your Android SDK installation

package.json

"dependencies": {
    "@react-native-community/datetimepicker": "^7.5.0",
    "@react-navigation/native": "^6.1.7",
    "@react-navigation/native-stack": "^6.9.13",
    "@types/uuid": "^9.0.3",
    "react": "18.2.0",
    "react-native": "0.72.4",
    "react-native-safe-area-context": "^4.7.2",
    "react-native-screens": "^3.25.0",
    "uuid": "^9.0.0",
    "zustand": "^4.4.1"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/eslint-config": "^0.72.2",
    "@react-native/metro-config": "^0.72.11",
    "@tsconfig/react-native": "^3.0.0",
    "@types/react": "^18.0.24",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.2.1",
    "eslint": "^8.19.0",
    "jest": "^29.2.1",
    "metro-react-native-babel-preset": "0.76.8",
    "prettier": "^2.4.1",
    "react-test-renderer": "18.2.0",
    "typescript": "4.8.4"
  },
  "engines": {
    "node": ">=16"
  }
@crisbal crisbal changed the title Having trouble making the library build for debug on Android | :react-native-community_datetimepicker:packageDebugResources FAILED Fail on Android debug build / :react-native-community_datetimepicker:packageDebugResources FAILED Sep 9, 2023
@AbdurRobTanvir
Copy link

same issue

@Eliasdbr
Copy link

Eliasdbr commented Sep 25, 2023

Same issue here.
It appears to be a gradle configuration issue from the library side. I found a similar issue for the "react-native-vector-icons" library Here.
It seems there is a way to temporarily solve it by applying a patch.
I would love to help, but sadly I lack on gradle skills
I hope this can help. In the meantime, if someone knows an alternative to let the app build, please, let us know!

Update:
I downgraded the gradle wrapper version from 8.0.1 to 7.5.1 and it builds both for debug and for release.

./android/gradle/wrapper/gradle-wrapper.properties:

- distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip
+ distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip

I know this is not ideal and we still need to do some tests to check if this change implied breaking the build at runtime.

@cosminpwd
Copy link

Same issue. Unfortunately downgrading gradle is not an option.

@coawazie
Copy link

Same issue here. It appears to be a gradle configuration issue from the library side. I found a similar issue for the "react-native-vector-icons" library Here. It seems there is a way to temporarily solve it by applying a patch. I would love to help, but sadly I lack on gradle skills I hope this can help. In the meantime, if someone knows an alternative to let the app build, please, let us know!

Update: I downgraded the gradle wrapper version from 8.0.1 to 7.5.1 and it builds both for debug and for release.

./android/gradle/wrapper/gradle-wrapper.properties:

- distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip
+ distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip

I know this is not ideal and we still need to do some tests to check if this change implied breaking the build at runtime.

I tried this, it worked, but introduced other bugs.

Here is how I resolved it:

  • Shut down any server running
  • Restored the graddle wrapper version to distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip
  • Run ./gradlew clean in /android folder
  • Restarted my system
  • Rebuilt app
    Hope this helps someone

@Charnnarong
Copy link

I downgraded OpenJDK 21 to Azul Zulu 17 solved my problem

https://reactnative.dev/docs/environment-setup

@andrewvincoy-mllrdev
Copy link

andrewvincoy-mllrdev commented Apr 27, 2024

Were you able to resolve the error? @crisbal @AbdurRobTanvir @Eliasdbr @cosminpwd

I'm having the same issue when migrating from Expo sdk 48 to 49.

According to this, it should be fixed by updating to v7.4.1(gradle 8 compatible). I tried but i'm still having the error.

I also installed via npm and followed the manual-installation procedure. But still same error 😢

Did i miss anything?

@Eliasdbr
Copy link

Eliasdbr commented Apr 27, 2024

Were you able to resolve the error? @crisbal @AbdurRobTanvir @Eliasdbr @cosminpwd

I'm having the same issue when migrating from Expo sdk 48 to 49.

According to this, it should be fixed by updating to v7.4.1(gradle 8 compatible). I tried but i'm still having the error.

I also installed via npm and followed the manual-installation procedure. But still same error 😢

Did i miss anything?

Try downgrading the gradle wrapper version to 7.5.1 instead of 7.4.1 when building a debug build.

I do that when I need to make a debug APK, and when I need to make a release .AAB, I upgrade the Gradle wrapper back to 8.0.1

By the way, I'm using React Native v0.72.4.

One more thing: in the issue you shared, apparently, the RN devs fixed this on the 0.74.1 version of RN, but for the looks of the reactions, it didn't fixed the bug

@poojalivin
Copy link

Is there any other solution than downgrading gradle and react-native versions ?

@imanshul
Copy link

imanshul commented Jul 2, 2024

Is this issue resolved? I'm still facing in below version

react-native: 0.73.0
@react-native-community/datetimepicker: 8.1.1

  • What went wrong:
    A problem was found with the configuration of task ':react-native-community_datetimepicker:packageDebugResources' (type 'MergeResources').
    • Gradle detected a problem with the following location: '/Users/anshulthakur/WebstormProjects/cashe-newapp/node_modules/@react-native-community/datetimepicker/android/build/generated/res/resValues/debug'.

      Reason: Task ':react-native-community_datetimepicker:packageDebugResources' uses this output of task ':@react-native-community_datetimepicker:generateDebugResValues' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

      Possible solutions:

      1. Declare task ':@react-native-community_datetimepicker:generateDebugResValues' as an input of ':react-native-community_datetimepicker:packageDebugResources'.
      2. Declare an explicit dependency on ':@react-native-community_datetimepicker:generateDebugResValues' from ':react-native-community_datetimepicker:packageDebugResources' using Task#dependsOn.
      3. Declare an explicit dependency on ':@react-native-community_datetimepicker:generateDebugResValues' from ':react-native-community_datetimepicker:packageDebugResources' using Task#mustRunAfter.

      For more information, please refer to https://docs.gradle.org/8.3/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

@imanshul
Copy link

imanshul commented Jul 2, 2024

Is this issue resolved? I'm still facing in below version

react-native: 0.73.0 @react-native-community/datetimepicker: 8.1.1

  • What went wrong:
    A problem was found with the configuration of task ':react-native-community_datetimepicker:packageDebugResources' (type 'MergeResources').

    • Gradle detected a problem with the following location: '/Users/anshulthakur/WebstormProjects/cashe-newapp/node_modules/@react-native-community/datetimepicker/android/build/generated/res/resValues/debug'.
      Reason: Task ':react-native-community_datetimepicker:packageDebugResources' uses this output of task ':@react-native-community_datetimepicker:generateDebugResValues' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
      Possible solutions:

      1. Declare task ':@react-native-community_datetimepicker:generateDebugResValues' as an input of ':react-native-community_datetimepicker:packageDebugResources'.
      2. Declare an explicit dependency on ':@react-native-community_datetimepicker:generateDebugResValues' from ':react-native-community_datetimepicker:packageDebugResources' using Task#dependsOn.
      3. Declare an explicit dependency on ':@react-native-community_datetimepicker:generateDebugResValues' from ':react-native-community_datetimepicker:packageDebugResources' using Task#mustRunAfter.

      For more information, please refer to https://docs.gradle.org/8.3/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

I've resolved all community related package issues by just removing them from settings.gradle and app/build.gradle while migrating to 0.73.0 and gradle 8.3

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

No branches or pull requests

9 participants