Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all 28463 articles
Browse latest View live

Display png image from native module in react native

$
0
0

I have a slider component which I want to have a handle as png image pass as a prop. Now, I want that png image to pass through react native to native modules(android and ios both). The component is written at native side for both ios(Objective C) and android(Java).

  1. How can I pass png image as a prop to native modules?
  2. How can I use them at native Java part?(I am using Canvas to draw myslider as shown below).
  3. How can I use them at native Objective C?(I am using CGContext todraw my slider).

What I have tried:

  1. I resolved path of png image by following code at React Native side.
  const myImage = require('../assets/slider-handle.png');  const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');  const resolvedImage = resolveAssetSource(myImage); 

Then pass the path of image as a prop imagePath={resolvedImage.uri}.

Then at Java part I do following:

public void drawImage(String imagePath, Canvas canvas, int x, int y) {     Bitmap bitmap = BitmapFactory.decodeFile(imagePath);     canvas.drawBitmap(bitmap, y, x, somePaintValue);}

I am getting the path of image(the path is something like this: (http:/10.0.2.2:8081/assets/app/components/slider/assets/slider.png), I have verified that at native side by consoling the path.

Not sure if I need to pass only path of image or maybe there is a way to pass whole png.This is my first time working with Java and Objective C.This is the slider I am developing.Any help will be really appreciated.


React native Keyboard pushes Bottomsheet out of screen / to top

$
0
0

I am struggling with this issue now for over three weeks.I am using the package osdnk/react-native-reanimated-bottom-sheet and I want to use textinputs inside the bottomsheet. The problem appears when opening the keyboard. The bottomsheet is pushed out of the screen.

There is already a github issue about this but everyone seems to get the problem solved. Except me? Also no one answers my questions there.

Steps I tried:

  • Android.xml: android:windowSoftInputMode="adjustPan"I am using expo and don't want to escape, so please don't provide solutions with the Android.xml file.
  • Replaced all flex:1 with height:100%
  • I tried different variations with wrapping the whole Bottomsheet / Content
  • Tried to create a 3rd snapping point with 100% and snap to this point as soon as an Inputfield is focused. However, this also results in the bottom sheet beeing out of the screen.
  • On IOS its working fine.

My code looks like the following: (simplyfied)

const renderInner = () => (<View><FormTextInput/></View>)return (<BottomSheet        snapPoints={['100%']}        renderContent={renderInner}        renderHeader={renderHeader}        initialSnap={0}    />)

How can I fix this weird behaviour? Please provide an example. Its enough to just use an example provided inside the git-repo, clear everything inside the bottom sheet and add a simple text-input.

enter image description here

Resources are missing in apk

$
0
0

I'm trying to add a .wav file to my React Native app and having a problem with Android implementation.The file keeps getting removed from the build (its' missing in the res/raw folder when I'm unzipping the apk).

Folder structure:

enter image description here

keep.xml content:

<?xml version="1.0" encoding="utf-8"?><resources    xmlns:tools="http://schemas.android.com/tools"    tools:keep="@raw/push_notification_sound"/>

Both shrinking and minifying are disabled in build.gradle for all build types:

minifyEnabled falseshrinkResources false

Any ideas what might be the reason behind this?

react-native-video-controls Warning Animated: `useNativeDriver` was not specified. in React-Native 62.2

$
0
0

I am using react-native to develop the Android APP ,I am using react-native-video-controls in my app after upgrading React_native from 60.0 to 62.2 .

I am getting error
Warning Animated: useNativeDriver was not specified. in React-Native 62.2 for react-native-video-controls

import Video from 'react-native-video';import VideoPlayer from 'react-native-video-controls';<View style={{ width: "100%", height: '100%', backgroundColor: '#065535' }} ><VideoPlayer                      navigator={this.props.navigator}                      source={{ uri: "https://howtags.com/"+ items.file_Name }}                      style={{ width: '100%', height: '100%', top: 0, left: 0, bottom: 0, right: 0, position: "absolute" }}                      ref={(ref) => { this.player = ref }}                      resizeMode="cover"                      posterResizeMode="cover"                      fullscreen={true}                      onEnd={this.onEnd}                      onLoadStart={this.onLoadStart}                      onProgress={this.onProgress}                      paused={this.state.paused}                      onFullScreen={this.state.isFullScreen}                      volume={10}                    /></View>

I am getting this error only after upgrading to "react-native": "^0.62.2", If anyone know the solution please help me

React Native - Android - keyboardavoidingView in stackNavigator within a tabNavigator pushes bottomTabBar (clunky behaviour)

$
0
0

I am trying to build an auth flow that has a welcome page and then login or signup depending on the user's case.It is built inside a stack navigator. The first screen has no header but then login and signup do via their screen options.

// AuthNavigatorconst AuthStackNavigator = createStackNavigator();export const AuthNavigator = () => {  return (<AuthStackNavigator.Navigator      initialRouteName={WELCOME_PAGE.id}      screenOptions={{        headerShown: false,        headerTintColor: colors.primary,      }}      lazy><AuthStackNavigator.Screen        name={WELCOME_PAGE.id}        component={WELCOME_PAGE.component}      /><AuthStackNavigator.Screen        name={LOGIN_PAGE.id}        component={LOGIN_PAGE.component}        options={LOGIN_PAGE.options}      /><AuthStackNavigator.Screen        name={SIGN_UP_PAGE.id}        component={SIGN_UP_PAGE.component}        options={LOGIN_PAGE.options}      /></AuthStackNavigator.Navigator>  );};

This flow, is nested inside a tabNavigator:

// AuthTabNavigatorconst AuthTabNavigator =  Platform.OS === 'android'    ? createMaterialBottomTabNavigator()    : createBottomTabNavigator();const RootNavigator = () => {  return (<AuthTabNavigator.Navigator      activeColor={colors.primary}      inactiveColor="grey"      barStyle={materialBottomNavBackgroundColor}      tabBarOptions={defaultTabNavOptions}><AuthTabNavigator.Screen        name={WELCOME_PAGE.id}        component={AuthNavigator}        options={WELCOME_PAGE.options}      /></AuthTabNavigator.Navigator>  );};export default RootNavigator;

On iOS, things work fine but on Android, It has weird behaviour. When pressing on the input field, the keyboard pushes the bottom bar causing a clunky effect on press but also on dismiss of the field. As if it were recalculating the height every time and repositioning the layout.

In order to make sure it's not coming from my code, I tested again with the snippet from the React Native documentation

I get the following (these are on the Android emulator but I get the same result on my OnePlus android phone)

The only version that works is the one when not nested in the tab navigator so I guess the issue comes from there.

I checked a few solutions but none worked:

I am using React Native CLI:

"react-native": "0.62.2","@react-navigation/bottom-tabs": "^5.2.8","@react-navigation/drawer": "^5.7.2","@react-navigation/material-bottom-tabs": "^5.1.10","@react-navigation/native": "^5.1.7","@react-navigation/stack": "^5.2.17",

Let me know if you encountered the same issue and found a way to fix it. Thanks in advance.

Android issue on mac react native

$
0
0

This issue is happening when i ran react-native run-android command from terminal. It works perfectly if I'm running it in android sdk. See the output below. Any help will be appreciatedAndroid path setup: /Users/fngo/Library/Android/sdk: /Users/fngo/Library/Android/sdk/emulator: /Users/fngo/Library/Android/sdk/tools: /Users/fngo/Library/Android/sdk/tools/bin: /Users/fngo/Library/Android/sdk/platform-tools: -------------See problems below, my apology for the huge entry --------------------info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.Jetifier found 960 file(s) to forward-jetify. Using 8 workers...info Starting JS server...* daemon not running; starting now at tcp:5037* daemon started successfullyinfo Launching emulator...info Successfully launched emulator.info Installing the app...Starting a Gradle Daemon (subsequent builds will be faster)java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7 at org.codehaus.groovy.vmplugin.VMPluginFactory.(VMPluginFactory.java:43) at org.codehaus.groovy.reflection.GroovyClassValueFactory.(GroovyClassValueFactory.java:35) at org.codehaus.groovy.reflection.ClassInfo.(ClassInfo.java:107) at org.codehaus.groovy.reflection.ReflectionCache.getCachedClass(ReflectionCache.java:95) at org.codehaus.groovy.reflection.ReflectionCache.(ReflectionCache.java:39) at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerMethods(MetaClassRegistryImpl.java:210) at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.(MetaClassRegistryImpl.java:108) at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.(MetaClassRegistryImpl.java:86) at groovy.lang.GroovySystem.(GroovySystem.java:36) at org.codehaus.groovy.runtime.InvokerHelper.(InvokerHelper.java:86) at groovy.lang.GroovyObjectSupport.getDefaultMetaClass(GroovyObjectSupport.java:59) at groovy.lang.GroovyObjectSupport.(GroovyObjectSupport.java:32) at org.gradle.internal.extensibility.DefaultExtraPropertiesExtension.(DefaultExtraPropertiesExtension.java:29) at org.gradle.internal.extensibility.DefaultConvention.(DefaultConvention.java:49) at org.gradle.internal.extensibility.ExtensibleDynamicObject.(ExtensibleDynamicObject.java:60) at org.gradle.internal.instantiation.generator.MixInExtensibleDynamicObject.(MixInExtensibleDynamicObject.java:35) at org.gradle.initialization.DefaultSettings_Decorated.getAsDynamicObject(Unknown Source) at org.gradle.initialization.SettingsFactory.createSettings(SettingsFactory.java:58) at org.gradle.initialization.ScriptEvaluatingSettingsProcessor.process(ScriptEvaluatingSettingsProcessor.java:61) at org.gradle.initialization.PropertiesLoadingSettingsProcessor.process(PropertiesLoadingSettingsProcessor.java:38) at ...................................................................

 org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:60)at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:32)at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:55)at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:41)at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:48)at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:32)at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:68)at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:39)at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:27)at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:35)at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:78)at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:75)at org.gradle.util.Swapper.swap(Swapper.java:38)at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:75)at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:63)at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82)at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:52)at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)at java.base/java.lang.Thread.run(Thread.java:832)

