oblador / react-native-keychain

:key: Keychain Access for React Native
MIT License
3.21k stars 520 forks source link

Compilation error building Android - project :react-native-keychain > com.adarshr:gradle-test-logger-plugin:2.0.0 #595

Open janet-rivas opened 1 year ago

janet-rivas commented 1 year ago

info details

I'm using the lates version of react-native-keychain - V.8.1.1 also using React-native V.0.71.5 and java JDK 11 as per react native documentation

Please also find the environment info System: OS: macOS 12.6.5 CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 41.94 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.16.0 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 9.6.4 - /usr/local/bin/npm Watchman: 2023.05.08.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.12.0 - /Users/JXR0ACO/.rvm/rubies/ruby-2.7.4/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1 Android SDK: API Levels: 21, 23, 27, 28, 29, 30, 31, 32, 33 Build Tools: 28.0.3, 29.0.0, 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 33.0.0, 33.0.1, 33.0.2 System Images: android-23 | Google APIs ARM EABI v7a, android-23 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom_64, android-26 | Intel x86 Atom_64, android-26 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom_64, android-27 | Intel x86 Atom_64, android-27 | Google APIs Intel x86 Atom, android-28 | Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom_64, android-28 | Google X86_ARM Intel x86 Atom, android-29 | Google APIs Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom_64, android-31 | Google APIs Intel x86 Atom_64, android-32 | Google APIs Intel x86 Atom_64, android-33-ext4 | Google Play Intel x86 Atom_64, android-33 | Google APIs ARM 64 v8a, android-33 | Google APIs Intel x86 Atom_64 Android NDK: Not Found IDEs: Android Studio: 2022.2 AI-222.4459.24.2221.9971841 Xcode: 14.2/14C18 - /usr/bin/xcodebuild Languages: Java: 11.0.19 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.2.0 => 18.2.0 react-native: 0.71.5 => 0.71.5 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

This is the Error message

A problem occurred configuring project ':react-native-keychain'.

Could not determine the dependencies of null. Could not resolve all task dependencies for configuration ':react-native-keychain:classpath'. Could not resolve org.fusesource.jansi:jansi:1.18. Required by: project :react-native-keychain > com.adarshr:gradle-test-logger-plugin:2.0.0 Could not resolve org.fusesource.jansi:jansi:1.18. Could not get resource 'https://plugins.gradle.org/m2/org/fusesource/jansi/jansi/1.18/jansi-1.18.pom'. Could not GET 'https://jcenter.bintray.com/org/fusesource/jansi/jansi/1.18/jansi-1.18.pom'. PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Steps to replicate

Create a new react native application npx react-native@latest init AwesomeProject and install react-native-keychain package

Notes

this is a similar issue with this - https://github.com/facebook/react-native/issues/17197 but that fix does not work this package works with react-native old version and java JDK 1.8 but after create a new project with the latest react native version it does not longer work

This is the package is not able to download https://github.com/radarsh/gradle-test-logger-plugin because it's unable to find valid certification path to requested target

guillermeservilla commented 1 year ago

same issue here

janet-rivas commented 1 year ago

This works for me

  1. Edit node_modules/react-native-keychain/android/build.gradle
buildscript {  
    def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['RNSAC_kotlinVersion'] 
      repositories {  
        mavenCentral()  
        maven {  
          url "https://plugins.gradle.org/m2/"  
        }  
    }    
    dependencies {  
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")  
    }

def getExtOrDefault(name, defaultValue) {  
    return rootProject.ext.has(name) ? rootProject.ext.get(name) : defaultValue  
}

def kotlin_version = getExtOrDefault('kotlinVersion', project.properties['RNSAC_kotlinVersion'])

dependencies {      
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"  
}
  1. make sure you have a kotlin_version in the app android/build.gradle
buildscript {  
    ext {  
        kotlin_version = '1.7.0'  //example 
    }
  1. you could react a patch file using patch-package
guillermeservilla commented 1 year ago

Hi @janet-rivas, thanks for the tips, but it didn't work for me, and, after some research and studying (I'm kinda noob about dependencies and gradle lol), I've found this:

image

and updating my node_modules/react-native-keychain/android/build.gradle buildscript dependencies from classpath 'com.adarshr:gradle-test-logger-plugin:2.0.0' to classpath 'com.adarshr:gradle-test-logger-plugin:2.1.0' solved the issue

avioli commented 1 year ago

Neither (nor both) worked for me. Anyone else had any success?

Even tried upgrading gradle-test-logger-plugin to 3.2.0 (based on this draft PR) with no success

avioli commented 1 year ago

Ok... my problem was sorted (and maybe unrelated to this issue) when I upgraded my BuildTool to "34.0.0" and had none of the above patches.