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

Can not run app, getting errors related to the React Native Community Clipboard #234

Open
NguyenTran153 opened this issue May 6, 2024 · 1 comment

Comments

@NguyenTran153
Copy link

NguyenTran153 commented May 6, 2024

I'm getting errors related to the React Native Community Clipboard package after running yarn android

D:\Project\DATN\android\app\src\debug\AndroidManifest.xml Warning:
uses-feature#android.hardware.usb.host was tagged at AndroidManifest.xml:0 to replace another declaration but no other declaration present

Task :react-native-community_clipboard:compileDebugJavaWithJavac 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
292 actionable tasks: 6 executed, 286 up-to-date

info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx 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

D:\Project\DATN\node_modules@react-native-community\clipboard\android\src\main\java\com\reactnativecommunity\clipboard\ClipboardModule.java:14: error: cannot find symbol
import com.facebook.react.bridge.ContextBaseJavaModule;
^
symbol: class ContextBaseJavaModule
location: package com.facebook.react.bridge
D:\Project\DATN\node_modules@react-native-community\clipboard\android\src\main\java\com\reactnativecommunity\clipboard\ClipboardModule.java:23: error: cannot find symbol
public class ClipboardModule extends ContextBaseJavaModule {
^
symbol: class ContextBaseJavaModule
D:\Project\DATN\node_modules@react-native-community\clipboard\android\src\main\java\com\reactnativecommunity\clipboard\ClipboardModule.java:31: error: method does not override or implement a method from a supertype
@OverRide
^
D:\Project\DATN\node_modules@react-native-community\clipboard\android\src\main\java\com\reactnativecommunity\clipboard\ClipboardModule.java:37: error: cannot find symbol
return (ClipboardManager) getContext().getSystemService(getContext().CLIPBOARD_SERVICE);
^
symbol: method getContext()
location: class ClipboardModule
D:\Project\DATN\node_modules@react-native-community\clipboard\android\src\main\java\com\reactnativecommunity\clipboard\ClipboardModule.java:37: error: cannot find symbol
return (ClipboardManager) getContext().getSystemService(getContext().CLIPBOARD_SERVICE);
^
symbol: method getContext()
location: class ClipboardModule
D:\Project\DATN\node_modules@react-native-community\clipboard\android\src\main\java\com\reactnativecommunity\clipboard\ClipboardPackage.java:23: error: incompatible types: ClipboardModule cannot be converted to NativeModule
modules.add(new ClipboardModule(reactContext));
^
Note: D:\Project\DATN\node_modules@react-native-community\clipboard\android\src\main\java\com\reactnativecommunity\clipboard\ClipboardModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
6 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-community_clipboard:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

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

BUILD FAILED in 30s
error Failed to install the app. Command failed with exit code 1: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
D:\Project\DATN\node_modules@react-native-community\clipboard\android\src\main\java\com\reactnativecommunity\clipboard\ClipboardModule.java:14: error: cannot find symbol import com.facebook.react.bridge.ContextBaseJavaModule; ^ symbol: class ContextBaseJavaModule location: package com.facebook.react.bridge D:\Project\DATN\node_modules@react-native-community\clipboard\android\src\main\java\com\reactnativecommunity\clipboard\ClipboardModule.java:23: error: cannot find symbol public class ClipboardModule extends ContextBaseJavaModule { ^ symbol: class ContextBaseJavaModule D:\Project\DATN\node_modules@react-native-community\clipboard\android\src\main\java\com\reactnativecommunity\clipboard\ClipboardModule.java:31: error: method does not override or implement a method from a supertype @OverRide ^ D:\Project\DATN\node_modules@react-native-community\clipboard\android\src\main\java\com\reactnativecommunity\clipboard\ClipboardModule.java:37: error: cannot find symbol return (ClipboardManager) getContext().getSystemService(getContext().CLIPBOARD_SERVICE); ^ symbol: method getContext() location: class ClipboardModule D:\Project\DATN\node_modules@react-native-community\clipboard\android\src\main\java\com\reactnativecommunity\clipboard\ClipboardModule.java:37: error: cannot find symbol return (ClipboardManager) getContext().getSystemService(getContext().CLIPBOARD_SERVICE); ^ symbol: method getContext() location: class ClipboardModule D:\Project\DATN\node_modules@react-native-community\clipboard\android\src\main\java\com\reactnativecommunity\clipboard\ClipboardPackage.java:23: error: incompatible types: ClipboardModule cannot be converted to NativeModule modules.add(new ClipboardModule(reactContext)); ^ Note: D:\Project\DATN\node_modules@react-native-community\clipboard\android\src\main\java\com\reactnativecommunity\clipboard\ClipboardModule.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 6 errors FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':react-native-community_clipboard:compileDebugJavaWithJavac'. > Compilation failed; see the compiler error output for details. * 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 30s.
info Run CLI with --verbose flag for more details.

This is my ### build.gradle
`
buildscript {
ext {
buildToolsVersion = "34.0.0"
minSdkVersion = 21
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "25.1.8937393"
kotlinVersion = "1.8.0"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
classpath 'com.google.gms:google-services:4.3.14'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
}
}

apply plugin: "com.facebook.react.rootproject"
`

### app/build.gradle
`apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"

/**

  • This is the configuration block to customize your React Native Android app.

  • By default you don't need to apply any configuration, just uncomment the lines you need.
    /
    react {
    /
    Folders */
    // The root of your project, i.e. where "package.json" lives. Default is '..'
    // root = file("../")
    // The folder where the react-native NPM package is. Default is ../node_modules/react-native
    // reactNativeDir = file("../node_modules/react-native")
    // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
    // codegenDir = file("../node_modules/@react-native/codegen")
    // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
    // cliFile = file("../node_modules/react-native/cli.js")

    /* Variants */
    // The list of variants to that are debuggable. For those we're going to
    // skip the bundling of the JS bundle and the assets. By default is just 'debug'.
    // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
    // debuggableVariants = ["liteDebug", "prodDebug"]

    /* Bundling */
    // A list containing the node command and its flags. Default is just 'node'.
    // nodeExecutableAndArgs = ["node"]
    //
    // The command to run when bundling. By default is 'bundle'
    // bundleCommand = "ram-bundle"
    //
    // The path to the CLI configuration file. Default is empty.
    // bundleConfig = file(../rn-cli.config.js)
    //
    // The name of the generated asset file containing your JS bundle
    // bundleAssetName = "MyApplication.android.bundle"
    //
    // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
    // entryFile = file("../js/MyApplication.android.js")
    //
    // A list of extra flags to pass to the 'bundle' commands.
    // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
    // extraPackagerArgs = []

    /* Hermes Commands */
    // The hermes compiler command to run. By default it is 'hermesc'
    // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
    //
    // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
    // hermesFlags = ["-O", "-output-source-map"]
    }

/**

  • Set this to true to Run Proguard on Release builds to minify the Java bytecode.
    */
    def enableProguardInReleaseBuilds = false

/**

  • The preferred build flavor of JavaScriptCore (JSC)
  • For example, to use the international variant, you can use:
  • def jscFlavor = 'org.webkit:android-jsc-intl:+'
  • The international variant includes ICU i18n library and necessary data
  • allowing to use e.g. Date.toLocaleString and String.localeCompare that
  • give correct results when using with locales other than en-US. Note that
  • this variant is about 6MiB larger per architecture than default.
    */
    def jscFlavor = 'org.webkit:android-jsc:+'

android {
ndkVersion rootProject.ext.ndkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
compileSdk rootProject.ext.compileSdkVersion

namespace "com.datn"
defaultConfig {
    applicationId "com.datn"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
}
signingConfigs {
    debug {
        storeFile file('debug.keystore')
        storePassword 'android'
        keyAlias 'androiddebugkey'
        keyPassword 'android'
    }
}
buildTypes {
    debug {
        signingConfig signingConfigs.debug
    }
    release {
        // Caution! In production, you need to generate your own keystore file.
        // see https://reactnative.dev/docs/signed-apk-android.
        signingConfig signingConfigs.debug
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}

}

dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
implementation("com.facebook.react:flipper-integration")
implementation project(':react-native-vector-icons')

if (hermesEnabled.toBoolean()) {
    implementation("com.facebook.react:hermes-android")
} else {
    implementation jscFlavor
}

}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle")
`

package.json

{ "name": "DATN", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "lint": "eslint .", "start": "react-native start", "test": "jest" }, "dependencies": { "@amplitude/react-native": "2.7.0", "@braintree/sanitize-url": "7.0.0", "@giphy/react-native-sdk": "2.3.0", "@jitsi/react-native-sdk": "^2.2.1", "@material/material-color-utilities": "^0.2.7", "@react-native-async-storage/async-storage": "1.19.4", "@react-native-community/clipboard": "1.5.1", "@react-native-community/netinfo": "11.1.0", "@react-native-community/slider": "4.4.3", "@react-native-google-signin/google-signin": "10.1.0", "@react-native/metro-config": "0.72.9", "@react-navigation/bottom-tabs": "^6.5.20", "@react-navigation/material-bottom-tabs": "^6.2.28", "@react-navigation/native": "^6.1.17", "@react-navigation/native-stack": "^6.9.26", "@reduxjs/toolkit": "^2.2.3", "@types/react-native-vector-icons": "^6.4.18", "healthicons-react-native": "^1.4.0", "i": "^0.3.7", "lottie-react-native": "^6.7.2", "npm": "^10.5.2", "react": "18.2.0", "react-native": "0.73.6", "react-native-background-timer": "2.4.1", "react-native-calendar-events": "2.2.0", "react-native-calendars": "^1.1304.1", "react-native-default-preference": "1.4.4", "react-native-device-info": "10.9.0", "react-native-gesture-handler": "2.9.0", "react-native-get-random-values": "1.9.0", "react-native-gifted-chat": "^2.4.0", "react-native-immersive-mode": "2.0.1", "react-native-keep-awake": "4.0.0", "react-native-linear-gradient": "^2.8.3", "react-native-orientation-locker": "1.6.0", "react-native-pager-view": "6.2.0", "react-native-paper": "5.10.3", "react-native-performance": "5.0.0", "react-native-qrcode-svg": "^6.3.0", "react-native-safe-area-context": "4.7.1", "react-native-screens": "3.24.0", "react-native-sound": "0.11.2", "react-native-splash-screen": "3.3.0", "react-native-svg": "13.13.0", "react-native-vector-icons": "^10.0.3", "react-native-video": "6.0.0-alpha.11", "react-native-watch-connectivity": "1.1.0", "react-native-webrtc": "118.0.6", "react-native-webview": "13.5.1", "react-redux": "^9.1.2", "text-encoding": "0.7.0" }, "devDependencies": { "@babel/core": "^7.20.0", "@babel/preset-env": "^7.20.0", "@babel/runtime": "^7.20.0", "@react-native/babel-preset": "0.73.21", "@react-native/eslint-config": "0.73.2", "@react-native/metro-config": "0.73.5", "@react-native/typescript-config": "0.73.1", "@types/color": "^3.0.6", "@types/jest": "^29.5.12", "@types/react": "^18.2.6", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.6.3", "eslint": "^8.19.0", "jest": "^29.6.3", "prettier": "2.8.8", "react-test-renderer": "18.2.0", "typescript": "5.0.4" }, "engines": { "node": ">=18" }, "overrides": { "@xmldom/xmldom": "0.8.7" } }

Android Manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.MANAGE_OWN_CALLS" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" /> <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:theme="@style/AppTheme"> <activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="datn" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" /> <data android:scheme="https" /> <data android:host="www.datn.com.vn" /> </intent-filter> </activity> </application> </manifest>

How can I fix this? Thank you so much

@NguyenTran153 NguyenTran153 changed the title Can run app Can not run app May 6, 2024
@NguyenTran153 NguyenTran153 changed the title Can not run app Can not run app, getting errors related to the React Native Community Clipboard May 6, 2024
@saghul
Copy link
Member

saghul commented May 6, 2024

I'd recomend you use RN 0.72 and Gradle 7 since that's what our SDK is built with.

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

2 participants