FAILURE: Build failed with an exception.

  • What went wrong:Could not initialize class org.codehaus.groovy.reflection.ReflectionCache

  • 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 3s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7 at org.codehaus.groovy.vmplugin.VMPluginFactory.(VMPluginFactory.java:43) at org.codehaus.groovy.reflection.GroovyClassValueFactory.(GroovyClassValueFactory.java:35) at org.codehaus.groovy.reflection.ClassInfo.(ClassInfo.java:107) at org.codehaus.groovy.reflection.ReflectionCache.getCachedClass(ReflectionCache.java:95) at org.codehaus.groovy.reflection.ReflectionCache.(ReflectionCache.java:39) at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerMethods(MetaClassRegistryImpl.java:210) at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.(MetaClassRegistryImpl.java:108) at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.(MetaClassRegistryImpl.java:86) at groovy.lang.GroovySystem.(GroovySystem.java:36) at org.codehaus.groovy.runtime.InvokerHelper.(InvokerHelper.java:86) at groovy.lang.GroovyObjectSupport.getDefaultMetaClass(GroovyObjectSupport.java:59) at groovy.lang.GroovyObjectSupport.(GroovyObjectSupport.java:32) at org.gradle.internal.extensibility.DefaultExtraPropertiesExtension.(DefaultExtraPropertiesExtension.java:29) at org.gradle.internal.extensibility.DefaultConvention.(DefaultConvention.java:49) at org.gradle.internal.extensibility.ExtensibleDynamicObject.(ExtensibleDynamicObject.java:60) at org.gradle.internal.instantiation.generator.MixInExtensibleDynamicObject.(MixInExtensibleDynamicObject.java:35) at org.gradle.initialization.DefaultSettings_Decorated.getAsDynamicObject(Unknown Source) at org.gradle.initialization.SettingsFactory.createSettings(SettingsFactory.java:58) at org.gradle.initialization.ScriptEvaluatingSettingsProcessor.process(ScriptEvaluatingSettingsProcessor.java:61) at org.gradle.initialization.PropertiesLoadingSettingsProcessor.process(PropertiesLoadingSettingsProcessor.java:38) at ..................................... org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29) at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:60) at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:32) at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:55) at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:41) at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:48) at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:32) at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:68) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104) at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:39) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104) at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:27) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104) at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:35) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:78) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:75) at org.gradle.util.Swapper.swap(Swapper.java:38) at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:75) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104) at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104) at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:63) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104) at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104) at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:52) at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56) at java.base/java.lang.Thread.run(Thread.java:832)

