how can i fix font garbled in android emulaoter [duplicate]
android emulator screen doesn't show string or icon
i'm using android studio. when i onpend emulator for the first time it's fine evrything but if i running from second time screen is something wrong .i can't see string and some of icon
i don't know why this error happen.... how can i fix?...
this is my emulator screen
for resolve this problem what should i try??
how can i set OpenGL ES to Compatibility in Android studio?
Why am I receiving a cannot read property `UIAppFonts of null` error when running react-native link?
I am trying to implement custom fonts in a react native application. I am using react native web and can see the custom fonts working on web but not in native. I am working on an Android app but the issues seems to be within the IOS folder which I'm not even using. I found this question on SO but none of the solutions have worked for me. I've tried:
- Uninstalling and reinstalling react-native
- Running react-native upgrade
- The assets folder was originally in my
src
folder so I moved it to the root of the project
My fonts are located in ./assets/fonts
in the root of my project and they are otf files, there are no hyphens in the file names. I created a react-native.config.js
file in the root of my project and this is what is in it:
module.exports = { project: { ios: {}, android: {}, }, assets: ['./assets/fonts/'], };
When I run react-native link
this is the error I'm receiving:
info Linking assets to ios projectwarn Group 'Resources' does not exist in your Xcode project. We have created it automatically for you.error Linking assets failed. Run CLI with --verbose flag for more details.TypeError: Cannot read property 'UIAppFonts' of null at Object.linkAssetsIOS [as copyAssets] (/Users/daniellemccarthy/linos-poc/voice/case-picking/node_modules/@react-native-community/cli-platform-ios/build/link/copyAssets.js:89:31) at Object.keys.forEach.platform (/Users/daniellemccarthy/linos-poc/voice/case-picking/node_modules/@react-native-community/cli/build/commands/link/linkAssets.js:42:16) at Array.forEach (<anonymous>) at linkAssets (/Users/daniellemccarthy/linos-poc/voice/case-picking/node_modules/@react-native-community/cli/build/commands/link/linkAssets.js:33:32) at linkAll (/Users/daniellemccarthy/linos-poc/voice/case-picking/node_modules/@react-native-community/cli/build/commands/link/linkAll.js:96:31) at Object.link [as func] (/Users/daniellemccarthy/linos-poc/voice/case-picking/node_modules/@react-native-community/cli/build/commands/link/link.js:82:33) at Command.handleAction (/Users/daniellemccarthy/linos-poc/voice/case-picking/node_modules/@react-native-community/cli/build/index.js:186:23) at Command.listener (/Users/daniellemccarthy/linos-poc/voice/case-picking/node_modules/commander/index.js:315:8) at Command.emit (events.js:198:13) at Command.parseArgs (/Users/daniellemccarthy/linos-poc/voice/case-picking/node_modules/commander/index.js:651:12)
When I run react-native info
this is what is shows:
System: OS: macOS 10.15.3 CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz Memory: 1.72 GB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 10.16.0 - /usr/local/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.13.7 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.8.4 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2 Android SDK: Not Found IDEs: Android Studio: 3.6 AI-192.7142.36.36.6392135 Xcode: 11.4.1/11E503a - /usr/bin/xcodebuild Languages: Java: 11.0.6 - /Users/daniellemccarthy/.sdkman/candidates/java/current/bin/javac Python: 3.7.3 - /usr/local/bin/python npmPackages: @react-native-community/cli: ^4.8.0 => 4.8.0 react: ^16.9.0 => 16.13.1 react-native: ^0.62.2 => 0.62.2 npmGlobalPackages:
Error: Bundling failed - While trying to resolve module 'react-native-firebase'
I'm trying to use Firebase Authentication and am getting the below error when running react-native run-android
. The error is happening in the node terminal that pops up when \react-native\scripts\..\local-cli\cli.js script runs. I'm following the docs for the initial setup, android setup, and auth setup. Where is the dist/ folder supposed to come from? Thanks in advance!
error: bundling failed: Error: While trying to resolve module react-native-firebase
from file D:\Temp\projects\app\src\components\LoginView.js
, the package D:\Temp\projects\app\node_modules\react-native-firebase\package.json
was successfully found. However, this package itself specifies a main
module field that could not be resolved (D:\Temp\projects\app\node_modules\react-native-firebase\dist\index.js
. Indeed, none of these files exist:
D:\Temp\projects\app\node_modules\react-native-firebase\dist\index.js(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
D:\Temp\projects\app\node_modules\react-native-firebase\dist\index.js\index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
at ResolutionRequest.resolveDependency (D:\Temp\projects\app\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:61:15)at DependencyGraph.resolveDependency (D:\Temp\projects\app\node_modules\metro\src\node-haste\DependencyGraph.js:219:16)at Object.resolve (D:\Temp\projects\app\node_modules\metro\src\lib\transformHelpers.js:141:30)at dependencies.map.result (D:\Temp\projects\app\node_modules\metro\src\DeltaBundler\traverseDependencies.js:373:31)at Array.map ()at resolveDependencies (D:\Temp\projects\app\node_modules\metro\src\DeltaBundler\traverseDependencies.js:369:18)at D:\Temp\projects\app\node_modules\metro\src\DeltaBundler\traverseDependencies.js:188:33at Generator.next ()at step (D:\Temp\projects\app\node_modules\metro\src\DeltaBundler\traverseDependencies.js:298:30)at D:\Temp\projects\app\node_modules\metro\src\DeltaBundler\traverseDependencies.js:309:15
package.json:
{"dependencies": {"react": "^16.6.0-alpha.8af6728","react-native": "0.57.4","react-native-firebase": "^5.1.0" },"peerDependencies": {"react": "^16.5.0" },"devDependencies": {"babel-jest": "23.6.0","jest": "23.6.0","metro-react-native-babel-preset": "0.49.0","react-test-renderer": "16.6.0-alpha.8af6728" }
Get event from React JS to React Native
I am new to React technology. have a mobile app developed in React Native, in that we are loading some webpages in the web view. Can we capture some events from ReactJS to React Native or can we can React Native method from React JS?
How to implement interactive bar chart in React native?
I am working on React Native App project where I have to display an interactive bar chart. As shown in attracted screenshot. The app is working on both iOS and Android devices. Where we are currently providing minimal iOS and Android app support as following:
1. Android 4.3.x / Jelly Bean / API level 18 2. iOS 9.0 or later3. iPadOS 9.0 or later.
Requirement:
- In a bar chart, every bar will be clickable. When the user clicks on any bar, the relative information will be display below the chart accordingly.
- Suggested chart library should match our minimal app support in both operating systems (iOS & Android).
Current dependencies
Currently, the project is running with the following React framework versions:
- React Native: 0.63.4
- React: 16.13.1
React native "Attempt to invoke virtual method 'android.app.Activity.showdShowRequestPermissionRationale' on a null object reference"
I'm trying to incorporate Twilio voice using the react-native-twilio-programmable-voice package. My app loads on ios, but when running on android I get this error message
Attempt to invoke virtual method 'boolean android.app.Activity.shouldShowRequestPermissionRationale' on a null object referencescreenshot here
I've included <uses-permission android:name="android.permission.RECORD_AUDIO" />
in AndroidManifest.xml
and none of the TwilioVoice related functions are called until 4 or 5 screens into the app.
Been scratching my head for a few days now, any help is greatly appreciated.
Code snippet of my Twilio helper class:
import TwilioVoice from 'react-native-twilio-programmable-voice';import {Platform} from 'react-native';import config from '../config/Config';export default class Voip{ constructor(props) { this.state = { };} async setupDeviceWithToken(accessToken){ console.log('V32: setup device', accessToken); TwilioVoice.addEventListener('deviceReady', () => this.deviceReadyHandler()); TwilioVoice.addEventListener('deviceNotReady', () => this.deviceNotReadyHandler()); TwilioVoice.addEventListener('connectionDidConnect', () => this.connectionDidConnectHandler()); TwilioVoice.addEventListener('connectionDidDisconnect', () => this.connectionDidDisconnectHandler());if(Platform.OS === 'ios'){ TwilioVoice.addEventListener('callRejected', this.callRejected());} else if (Platform.OS === 'android'){ TwilioVoice.addEventListener('deviceDidReceiveIncoming', this.deviceDidReceiveIncomingHandler());}var success;try { success = await TwilioVoice.initWithToken(accessToken); console.log('V36: ', success); //return success; }catch(err){ console.log('V40: ' ,err); return err; } // if(Platform.OS === 'ios') // { try { TwilioVoice.configureCallKit({ appName: 'VoipApp' // Required param }) console.log('V50: ios success'); //return 'success'; } catch (err) { console.log('V54: ',err); return err; } // } return success;}
Unable to bind isolated service in react native android application
Am trying to bind one service as an isolated process in my react native Android app
<service android:name="com.xx.xx.services.IsolatedService" android:enabled="true" android:isolatedProcess="false" android:process=":service" />
But if enabled the service as an isolated process then service is not binding else it's working fine.I have tried in a simple native android app and its binding without any issue.
public class MainActivity extends ReactActivity { private AIDLInterface serviceBinder; @Override protected void onCreate(Bundle savedInstanceState) { SplashScreen.show(this, R.style.SplashScreenTheme); super.onCreate(savedInstanceState); } @Override protected void onStart() { super.onStart(); Intent intent = new Intent(this, IsolatedService.class); this.getApplicationContext().bindService(intent, mIsolatedConnection, BIND_AUTO_CREATE); } /** * Returns the name of the main component registered from JavaScript. * This is used to schedule rendering of the component. */ @Override protected String getMainComponentName() { return "xcvxcv"; } private ServiceConnection mIsolatedConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName componentName, IBinder iBinder) { serviceBinder = AIDLInterface.Stub.asInterface(iBinder); // Console.log("mIsolatedConnection"); } @Override public void onServiceDisconnected(ComponentName componentName) { // Console.log("onServiceDisconnected"); } };}
its not giving onServiceDisconnected /onServiceConnected or any exception.
but the same is binding to the service if I update the isolatedProcess
as false
How do I listen for a specific tone using react-native?
I am trying to create an app for my brother that snaps a picture when it hears a specific tone. I have the picture taking part down, but can't seem to find anything on listening for a tone. There are TONS of stuff about how to record audio, but that doesn't help me.
I was thinking about looking into voice activation, but is that overkill? Any info would be greatly appreciated.
can read /storage but cannot read /storage/emulated in react-native-fs [Error: Attempt to get length of null array]
I'm trying to write an app that needs to navigate through file system (directory based music player). For that I'm using react-native-fs. The problem is that I can read content of the /storage directory but when I'm trying to read any deeper like for example /storage/emulated or content of sd card the app shows me an error - [Error: Attempt to get length of null array].
When I'm checking for permission both build in function and app settings shows me that I have permission granted. The problem occurs both on android emulator and on real device.
Any ideas what am I doing wrong or how can I bypass this problem?
That's my android manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.filesys"><uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/><application ...
And that's my code:
import { View, Text, StyleSheet, PermissionsAndroid, Alert, Button } from 'react-native';import * as RNFS from 'react-native-fs';const requestPermission = async () => { try { const granted = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE, {'title': 'Read External Storage Permission','message': 'The App needs access to your external storage ' } ) if (granted === PermissionsAndroid.RESULTS.GRANTED) { Alert.alert("Read external storage permission granted."); } else { Alert.alert("Read external storage permission not granded"); } } catch (err) { console.log(err) }}const checkPermission = () => { PermissionsAndroid.check( PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE) .then(result => console.log(result)) .catch(err => console.log(err));}const showFiles = (path) => { RNFS.readDir(path) .then(files => { console.log('files:') files.forEach(file => console.log(file)) }) .catch(err => console.log(err));}export default class Main extends Component { async componentDidMount() { await requestPermission() } render() { return (<View style={styles.container} ><Text>show files app</Text><Button title='check permission' onPress={checkPermission}/><Button title='show storage files' onPress={() => showFiles('/storage')}/><Button title='show storage/amulated files' onPress={() => showFiles('/storage/emulated')}/></View> ); }}const styles = StyleSheet.create( { container: { flex: 1, justifyContent: 'center', alignItems: 'center' }, });
When I press "show storage files" button the console logs me:
LOG files:
LOG {"ctime": null, "isDirectory": [Function isDirectory], "isFile": [Function isFile], "mtime": 2021-03-21T21:02:49.000Z, "name": "0123-4567", "path": "/storage/0123-4567", "size": 131072}
LOG {"ctime": null, "isDirectory": [Function isDirectory], "isFile": [Function isFile], "mtime": 2021-03-21T21:01:52.000Z, "name": "emulated", "path": "/storage/emulated", "size": 4096}
LOG {"ctime": null, "isDirectory": [Function isDirectory], "isFile": [Function isFile], "mtime": 2021-03-21T20:54:25.000Z, "name": "sdcard0", "path": "/storage/sdcard0", "size": 4096}
LOG {"ctime": null, "isDirectory": [Function isDirectory], "isFile": [Function isFile], "mtime": 2021-03-21T21:01:52.000Z, "name": "self", "path": "/storage/self", "size": 60}
But when I press "show storage/amulated files" I've got:
LOG [Error: Attempt to get length of null array]
React Native on android complains about requireNativeComponent RNCSafeAreaProvider
So the error is:
Invariant Violation: requireNativeComponent: "RNCSafeAreaProvider" was not found in the UIManager.This error is located at: in RNCSafeAreaProvider (at SafeAreaContext.tsx:76)...etc
I believe I was getting this same error when spinning up the project in the iOS simulator and the fix ended up being cd ios/; pod install
but I am unable to find an equivalent solution when spinning up in the android studio simulator
I'm new to the whole react native setup without expo and more specifically the android side of things.
Any suggestions?
React Native Error: Attempted to use a firebase module that is not installed on your Android project by calling firebase.firestore()
I am not sure what else to do. I have this erros when trying to login into a application:
React Native Error: Attempted to use a firebase module that is not installed on your Andrid project by calling firebase.firestore()
I read documentation and everything looks good according to it.
MainApplication.java:
> import io.invertase.firebase.auth.RNFirebaseAuthPackage;> import io.invertase.firebase.RNFirebasePackage;> import io.invertase.firebase.storage.RNFirebaseStoragePackage;> import com.facebook.soloader.SoLoader; @Override protected List<ReactPackage> getPackages() { @SuppressWarnings("UnnecessaryLocalVariable") List<ReactPackage> packages = new PackageList(this).getPackages(); // Packages that cannot be autolinked yet can be added manually here, for example: // packages.add(new MyReactNativePackage()); packages.add(new RNFirebaseAuthPackage()); packages.add(new RNFirebaseStoragePackage()); return packages; }
build.gradle in android/:
buildscript { ext { buildToolsVersion = "28.0.3" minSdkVersion = 16 compileSdkVersion = 28 targetSdkVersion = 28 supportLibVersion = "28.0.0" } repositories { google() jcenter() mavenCentral() } dependencies { classpath 'com.google.gms:google-services:4.3.3' classpath("com.android.tools.build:gradle:3.4.1")
build.gradle in android/app
implementation project(':react-native-firebase') implementation "com.google.firebase:firebase-auth:19.2.0" implementation "com.google.firebase:firebase-storage:19.1.1" implementation "com.google.firebase:firebase-database:19.2.1" implementation "com.google.firebase:firebase-firestore:21.2.1"
Already clean e nothing works. I still getting the same error. According to the documentation, all the files are right configured.
React Native, Failed to launch emulator. Reason: No emulators found as an output
I'm trying to run my react native app in emulator by using command react-native run-android
but it's throwing that error
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.Use '--warning-mode all' to show the individual deprecation warnings.See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warningsBUILD SUCCESSFUL in 44sinfo Connecting to the development server...warn Failed to connect to development server using "adb reverse": spawnSync /Opt/Android/platform-tools/adb ENOENTinfo Starting the app...The system cannot find the path specified.error Failed to start the app. Run CLI with --verbose flag for more details.Error: Command failed: /Opt/Android/platform-tools/adb shell am start -n com.reactproject/com.reactproject.MainActivity at makeError (C:\Users\Danger World\ReactProject\node_modules\execa\index.js:174:9)
I already setup my android studio and sdk manager, avd manager like it's shown in doc also I already set path but it's still showing that error, anyone know why? Can anyone help please?
How to implement Mapbox turn-by-turn react-native
I am very new to react-native.
And now I want to build app in react-native with turn-by-turn navigation feature, where can I find the library that I can use for?
I just find this repository https://github.com/emin93/react-native-mapbox-navigation but I don't know what to do next, there is no documentation added, is the repository worked? or not, can you guys help me what should I do next??-o- { }
react-native-camera: Android app keeps crashing
I've added react-native-camera to my application. After creating a component that uses RNCamera, everytime I try to run my app (using react-native run-android
), it crashes without outputting any error messages.
This is my package.json:
{"main": "index.js","scripts": {"android": "react-native run-android","ios": "react-native run-ios","web": "expo start --web","start": "react-native start","test": "jest" },"dependencies": {"@react-native-community/async-storage": "^1.12.1","@tensorflow-models/mobilenet": "^2.0.4","@tensorflow/tfjs": "^3.3.0","@tensorflow/tfjs-react-native": "^0.5.0","expo": "~40.0.0","expo-camera": "~9.1.0","expo-constants": "^10.0.1","expo-gl": "~9.2.0","expo-gl-cpp": "~9.2.0","expo-splash-screen": "~0.8.0","expo-status-bar": "~1.0.3","expo-updates": "~0.4.0","mobx": "^6.1.8","react": "16.13.1","react-dom": "16.13.1","react-native": "~0.63.4","react-native-camera": "^3.43.0","react-native-fs": "^2.16.6","react-native-gesture-handler": "~1.8.0","react-native-reanimated": "~1.13.0","react-native-screens": "~2.15.0","react-native-unimodules": "~0.12.0","react-native-web": "~0.13.12" },"devDependencies": {"@babel/core": "~7.9.0","babel-jest": "~25.2.6","jest": "~25.2.6","react-test-renderer": "~16.13.1" },"jest": {"preset": "react-native" },"private": true}
This is my build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.buildscript { ext { buildToolsVersion = "29.0.2" minSdkVersion = 21 compileSdkVersion = 29 targetSdkVersion = 29 } repositories { google() jcenter() } dependencies { classpath("com.android.tools.build:gradle:3.5.3") classpath("com.google.gms:google-services:4.3.5") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }}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 { url("$rootDir/../node_modules/expo-camera/android/maven") } maven { url 'https://www.jitpack.io' } google() jcenter() }}
This is my /app/build.gradle:
apply plugin: "com.android.application"apply plugin: "com.google.gms.google-services"import com.android.build.OutputFileproject.ext.react = [ enableHermes: false]apply from: '../../node_modules/react-native-unimodules/gradle.groovy'apply from: "../../node_modules/react-native/react.gradle"apply from: "../../node_modules/expo-constants/scripts/get-app-config-android.gradle"apply from: "../../node_modules/expo-updates/scripts/create-manifest-android.gradle"def enableSeparateBuildPerCPUArchitecture = falsedef enableProguardInReleaseBuilds = falsedef jscFlavor = 'org.webkit:android-jsc:+'def enableHermes = project.ext.react.get("enableHermes", false);android { compileSdkVersion rootProject.ext.compileSdkVersion ndkVersion "22.0.7026061" compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { applicationId "com.chowtime" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName "1.0" missingDimensionStrategy 'react-native-camera', 'mlkit' } splits { abi { reset() enable enableSeparateBuildPerCPUArchitecture universalApk false // If true, also generate a universal APK include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } 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" } } // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.each { output -> // For each separate APK per architecture, set a unique version code as described here: // https://developer.android.com/studio/build/configure-apk-splits.html def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] def abi = output.getFilter(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = versionCodes.get(abi) * 1048576 + defaultConfig.versionCode } } }}dependencies { implementation platform('com.google.firebase:firebase-bom:26.7.0') implementation 'com.google.firebase:firebase-analytics' implementation (project(':react-native-camera')) { exclude group: "com.google.android.gms" exclude group: "com.google.android.gms", module: "play-services-vision" exclude group: "com.google.firebase", module: "firebase-ml-vision-face-model" } implementation ("com.google.firebase:firebase-ml-vision:19.0.3") { force = true; } implementation ("com.google.firebase:firebase-ml-vision-face-model:17.0.2") { force = true; } implementation fileTree(dir: "libs", include: ["*.jar"]) //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { exclude group:'com.facebook.fbjni' } debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' exclude group:'com.squareup.okhttp3', module:'okhttp' } debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' } addUnimodulesDependencies() if (enableHermes) { def hermesPath = "../../node_modules/hermes-engine/android/"; debugImplementation files(hermesPath +"hermes-debug.aar") releaseImplementation files(hermesPath +"hermes-release.aar") } else { implementation jscFlavor }}task copyDownloadableDepsToLibs(type: Copy) { from configurations.compile into 'libs'}apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
This is what my android project directory looks like:
Any info about why this may be happening or how to resolve this issue would be greatly appreciated! Thanks :)
Flatlist React native card's onPress does not trigger on Android
I am using Expo
for my app. I have a horizontal Flatlist where I render my data react native paper's
Card. I saw Card have onPress function. I used that to navigate the another page. But onPress function does not trigger on Android device. I know React native's touchable-opacity have positioning issue on Android. I tried hitSlop
and inline styling zIndex
but still does not work. I also wrap my card with react-native's
touchable-opacity and play with positioning still did not help me, only it works when i used react-native-gesture-handler's
touchable-opacity but then it does not work on IOS. Hope anyone can help me...
import React from 'react';import { Card } from 'react-native-paper';import { useNavigation } from '@react-navigation/native';interface Iprops { item: string;}export default function RenderCard({ item }: Iprops) { const navigation = useNavigation(); return (<Card hitSlop={{ "bottom": 30, "top": 30, "right": 30, "left": 30 }} onPress={() => { navigation.navigate(`detail`, { // THIS DOES NOT TRIGGER ON ANDROID "id": `${item.pk}` }); }} style={{ "marginBottom": 20 }}><Card.Cover source={{ "uri": `${item.img_url}` }} /><Card.Actions><Card.Title title={item.name} subtitle="Card Subtitle" /></Card.Actions></Card> );}
react-native Task :app:multiDexListDebug FAILED
I have installed react-native-firebase package using yarn. I've setup the code in the build.gradle, settings.gradle as well as the AndroidManifest as well. Added multiDexEnabled as true and also added the implementation line in the code, but it is still not working.
build.gradle (App Level)
apply plugin: "com.android.application"import com.android.build.OutputFile/** * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets * and bundleReleaseJsAndAssets). * These basically call `react-native bundle` with the correct arguments during the Android build * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the * bundle directly from the development server. Below you can see all the possible configurations * and their defaults. If you decide to add a configuration block, make sure to add it before the * `apply from: "../../node_modules/react-native/react.gradle"` line. * * project.ext.react = [ * // the name of the generated asset file containing your JS bundle * bundleAssetName: "index.android.bundle", * * // the entry file for bundle generation. If none specified and * // "index.android.js" exists, it will be used. Otherwise "index.js" is * // default. Can be overridden with ENTRY_FILE environment variable. * entryFile: "index.android.js", * * // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format * bundleCommand: "ram-bundle", * * // whether to bundle JS and assets in debug mode * bundleInDebug: false, * * // whether to bundle JS and assets in release mode * bundleInRelease: true, * * // whether to bundle JS and assets in another build variant (if configured). * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants * // The configuration property can be in the following formats * // 'bundleIn${productFlavor}${buildType}' * // 'bundleIn${buildType}' * // bundleInFreeDebug: true, * // bundleInPaidRelease: true, * // bundleInBeta: true, * * // whether to disable dev mode in custom build variants (by default only disabled in release) * // for example: to disable dev mode in the staging build type (if configured) * devDisabledInStaging: true, * // The configuration property can be in the following formats * // 'devDisabledIn${productFlavor}${buildType}' * // 'devDisabledIn${buildType}' * * // the root of your project, i.e. where "package.json" lives * root: "../../", * * // where to put the JS bundle asset in debug mode * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", * * // where to put the JS bundle asset in release mode * jsBundleDirRelease: "$buildDir/intermediates/assets/release", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in debug mode * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in release mode * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", * * // by default the gradle tasks are skipped if none of the JS files or assets change; this means * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to * // date; if you have any other folders that you want to ignore for performance reasons (gradle * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ * // for example, you might want to remove it from here. * inputExcludes: ["android/**", "ios/**"], * * // override which node gets called and with what additional arguments * nodeExecutableAndArgs: ["node"], * * // supply additional arguments to the packager * extraPackagerArgs: [] * ] */project.ext.react = [ enableHermes: false, // clean and rebuild if changing]apply from: "../../node_modules/react-native/react.gradle"/** * Set this to true to create two separate APKs instead of one: * - An APK that only works on ARM devices * - An APK that only works on x86 devices * The advantage is the size of the APK is reduced by about 4MB. * Upload all the APKs to the Play Store and people will download * the correct one based on the CPU architecture of their device. */def enableSeparateBuildPerCPUArchitecture = false/** * Run Proguard to shrink the Java bytecode in release builds. */def enableProguardInReleaseBuilds = false/** * The preferred build flavor of JavaScriptCore. * * 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:+'/** * Whether to enable the Hermes VM. * * This should be set on project.ext.react and mirrored here. If it is not set * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode * and the benefits of using Hermes will therefore be sharply reduced. */def enableHermes = project.ext.react.get("enableHermes", false);android { compileSdkVersion rootProject.ext.compileSdkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { applicationId "com.safetravel_100" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName "1.0" multiDexEnabled true } splits { abi { reset() enable enableSeparateBuildPerCPUArchitecture universalApk false // If true, also generate a universal APK include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } 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://facebook.github.io/react-native/docs/signed-apk-android. signingConfig signingConfigs.debug minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } packagingOptions { pickFirst "lib/armeabi-v7a/libc++_shared.so" pickFirst "lib/arm64-v8a/libc++_shared.so" pickFirst "lib/x86/libc++_shared.so" pickFirst "lib/x86_64/libc++_shared.so" } // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.each { output -> // For each separate APK per architecture, set a unique version code as described here: // https://developer.android.com/studio/build/configure-apk-splits.html def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] def abi = output.getFilter(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = versionCodes.get(abi) * 1048576 + defaultConfig.versionCode } } }}dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules implementation project(':react-native-geocoder') implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" implementation 'androidx.multidex:multidex:2.0.0' debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { exclude group:'com.facebook.fbjni' } debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' } debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' } if (enableHermes) { def hermesPath = "../../node_modules/hermes-engine/android/"; debugImplementation files(hermesPath +"hermes-debug.aar") releaseImplementation files(hermesPath +"hermes-release.aar") } else { implementation jscFlavor }}// Run this once to be able to run the application with BUCK// puts all compile dependencies into folder libs for BUCK to usetask copyDownloadableDepsToLibs(type: Copy) { from configurations.compile into 'libs'}apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)apply plugin: 'com.google.gms.google-services'
build.gradle (Project Level)
// Top-level build file where you can add configuration options common to all sub-projects/modules.buildscript { ext { buildToolsVersion = "28.0.3" minSdkVersion = 16 compileSdkVersion = 28 targetSdkVersion = 28 } repositories { google() jcenter() } dependencies { classpath('com.android.tools.build:gradle:3.6.3') classpath 'com.google.gms:google-services:4.2.0' //added // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }}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") } google() jcenter() maven { url 'https://www.jitpack.io' } }}
Send push notifications via AWS Pinpoint to specified User
I am using react-native and amplify to send push notifications to devices via AWS Pinpoint. I can get the generated token for the devices. But I just need to send push notifications using user Id. I try to update the endpoint, but it's not working. Can anyone suggest me the proper way to handle this?
PushNotification.onRegister((token) => { console.log('in app registration', token); Analytics.updateEndpoint({ address: token, channelType: "GCM", OptOut: 'NONE', userId: "12345" }).then(data => { console.log(data) }).catch(error => { console.log(error) });});
Could not connect to React Native development server on Android
When I run react-native run-android
, it gives me the following error:
Could not connect to development server
- Package server is running and I can access it directly from browseron my mobile device.
- My Android device is connected to computer and has debugging enabled (Ichecked using
adb devices
command). - My Android version is 4.4.4 so I cannot use
adb reverse
command. - I have set the ID address and port in Dev setting.
- USB debug is on.
- I use Windows 7.
How to fix this error?