FAILURE: Build failed with an exception.

  • What went wrong:Could not initialize class org.codehaus.groovy.reflection.ReflectionCache

  • 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 3s

at makeError (/Users/fngo/Reactnative/xxxxx/node_modules/execa/index.js:174:9)at /Users/fngo/Reactnative/xxxxx/node_modules/execa/index.js:278:16at processTicksAndRejections (internal/process/task_queues.js:97:5)at async runOnAllDevices (/Users/fngo/Reactnative/xxxxx/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)at async Command.handleAction (/Users/fngo/Reactnative/xxxxx/node_modules/@react-native-community/cli/build/index.js:186:9)

EdgeLight: Screen borders are not going beyond the notch and softkeys in react native

$
0
0

I am just trying to implement "edge light" Ref in react native.

I have this below code to achieve it.

<Layout style={{ flex: 1, paddingTop: 18, paddingBottom: 18, paddingLeft: 28, paddingRight: 28, borderWidth: 10, borderColor: '#36ABA5', justifyContent: 'center', backgroundColor: '#000', color: '#fff' }}> // All my code </Layout>

This seems to be working fine for the mobiles which are having straigh screens. But I am facing 2 issues,

  1. The same is not working when the mobile has notch or the mobile's softkeys are enabled.
  2. In Honor 8x the border itself is not coming when softkeys are disabled, when those are enabled, the border comes above the softkeys.

I tried calculating the window height, screen height and put the border. It seems to be not happening.

In Straight phone

In Straight phone:

In Notch phone:

In Notch phone:

In Softkeys enabled:

enter image description here

In Softkeys disabled:

In Softkeys disabled:

Wanted similar to this, but not colorful/ Expected Results:

Wanted similar to this, but not colorful/ Expected Results:

{"error": {"extra": -2147483648, "what": 1}} error while playing .mpd dash files in react -native Android

$
0
0

I have used react-native-video to play DRM content with .mpd extension. But it is giving me an error {"error": {"extra": -2147483648, "what": 1}}

My video-player is like :

         onBack={this.goBack}         videoInfo={toJS(videoDetails)}         videoUrl={dashUrl}         source={{           uri: url,           drm: {             type: "widevine",             licenseServer: [licence_server]",              headers: {                customdata: xml,              },            },          }}        />

There is not any error or urls as it is being played in DRM test site.The above video player uses RNVideo so there is also not an issue as it plays other normal mp4 files.What can be the error?Is it a library issue or what?


make Drawer.screen have default header like Stack.screen

$
0
0

I have a side drawer and stack nested but the screens rendered by the drawer do not have a default header like a stack screen. I do not want to create a customer header component so the UI will be uniform across screens

import 'react-native-gesture-handler';import React from 'react';import {NavigationContainer} from '@react-navigation/native';import {createStackNavigator} from '@react-navigation/stack';import Login from '../login/login';import Register from '../register/register';import Welcome from '../welcome/welcome';import ResetPWD from '../register/resetpwd';import RegisterLogin from '../register/registerlogin';import About from '../screens/about';import More from '../screens/more';import Gallery from '../screens/gallery';import Excos from '../screens/excos';import AbuladWebsite from '../screens/abuladwebsite';import LifeInAbu from '../screens/lifeinabu';import {Icon} from 'react-native-elements';import {createDrawerNavigator} from '@react-navigation/drawer';const Stack = createStackNavigator();const Drawer = createDrawerNavigator();function sideDrawer({navigation}) {  return (<NavigationContainer><Drawer.Navigator        drawerContentOptions={{          activeTintColor: '#398f68',          itemStyle: {marginVertical: 8},        }}><Drawer.Screen name="Home" component={homeStack} /><Drawer.Screen name="Gallery" component={Gallery} /><Drawer.Screen name="Life in ABU" component={LifeInAbu} /><Drawer.Screen name="Buy and Sell" component={AbuladWebsite} /><Drawer.Screen name="About" component={About} /><Drawer.Screen name="Excos" component={Excos} /><Drawer.Screen name="More" component={More}/></Drawer.Navigator></NavigationContainer>  );}function homeStack({navigation}) {  return (<Stack.Navigator><Stack.Screen        name="Login"        component={Login}        options={{headerShown: false}}      /><Stack.Screen        name="Register"        component={Register}        options={{headerShown: false}}      /><Stack.Screen        name="ResetPWD"        component={ResetPWD}        options={{headerShown: false}}      /><Stack.Screen        name="RegisterLogin"        component={RegisterLogin}        options={{headerShown: false}}      /><Stack.Screen        name="Welcome"        component={Welcome}        options={{          title: 'Abulad',          headerLeft: () => (<Icon              name="android"              onPress={() => navigation.openDrawer()}              // title="Info"              color="#000"            />          ),        }}      /><Stack.Screen name="sideStack" component={sideDrawer} /></Stack.Navigator>  );}export default sideDrawer;

one of the screens without the default header

I have tried the screenOptions props to no availenter image description here

ReactNative Android - Unable to start activity ComponentInfo After changing Firebase version

$
0
0

It happened After changing the Firebase version.

It doesn't happen on my device, it can only be found in Crashlytics.

Fatal Exception: java.lang.RuntimeExceptionUnable to start activity ComponentInfo{com.myApp /com.myApp.MainActivity}: java.util.ConcurrentModificationExceptionandroid.app.ActivityThread.performLaunchActivity (ActivityThread.java:2957)com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)Caused by java.util.ConcurrentModificationExceptionandroidx.collection.SimpleArrayMap.put (SimpleArrayMap.java:482)androidx.appcompat.app.AppCompatActivity.onCreate (AppCompatActivity.java:106)com.facebook.react.ReactActivity.onCreate (ReactActivity.java:43)com.cotoone.nagizi.MainActivity.onCreate (MainActivity.java:22)android.app.Activity.performCreate (Activity.java:7183)com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)

MainActivity

package com.myApp;import android.os.Bundle;import com.facebook.react.ReactActivity;import com.facebook.react.ReactActivityDelegate;import com.facebook.react.ReactRootView;import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;import org.devio.rn.splashscreen.SplashScreen;public class MainActivity extends ReactActivity {    /**     * Returns the name of the main component registered from JavaScript.     * This is used to schedule rendering of the component.     */    @Override    protected void onCreate(Bundle savedInstanceState) {        SplashScreen.show(this,true);  // here        super.onCreate(savedInstanceState);    }    @Override    protected String getMainComponentName() {        return "test3";    }  @Override  protected ReactActivityDelegate createReactActivityDelegate() {    return new ReactActivityDelegate(this, getMainComponentName()) {     @Override      protected ReactRootView createRootView() {      return new RNGestureHandlerEnabledRootView(MainActivity.this);     }    };  }}

changelog

implementation "com.google.android.gms:play-services-base:16.1.0"implementation "com.google.firebase:firebase-messaging:18.0.0"implementation "com.google.firebase:firebase-ads:17.2.1"

to

implementation "com.google.android.gms:play-services-base:17.2.1"implementation 'com.google.firebase:firebase-messaging:+'implementation "com.google.firebase:firebase-ads:19.1.0"

An error occurred in this state.

I did this with a solution I found by searching.

implementation "com.google.firebase:firebase-core:16.0.8"

to

implementation "com.google.firebase:firebase-core:17.2.0"

But I keep getting the same error.

now Using

implementation "com.google.android.gms:play-services-base:17.2.1"implementation "com.google.firebase:firebase-core:17.2.0"implementation 'com.google.firebase:firebase-messaging:+'implementation "com.google.firebase:firebase-ads:19.1.0"implementation "com.google.firebase:firebase-perf:17.0.2"implementation 'com.google.android.gms:play-services-location:16.0.0'

Android emulator adb error: device still connecting

$
0
0

Has anyone ever seen this behavior: Trying to run my expo react-native app on the Android emulator, however I cannot and get these errors:

WARNING 15:17: Couldn't adb reverse: more than one device/emulatorERROR 15:17: Couldn't start project on Android: Error running adb: more than one device/emulator

After digging further, with the Android emulator opened (no other emulators or external devices connected), I typed the following at the command prompt:

adb devices

and this is what shows up:

List of devices attachedemulator-5554   deviceemulator-5562   connecting

The emulator-5554 device is my Pixel XL, however the emulator-5562 is the mystery device. I do not have any other emulators setup in my AVD Manager nor do I have a physical Android device. I've tried googling all case scenarios and have tried everything suggested in every possible combination to wit:

adb kill-serveradb start-server

after killing the server, then starting the server, I get this message:

* daemon not running; starting now at tcp:5037* daemon started successfully

then I run "adb devices", it shows up as "emulator-5562 connecting" again. I've tried disconnecting the device:

adb disconnectadb -s emulator-5562 disconnect

after running these I get the message: "disconnected everything" which I thought would fix it, but when I kill the server, then run adb devices again, it shows back up "emulator-5562 connecting". I've also tried:

adb forward --remove-alladb reboot

The result after typing adb reboot (if I have my Pixel XL emulator open), is:

error: more than one device/emulator

if no emulators open

error: device still connecting

I've tried deleting all the emulators in my AVD Manager and it still shows up. Is there a way to kill this thing outside of what I've already tried as it's preventing me from testing my app in the Android emulator?

Issues using AndroidX and React Native

$
0
0

I've been trying to integrate AndroidX into my hybrid React Native project, and I've run into the issue that Jetifier doesn't run on "local" projects. This results in all of my React Native libraries still using the old support libraries. I've put the appropriate lines into my gradle.properties file:

android.useAndroidX=trueandroid.enableJetifier=true

This works for any remote libraries, but React Native places all of it's libraries as local modules on disk.

I've tried a lot of things, but so far my best solution is a post package-install script that basically manually replaces all of the packages and add/removes libraries to the various gradle scripts.

This is a very manual process and not super sustainable. Is there a better way to handle this issue?

React Native version Mismatch - Native version: 0.59.5

$
0
0

I am getting this error on Android simulator:

React Native version mismatch:Javascript version: 0.58.5Native version: 0.59.5

I have upgraded React Native, modules, Android studio and pretty much everything i could. Everything works fine on iOS, this happens only on Android. Build is succesful

Package.json

{"name": "MyProject","version": "0.0.1","private": true,"scripts": {"start": "node node_modules/react-native/local-cli/cli.js start","test": "jest"  },"dependencies": {"@react-native-community/async-storage": "^1.3.3","latlon-geohash": "^1.1.0","react": "16.8.3","react-native": "0.59.5","react-native-firebase": "^5.2.3","react-native-gesture-handler": "^1.0.16","react-native-keyboard-aware-scroll-view": "^0.8.0","react-native-linear-gradient": "^2.5.3","react-native-maps": "^0.24.2","react-native-vector-icons": "^6.4.2","react-navigation": "^3.3.2","react-redux": "^6.0.1","redux": "^4.0.1"  },"devDependencies": {"babel-core": "^7.0.0-bridge.0","babel-jest": "24.1.0","jest": "24.1.0","metro-react-native-babel-preset": "0.52.0","react-test-renderer": "16.6.3"  },"jest": {"preset": "react-native"  }}

Build.gradle

buildscript {    ext {        buildToolsVersion = "28.0.3"        minSdkVersion = 16        compileSdkVersion = 28        targetSdkVersion = 28        supportLibVersion = "28.0.0"        googlePlayServicesVersion = "15.0.1"        androidMapsUtilsVersion = "0.5+"    }    repositories {        google()        //mavenLocal()                jcenter()        maven {            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm            url "$rootDir/../node_modules/react-native/android"        }    }    dependencies {        classpath 'com.android.tools.build:gradle:3.3.0'        classpath 'com.google.gms:google-services:4.2.0'    }}allprojects {    repositories {        mavenLocal()        google()        jcenter()        maven {            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm            url "$rootDir/../node_modules/react-native/android"        }    }}/*task wrapper(type: Wrapper) {    gradleVersion = '4.7'    distributionUrl = distributionUrl.replace("bin", "all")}*/   dependencies {        implementation project(':react-native-firebase')        implementation project(':react-native-gesture-handler')        implementation fileTree(dir: "libs", include: ["*.jar"])        implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"        implementation "com.facebook.react:react-native:+"  // From node_modules        implementation project(':react-native-linear-gradient')        implementation project(':react-native-maps')         implementation "com.google.android.gms:play-services-base:16.0.1"        implementation project(':@react-native-community_async-storage')        implementation ("com.google.firebase:firebase-core:16.0.7") {            exclude group: 'com.google.android.gms'        }         implementation ("com.google.firebase:firebase-auth:16.1.0") {            exclude group: 'com.google.android.gms'        }         implementation ("com.google.firebase:firebase-database:16.0.6") {            exclude group: 'com.google.android.gms'        }    }

I have tried closing all terminals, yarn install, creating new android device. I am guessing it has to do with actual version of the React Native in Package.json, but it is the 0.59.5 and when i searched whole project i cant find any reference to 0.58.5 anywhere.

ThanksLuke

Can I build an android app recorder video and sound when a video calls on other Applications like Skype, Zoom?

$
0
0

I want to build an android application can record the video and sound when video calls on other application. It's possible?

React native security Android [closed]

$
0
0

I reverse engineered my react native release signed app, I now can see all js code in index bundle which is only obfuscated not encrypted, in assets directory. I don't want my code to be seen. I reverse engineered one of the app in play store which is made up of react-native but I couldn't see the js bundle. So is it possible to make it secure ? If so how?


Cannot open phone call with Linking.openURL

$
0
0

Description

Cannot open phone call with Linking.openURL('tel:+123456789')

Environment

Environment: OS: macOS High Sierra 10.13.4 Node: 8.5.0 Yarn: Not Found npm: 5.8.0 Watchman: Not Found Xcode: Xcode 9.3 Build version 9E145 Android Studio: 2.3 AI-162.4069837

Packages: (wanted => installed) react: 16.3.1 => 16.3.1 react-native: https://github.com/expo/react-native/archive/sdk-27.0.0.tar.gz => 0.55.2 expo: 27.0.1,

Steps to Reproduce

import ...export default class App extends React.Component {_pressCall=()=>{    const url='tel:+123456789'    Linking.openURL(url)}render() {    return (<View style={styles.container}><Button title='call' onPress={this._pressCall}/></View>    );}}

https://snack.expo.io/@kikoololmdrxdd/test-linking-phone-call

Expected Behavior

open phone call

Actual Behavior

[Android]Error messageattempt to invoke virtual method 'boolean java.lang.string.endsWith(java.lang.String)' on a null object reference

How can I use OnePlus 5t and above version as an Android emulator?

$
0
0

I don't have one plus device to fix the bugs related to it. I couldn't find one emulator in the android studio other than pixel/Google devices.

I am coding in react native.

I have looked around for the answer. help me.

I have a problem when running Android I get this : error Failed to launch emulator. Reason

$
0
0

I have a problem when running Android I get this error :error Failed to launch emulator. Reason: Emulator exited before boot..I did all the solutions that I read from this site and it was not usefulPlease Help!enter image description here

Access to screen height depending on the device

$
0
0

Below are various situations with the screen on the phone:

  • with Android navigation bar (bottom black bar)

  • without Android navigation bar (bottom black bar)

  • with notches (small and large)

  • without notches (small and large)

enter image description here

How can I access the height in red?

I am currently trying to use:

react-native-responsive-screen

But it doesn't always work well. When I test on the screen with notches it is OK but when I test on another device, the height does not match

When I do something on the device without Android navigation bar, when I run the application on the phone with this bar it covers part

Stream screen react native using MediaRecorder

$
0
0

I can not find any package to stream what the user is doing out of the application with react native.

I am creating my own plugin

The goal is to send a stream from java to javascript to then send it an external socket server via socket.io

This is my java class to ask authorization and stream

import android.hardware.display.DisplayManager;import android.util.DisplayMetrics;import android.app.Activity;import android.content.Intent;import android.media.projection.MediaProjectionManager;import android.media.projection.MediaProjection;import android.media.MediaRecorder;import android.util.Log;import com.facebook.react.bridge.ReactApplicationContext;import com.facebook.react.bridge.ReactContextBaseJavaModule;import com.facebook.react.bridge.ReactMethod;import com.facebook.react.bridge.Promise;import com.facebook.react.bridge.ActivityEventListener;import com.facebook.react.bridge.BaseActivityEventListener;import static android.content.Context.MEDIA_PROJECTION_SERVICE;public class ScreenMirroringModule extends ReactContextBaseJavaModule {    private static final int SCREEN_SHARE_REQUEST = 4242;    private static final String S_MIRROR_CANCELLED = "S_MIRROR_CANCELLED";    private Promise sMirrorPromise;    private MediaProjectionManager mMediaProjectionManager;    private MediaStreamer mMediaStreamer = new MediaStreamer();    private final ActivityEventListener mActivityEventListener = new BaseActivityEventListener() {        @Override        public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent intent) {            if (requestCode == SCREEN_SHARE_REQUEST) {                if (sMirrorPromise != null) {                    if (resultCode == Activity.RESULT_CANCELED) {                        sMirrorPromise.reject(S_MIRROR_CANCELLED, "Screen mirroring was cancelled");                    } else if (resultCode == Activity.RESULT_OK) {                        DisplayMetrics dm = new DisplayMetrics();                        activity.getWindowManager().getDefaultDisplay().getMetrics(dm);                        mMediaStreamer.reset();                        mMediaStreamer.setVideoSource(MediaRecorder.VideoSource.SURFACE);                        mMediaStreamer.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);                        mMediaStreamer.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);                        mMediaStreamer.setVideoSize(dm.widthPixels, dm.heightPixels);                        mMediaStreamer.setVideoFrameRate(30);                        StreamTask st =  new StreamTask();                        st.execute(mMediaStreamer);                        try {                            st.get();                        } catch (Exception e) {                            sMirrorPromise.reject(e);                        }                        MediaProjection mMediaProjection = mMediaProjectionManager.getMediaProjection(resultCode, intent);                        try {                            mMediaProjection.createVirtualDisplay("MainActivity",                                    dm.widthPixels, dm.heightPixels, dm.densityDpi,                                    DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,                                    mMediaStreamer.getSurface(), null /*Callbacks*/, null/*Handler*/);                            mMediaStreamer.start();                        } catch (Exception e) {                            //Log.v("ReactNative", Log.getStackTraceString(e));                            sMirrorPromise.reject(e);                        }                        sMirrorPromise.resolve("Test");                    }                }                sMirrorPromise = null;            }        }    };    public ScreenMirroringModule(ReactApplicationContext reactContext) {        super(reactContext);        // Add the listener for `onActivityResult`        reactContext.addActivityEventListener(mActivityEventListener);    }    @Override    public String getName() {        return "ScreenMirroring";    }    @ReactMethod    public void stream(String ip, int port, Promise promise) {        final Activity activity = getCurrentActivity();        // Store the promise to resolve/reject when picker returns data        sMirrorPromise = promise;        mMediaProjectionManager = (MediaProjectionManager) activity.getSystemService(MEDIA_PROJECTION_SERVICE);        Intent intent = mMediaProjectionManager.createScreenCaptureIntent();        activity.startActivityForResult(intent, SCREEN_SHARE_REQUEST);    }}

This is my class which is transforming the recording into a stream

package com.ijkoareactapp;import android.media.MediaRecorder;import android.net.LocalServerSocket;import android.net.LocalSocket;import android.net.LocalSocketAddress;import android.util.Log;import java.io.IOException;import java.io.InputStream;public class MediaStreamer extends MediaRecorder {    private LocalServerSocket localServerSocket = null;    private LocalSocket receiver, sender = null;    public void prepare() throws IllegalStateException, IOException {        receiver = new LocalSocket();        try {            localServerSocket = new LocalServerSocket("screen_mirror_socket");            receiver.connect(new LocalSocketAddress("screen_mirror_socket"));            receiver.setReceiveBufferSize(4096);            receiver.setSendBufferSize(4096);            sender = localServerSocket.accept();            sender.setReceiveBufferSize(4096);            sender.setSendBufferSize(4096);        } catch (Exception e) {            throw new IOException("Can't create local socket !");        }        setOutputFile(sender.getFileDescriptor());        try {            super.prepare();        } catch (Exception e) {            Log.v("ReactNative", Log.getStackTraceString(e));            closeSockets();            throw e;        }    }    public InputStream getInputStream() {        InputStream out = null;        try {            out = receiver.getInputStream();        } catch (IOException e) {        }        return out;    }    public void stop() {        closeSockets();        super.stop();    }    private void closeSockets() {        if (localServerSocket != null) {            try {                localServerSocket.close();                sender.close();                receiver.close();            } catch (IOException e) {            }            localServerSocket = null;            sender = null;            receiver = null;        }    }}

And this is the class which is running the task in background because I can not start a local socket in main process

package com.ijkoareactapp;import android.os.AsyncTask;import android.util.Log;public class StreamTask extends AsyncTask <MediaStreamer, Integer, Long>{    protected Long doInBackground(MediaStreamer... mediaStreamers) {        Log.v("ReactNative", "Start");        for(int i = 0; i < mediaStreamers.length; i++) {            try {                mediaStreamers[i].prepare();                Log.v("ReactNative", "Prepared");            } catch (Exception e) {                Log.v("ReactNative", "Error");                Log.v("ReactNative", Log.getStackTraceString(e));            }        }        return null;    }}

The error I have is

08-05 15:28:49.465   555   571 V ReactNative: java.lang.IllegalStateException08-05 15:28:49.465   555   571 V ReactNative:   at android.media.MediaRecorder._prepare(Native Method)08-05 15:28:49.465   555   571 V ReactNative:   at android.media.MediaRecorder.prepare(MediaRecorder.java:827)08-05 15:28:49.465   555   571 V ReactNative:   at com.ijkoareactapp.MediaStreamer.prepare(MediaStreamer.java:37)08-05 15:28:49.465   555   571 V ReactNative:   at com.ijkoareactapp.StreamTask.doInBackground(StreamTask.java:14)08-05 15:28:49.465   555   571 V ReactNative:   at com.ijkoareactapp.StreamTask.doInBackground(StreamTask.java:6)08-05 15:28:49.465   555   571 V ReactNative:   at android.os.AsyncTask$2.call(AsyncTask.java:304)08-05 15:28:49.465   555   571 V ReactNative:   at java.util.concurrent.FutureTask.run(FutureTask.java:237)08-05 15:28:49.465   555   571 V ReactNative:   at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)08-05 15:28:49.465   555   571 V ReactNative:   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)08-05 15:28:49.465   555   571 V ReactNative:   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)08-05 15:28:49.465   555   571 V ReactNative:   at java.lang.Thread.run(Thread.java:761)

Reading some documentation it seems that prepare is called before start or after setOutputFormat but this is not the case.

I think that my internal socket connection is not well initialized but I can not find the right way to do it.

As well not sure where should I put the mMediaProjection.createVirtualDisplay, at the moment I have the follwing error should be because the prepare does not works

08-05 15:43:36.077  1575  1575 V ReactNative: java.lang.IllegalStateException: failed to get surface08-05 15:43:36.077  1575  1575 V ReactNative:   at android.media.MediaRecorder.getSurface(Native Method)08-05 15:43:36.077  1575  1575 V ReactNative:   at com.ijkoareactapp.ScreenMirroringModule$1.onActivityResult(ScreenMirroringModule.java:65)08-05 15:43:36.077  1575  1575 V ReactNative:   at com.facebook.react.bridge.ReactContext.onActivityResult(ReactContext.java:262)08-05 15:43:36.077  1575  1575 V ReactNative:   at com.facebook.react.ReactInstanceManager.onActivityResult(ReactInstanceManager.java:703)08-05 15:43:36.077  1575  1575 V ReactNative:   at com.facebook.react.ReactActivityDelegate.onActivityResult(ReactActivityDelegate.java:124)08-05 15:43:36.077  1575  1575 V ReactNative:   at com.facebook.react.ReactActivity.onActivityResult(ReactActivity.java:75)08-05 15:43:36.077  1575  1575 V ReactNative:   at android.app.Activity.dispatchActivityResult(Activity.java:6915)08-05 15:43:36.077  1575  1575 V ReactNative:   at android.app.ActivityThread.deliverResults(ActivityThread.java:4049)08-05 15:43:36.077  1575  1575 V ReactNative:   at android.app.ActivityThread.handleSendResult(ActivityThread.java:4096)08-05 15:43:36.077  1575  1575 V ReactNative:   at android.app.ActivityThread.-wrap20(ActivityThread.java)08-05 15:43:36.077  1575  1575 V ReactNative:   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1516)08-05 15:43:36.077  1575  1575 V ReactNative:   at android.os.Handler.dispatchMessage(Handler.java:102)08-05 15:43:36.077  1575  1575 V ReactNative:   at android.os.Looper.loop(Looper.java:154)08-05 15:43:36.077  1575  1575 V ReactNative:   at android.app.ActivityThread.main(ActivityThread.java:6077)08-05 15:43:36.077  1575  1575 V ReactNative:   at java.lang.reflect.Method.invoke(Native Method)08-05 15:43:36.077  1575  1575 V ReactNative:   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)08-05 15:43:36.077  1575  1575 V ReactNative:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Viewing all 28463 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>