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

Get user id in play store review

$
0
0

Is it possible to attach a user's in app user Id or some other identifying information to play store reviews. I am using react native.

Despite having a function within our app for sending feedback users tend to instead just leave negative feedback on the play store.

The problem there is that I don't have their user Id so despite having all the tools to check what happened to an individual user, I have no idea which user to look at.


Android splash screen doesn't hide using react native

$
0
0

My splash stays open and doesn't hide. Using RN 62.2, previous versions of RN I didn't have to manually hide the screen.

How can I hide my splash screen without adding any code in componentDidMount?

AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" /><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|screenSize|uiMode"    android:launchMode="singleTask"    android:windowSoftInputMode="adjustResize"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity><activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /></application>

layout/launch_screen.xml

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical" android:layout_width="match_parent"    android:layout_height="match_parent"><ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/launch_screen" android:scaleType="centerCrop" /></RelativeLayout>

MainActivity.java:

package com.ceipapp;import com.facebook.react.ReactActivity;import org.devio.rn.splashscreen.SplashScreen;import android.os.Bundle;public class MainActivity extends ReactActivity {  /**   * Returns the name of the main component registered from JavaScript. This is used to schedule   * rendering of the component.   */      protected void onCreate(Bundle savedInstanceState)    {        SplashScreen.show(this);  // here        super.onCreate(savedInstanceState);    }  @Override  protected String getMainComponentName() {    return "ceipApp";  }}

removing specific library from app build in react native

$
0
0

I am using storybook library in my react native application but only for development proposesI would like to delete the bundle completely in production from the build folder

my package.jsonthis is how my devDependencies look like

"devDependencies": {    ....."@storybook/addon-actions": "^5.3.14","@storybook/addon-links": "^5.3.14","@storybook/addons": "^5.3.14","@storybook/react-native": "^5.3.14","@storybook/react-native-server": "^5.3.14",......}

and this is in the script

"scripts": {  ...."storybook": "start-storybook -p 7007",....}

any ideas how to do that ?thank you

Recorded AAC audio in Android does not play on iOS devices

$
0
0

AAC audio recorded in Android is not playing on iOS devices. Here is the code example of how we are recording audio in Android devices. When we try to play that audio in an iOS device using react-native-sound, it does not play on iOS device and getting an error as below.

Failed to load the soundand iOS exception read as below.

Objectcode: "ENSOSSTATUSERRORDOMAIN1937337955"domain:"NSOSStatusErrorDomain"message: "The operation couldn't be completed.(OSStatus error 1937337955.)"nativeStackIOS: Array[17]userInfo:Object__proto__: Object

AudioRecorder.prepareRecordingAtPath('/path/to/audio/test.aac', {        SampleRate: 22050,        Channels: 1,        AudioQuality: "Low",        AudioEncoding: "aac",        AudioEncodingBitRate: 32000});

We are using RN 0.41 and react-native-audio 3.2.1

Did anyone face similar issue? let me know if there is any misconfiguration.

TypeError: Cannot read property 'bind' of undefined (evaluating 'this._callListeners.bind')

$
0
0

My React Native app don't work anymore. I had babel package and now, she doesn't work.

I've got this error :

Error I get

I try to clean cash and other things, but nothing works.

White screen issue react native during recyclerlistview scroll

$
0
0

during or after scroll, when new data are being rendered then there are some blank spaces issue and for milliseconds the screen also becomes white.

I am using this awsesome list view pkg: https://www.npmjs.com/package/recyclerlistview

the only issue i am facing is white screen.Does anybody have any fix for this ?

Error: constructor ModuleRegistryAdapter in class ModuleRegistryAdapter cannot be applied to given types, new ModuleRegistryAdapter()

$
0
0

Hello im getting the fallowing error on console:

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081/Users/user/Desktop/.../android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:82: error: constructor ModuleRegistryAdapter in class ModuleRegistryAdapter cannot be applied to given types;      new ModuleRegistryAdapter(),      ^  required: ReactModuleRegistryProvider  found:    no arguments  reason: actual and formal argument lists differ in length1 errorFAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':app: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.

on android studio:

/Users/username/.../project_name/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:82: error: constructor ModuleRegistryAdapter in class ModuleRegistryAdapter cannot be applied to given types;      new ModuleRegistryAdapter(),      ^  required: ReactModuleRegistryProvider  found: no arguments  reason: actual and formal argument lists differ in length

"react-native": "~0.61.5","react-native-unimodules": "^0.9.1",

It seems a recent react-native-unimodules bug on android, any solutions?this is the same error:https://www.gitmemory.com/issue/unimodules/react-native-unimodules/58/530738183

React Native App Works Fine In Debug Apk But Crashes After Apk Released On Device

$
0
0

i have created a release apk for a react native app ,i tried to get log by running adb logcatit shows i have used some hooks outside functional components, but i have checked all components and everthing is fine. No errors during builds or while running the debug app

06-24 18:38:59.282   927   927 E WifiTrafficPoller: TRAFFIC_STATS_POLL true Token 126 nu  clients 1506-24 18:38:59.283   927   927 E WifiTrafficPoller:  packet count Tx=181157 Rx=302169     06-24 18:38:59.881 23020 23065 E ReactNativeJS: Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:06-24 18:38:59.881 23020 23065 E ReactNativeJS: 1. You might have mismatching versions of React and the renderer (such as React DOM)06-24 18:38:59.881 23020 23065 E ReactNativeJS: 2. You might be breaking the Rules of Hooks06-24 18:38:59.881 23020 23065 E ReactNativeJS: 3. You might have more than one copy of React in the same app06-24 18:38:59.881 23020 23065 E ReactNativeJS: See react-invalid-hook-call for tips about how to debug and fix this problem.06-24 18:38:59.881 23020 23065 E ReactNativeJS:06-24 18:38:59.881 23020 23065 E ReactNativeJS: This error is located at:06-24 18:38:59.881 23020 23065 E ReactNativeJS:     in oe06-24 18:38:59.881 23020 23065 E ReactNativeJS:     in RNCSafeAreaProvider06-24 18:38:59.881 23020 23065 E ReactNativeJS:     in Unknown06-24 18:38:59.881 23020 23065 E ReactNativeJS:     in Unknown06-24 18:38:59.881 23020 23065 E ReactNativeJS:     in GestureHandlerRootView06-24 18:38:59.881 23020 23065 E ReactNativeJS:     in Unknown06-24 18:38:59.881 23020 23065 E ReactNativeJS:     in Unknown06-24 18:38:59.881 23020 23065 E ReactNativeJS:     in Unknown06-24 18:38:59.881 23020 23065 E ReactNativeJS:     in Unknown06-24 18:38:59.881 23020 23065 E ReactNativeJS:     in ForwardRef06-24 18:38:59.881 23020 23065 E ReactNativeJS:     in Unknown06-24 18:38:59.881 23020 23065 E ReactNativeJS:     in ForwardRef06-24 18:38:59.881 23020 23065 E ReactNativeJS:     in RCTView06-24 18:38:59.881 23020 23065 E ReactNativeJS:     in l06-24 18:38:59.881 23020 23065 E ReactNativeJS:     in Styled(l)06-24 18:38:59.881 23020 23065 E ReactNativeJS:     in _06-24 18:38:59.881 23020 23065 E ReactNativeJS:     in RCTView06-24 18:38:59.881 23020 23065 E ReactNativeJS:     in RCTView06-24 18:38:59.881 23020 23065 E ReactNativeJS:     in C06-24 18:38:59.900 23020 23065 E ReactNativeJS: Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:06-24 18:38:59.900 23020 23065 E ReactNativeJS: 1. You might have mismatching versions of React and the renderer (such as React DOM)06-24 18:38:59.900 23020 23065 E ReactNativeJS: 2. You might be breaking the Rules of Hooks06-24 18:38:59.900 23020 23065 E ReactNativeJS: 3. You might have more than one copy of React in the same app06-24 18:38:59.900 23020 23065 E ReactNativeJS: See /react-invalid-hook-call for tips about how to debug and fix this problem.06-24 18:38:59.900 23020 23065 E ReactNativeJS:06-24 18:38:59.900 23020 23065 E ReactNativeJS: This error is located at:06-24 18:38:59.900 23020 23065 E ReactNativeJS:     in oe06-24 18:38:59.900 23020 23065 E ReactNativeJS:     in RNCSafeAreaProvider06-24 18:38:59.900 23020 23065 E ReactNativeJS:     in Unknown06-24 18:38:59.900 23020 23065 E ReactNativeJS:     in Unknown06-24 18:38:59.900 23020 23065 E ReactNativeJS:     in GestureHandlerRootView06-24 18:38:59.900 23020 23065 E ReactNativeJS:     in Unknown06-24 18:38:59.900 23020 23065 E ReactNativeJS:     in Unknown06-24 18:38:59.900 23020 23065 E ReactNativeJS:     in Unknown06-24 18:38:59.900 23020 23065 E ReactNativeJS:     in Unknown06-24 18:38:59.900 23020 23065 E ReactNativeJS:     in ForwardRef06-24 18:38:59.900 23020 23065 E ReactNativeJS:     in Unknown06-24 18:38:59.900 23020 23065 E ReactNativeJS:     in ForwardRef06-24 18:38:59.900 23020 23065 E ReactNativeJS:     in RCTView06-24 18:38:59.900 23020 23065 E ReactNativeJS:     in l06-24 18:38:59.900 23020 23065 E ReactNativeJS:     in Styled(l)06-24 18:38:59.900 23020 23065 E ReactNativeJS:     in _06-24 18:38:59.900 23020 23065 E ReactNativeJS:     in RCTView06-24 18:38:59.900 23020 23065 E ReactNativeJS:     in RCTView06-24 18:38:59.900 23020 23065 E ReactNativeJS:     in C

Creating APK issue React Native with Expo

$
0
0

Hi I started learning react native with expo.

Writing code and using it fastly with my phone, it works well.One thing is not well for me is creating apk. I searched and found "expo build:android" to create apk.It creates but takes long.Also giving error when try to install the apk like

"You may not have proper app for viewing this content apk" and the apk size is "45mb".How can I create apk with less size and time.

Thank you

The app.json

{"expo": {"name": "Some App","slug": "some-app","platforms": ["ios","android","web"    ],"version": "1.0.0","orientation": "portrait","icon": "./assets/icon.png","splash": {"image": "./assets/splash.png","resizeMode": "contain","backgroundColor": "#ffffff"    },"updates": {"fallbackToCacheTimeout": 0    },"assetBundlePatterns": ["**/*"    ],"ios": {"supportsTablet": true    },"android": {"package": "com.myapprandomname.myapprandomname"    },"description": ""  }}

package.json

{"main": "node_modules/expo/AppEntry.js","scripts": {"start": "expo start","android": "expo start --android","ios": "expo start --ios","web": "expo start --web","eject": "expo eject"  },"dependencies": {"expo": "~37.0.3","react": "~16.9.0","react-dom": "~16.9.0","react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz","react-native-web": "~0.11.7"  },"devDependencies": {"babel-preset-expo": "~8.1.0","@babel/core": "^7.8.6"  },"private": true}

I can't create apk

How do I receive query parameters from Firebase Dynamic Links using react-native-firebase?

$
0
0

I've followed the instructions from the official react-native-firebase documentation and everything, as per the instructions, works fine.

It is my understanding that I should be able to create a link like the following in the Firebase Dynamic Links console: https://myapp.page.link/offer?offerid=123456 and be able to receive the offerid parameter in my app. However, when I click that link (in the iOS simulator, Android emulator, and on a real device) the app opens, but I just get a link with the following data:

Received initial link {"minimumAppVersion": null, "url": "https://mysite.co/offers"}

There are no query string parameters attached. Am I missing something in the Firebase Dynamic Link configuration? Or in my implementation of react-native-firebase that was not covered in the documentation linked above? Or is this actually just not possible?

Getting error when running Android simulator, RN powerd with expo

$
0
0

I am getting an error when I run npm run

Execution failed for task ':unimodules-core:compileDebugJavaWithJavac'.

I have done all of the steps shown in other Stackoverflow posts.

my App.json looks like this

"expo": {"name": "Unit","slug": "UNIT","privacy": "public","sdkVersion": "36.0.0","platforms": ["ios", "android", "web"],"version": "1.1.1","orientation": "portrait","icon": "./assets/icon.png","splash": {"image": "./assets/splash.png","resizeMode": "contain","backgroundColor": "#ffffff"    },"updates": {"fallbackToCacheTimeout": 0    },"assetBundlePatterns": ["**/*"],"ios": {"supportsTablet": true,"bundleIdentifier": "com.unitvpm.unit"    },"android": {"package": "com.unitvpm.unit","versionCode": 2    },"entryPoint": "node_modules/expo/AppEntry.js"  },"displayName": "Unit","name": "Unit"}

I also added implementation "com.facebook.react:react-native:0.61.5" to /android/app/build.gradle file

I have no idea what else I need to do. Please help.

Android Splash Screen shifts

$
0
0

I have an Android Splash Screen which renders a drawable. When it is opened via a cold start, I find that my asset simply shifts in an upward direction.

You can find the appropriate code below, all unnecessary code has been omitted.

Here's the slight shift:

enter image description here

SplashActivity.java

public class SplashActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        Intent intent = new Intent(this, MainActivity.class);        startActivity(intent);        finish();    }}

MainActivity.java

@Overrideprotected void onCreate(Bundle savedInstanceState) {    SplashScreen.show(this, R.style.SplashTheme);    super.onCreate(savedInstanceState);}

res/drawable/background_splash.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque"><item android:drawable="@color/splash_background_color"/><item        android:gravity="center"><bitmap            android:src="@drawable/x150"/></item></layer-list>

res/layout/launch_screen.xml

<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:background="@color/splash_background_color"><ImageView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_gravity="center"        android:src="@drawable/background_splash"        /></FrameLayout>

res/values/styles.xml

<resources><!-- Base application theme. --><style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"><!-- Customize your theme here. --></style><style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar"><item name="android:windowBackground">@drawable/background_splash</item></style></resources>

KeyboArdavoidingView React Native Android Error

$
0
0

There's no way my KeyboardAV works, how i solve it?

I tried to put the KeyboardAV anywhere, but keep changing nothing about the elements, i'd like just putting my elements up when the user press some textInput.

I'm using React Native CLI, Android.

My code:

<KeyboardAvoidingView behavior="padding" style={styles.container}><DismissKeyboard><View style={styles.backgroundContainer}><StatusBar hidden={true}/><View style={styles.logoContainer}><Image                    source={require('../assets/icon2.png')}                    style={{width: 220, height: 220}}                /></View><View style={styles.inputContainer}><TextInput                    placeholder="EMAIL"                    placeholderTextColor='#555555'                    underlineColorAndroid='#4da5ff'                    style={styles.input}                    onChangeText={handleChange('email')}                    value={values.email}                    onBlur={() => setFieldTouched('email')}                />                {touched.email && errors.email &&<Text style={{ fontSize: 10, color: 'red', marginLeft: 2 }}>{errors.email}</Text>            }</View><View style={styles.inputContainer}><TextInput                    placeholder="SENHA"                    placeholderTextColor='#555555'                    underlineColorAndroid='#4da5ff'                    secureTextEntry={showPass}                    style={styles.input}                    onChangeText={handleChange('senha')}                    onBlur={() => setFieldTouched('senha')}                    value={values.senha}                    />                {touched.senha && errors.senha &&<Text style={{ fontSize: 10, color: 'red', marginLeft:2 }}>{errors.senha}</Text>            }<TouchableOpacity style={styles.btnEye}                                  onPress={() => showPassToggle()}><Icon name={press == false ?  'ios-eye' : 'ios-eye-off' } size={26} color={'rgba(0, 0, 0, 0.5)'}/></TouchableOpacity><TouchableOpacity><Text style={styles.SenhaForg}>Esqueci minha conta!</Text></TouchableOpacity></View><TouchableOpacity style={styles.btnLogin}                            onPress={() => handleSubmit()}                            disabled={!isValid}><Text style={styles.text}>Entrar</Text></TouchableOpacity>            {                loading ?<View style={styles.viewLoading}><ActivityIndicator size="large" color="#4da5ff"/></View>                    :<View style={{display:'none'}}></View>            }</View></DismissKeyboard></KeyboardAvoidingView>

My style:

backgroundContainer:{        height:900,        alignItems: 'center',        width: null,        backgroundColor: '#fff'    },    logoContainer:{        alignItems: 'center',        marginBottom: 50,        marginTop: 40    },    inputContainer:{        marginTop: 10    },      input:{        width: WIDTH - 55,        height: 55,        fontSize: 16,        paddingLeft: 5,        paddingBottom: 24 ,        color: 'black',    },    btnEye:{        position: 'absolute',        top: 0,        right: 15,    },    SenhaForg:{        textAlign: 'right',        color: '#555555',        opacity: 0.7,        textTransform: 'uppercase',        marginRight: 9    },    btnLogin:{        width: WIDTH - 55,        height: 45,        borderRadius: 25,        backgroundColor: '#fff',        justifyContent: 'center',        marginTop: 90,        borderColor: '#4da5ff',        borderWidth: 0.4    },    text:{        color: '#555555',        fontSize: 16,        textAlign: 'center',        textTransform: 'uppercase',    },    viewLoading:{        display:"flex",        flex:1,        backgroundColor:'#fff',        position: 'absolute',        left: 0,        right: 0,        top: 0,        bottom: 0,        alignItems: 'center',        justifyContent: 'center'    }

How it is being showed:

Without Keyboard

With Keyboard

How to implement checkbox in FlatList React Native

$
0
0

I'm trying to implement checkbox while fetching the data API from the backend but the issue that i encountered is that all the checkbox are checked and i'm unable to uncheck it and also how can i pass the selected checked checkbox as a params to the next component.Hope I could get some help.

This is what i have in my current codes;

 class Gifts extends Component {    constructor(props){      super(props);      this.state={        users:'',        checked: {},        selected: 0      }    }

//api codes//handle checkbox

  handleChange = (index) => {    let { checked } = this.state;    checked[index] = !checked[index];    this.setState({ checked });  }  onPress(value) {    this.setState({ selected: value });}  render() {    let { navigation } = this.props        return (<SafeAreaView style={{flex:1 }}><View style={{ flex:1,justifyContent: 'center'}}>               //...codes..//<View style={styles.userlist}><FlatList                            data={this.state.users}                            keyExtractor={(item ,index) => index.toString()}                            renderItem={({ item }) => (<FlatList                                  data={item.friendList}                                  renderItem={({ item }) => <View style= {{flexDirection:'row', justifyContent:'space-between'}}><Text style={{marginTop:20, marginLeft:10, fontSize: 20}}>{item.name}</Text><CheckBox                                      center                                      checkedIcon='dot-circle-o'                                      uncheckedIcon='circle-o'                                      checked={this.state.checked}                                      value={ this.state.checked[item.flag]}                                      onPress={this.onPress}                                    /> </View>                                }                                  keyExtractor={(item ,index) => index.toString()}                                  ItemSeparatorComponent ={this.ItemSeparator}                                />                            )}                    /></View><Button                   rounded                  // disabled={true}                    //onPress={}                  style={{width: 100, justifyContent: 'center',marginLeft:150}}><Text>Send</Text></Button></View></SafeAreaView>    );  }}

What are the correct and compatible version to mention in build.gradle?

$
0
0

I am experiencing some issues, which I guess because of incompatibility of version with react native

React native Version"react-native": "0.62.2",

build.gradle

ext {    buildToolsVersion = "29.0.2"    minSdkVersion = 21    compileSdkVersion = 29    targetSdkVersion = 29    supportLibVersion = "28.0.0"    googlePlayServicesVersion = "12.0.1"    googlePlayServicesVisionVersion = "15.0.2"    androidMapsUtilsVersion = "16.1.0"}dependencies {    classpath 'com.android.tools.build:gradle:3.6.3'    classpath 'com.google.gms:google-services:4.3.3'  // Google Services plugin    classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'    classpath 'com.google.firebase:perf-plugin:1.3.1'    // NOTE: Do not place your application dependencies here; they belong    // in the individual module build.gradle files}

Can anyone share compatible version


Android "Could not get BatchedBridge, make sure your bundle is packaged properly"

$
0
0

I am running the codes here http://rationalappdev.com/react-native-list-app-complete-how-to-guide/, but got the error Could not get BatchedBridge, make sure your bundle is packaged properly".

I searched and tried lots of methods, but still got the error. e.g.In on terminal, run react-native start --reset-cacheIn the other terminal, run react-native run-android

My android is ASUS_X008DC - 7.0.

Thanks

RN app does not build after expo-task-manager installation

$
0
0

My app ran fine until the expo-task-manager installation. The IOS app builds and works as expected, tasks are created and work as they should. After getting IOS to work I switched to android but unfortunately the app doesn't build anymore.

node_modules/react-native-unimodules/node_modules/@unimodules/react-native-adapter/android/src/main/java/org/unimodules/adapters/react/ReactAdapterPackage.java:29: error: cannot find symbol AppLoaderProvider.registerLoader(context, "react-native-headless", RNHeadlessAppLoader.class);

The arrow to indicate the error is placed on the dot between AppLoaderProvider.registerLoader.

Reverting back to before the expo-task-manager was installed gets the app working 100% so the problem is directly related. The app is ejected btw.

I already updated react-native-unimodules but that was not the fix.

rn version; 0.62.2expo-task-manager: 8.3.0expo: 35.0.0react-native-unimodules: ^0.9.1

Does anyone know how I can get the android app to build?

How to solve the error, Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds` in React native?

$
0
0

I am creating react native app for mobile application. I am fully new in building react native app. I am using ubuntu for creating the app and following below link to create the app.https://facebook.github.io/react-native/docs/getting-started . Can anyone please solve the issue ?

At below stage I am getting error:

cd AwesomeProjectnpx react-native run-android

Error in my command line:

All-Series:~/Projects_App/AwesomeProject$ npx react-native run-androidinfo Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.Jetifier found 864 file(s) to forward-jetify. Using 4 workers...info Starting JS server.../bin/sh: 1: adb: not foundinfo Launching emulator...error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.info Installing the app...> Task :app:compileDebugJavaWithJavac FAILEDDeprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.Use '--warning-mode all' to show the individual deprecation warnings.See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings13 actionable tasks: 4 executed, 9 up-to-dateFAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':app:compileDebugJavaWithJavac'.> Could not find tools.jar. Please check that /usr/lib/jvm/java-8-openjdk-amd64 contains a valid JDK installation.* 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.orgBUILD FAILED in 5serror Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081FAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':app:compileDebugJavaWithJavac'.> Could not find tools.jar. Please check that /usr/lib/jvm/java-8-openjdk-amd64 contains a valid JDK installation.* 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.orgBUILD FAILED in 5s    at checkExecSyncError (child_process.js:621:11)    at execFileSync (child_process.js:639:15)    at runOnAllDevices (/home/rupeevest/Projects_App/AwesomeProject/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)    at processTicksAndRejections (internal/process/task_queues.js:93:5)

React Native - Native Base Footer not change color

$
0
0

Here is the code:

 // Bottom.js<StyleProvider style={getTheme(commonColor)}><Footer><FooterTab><Button active><Icon active name="food" size={24}  /><Text active>Lunch Box</Text></Button><Button><Icon name="coins" size={24} /><Text>Point</Text></Button><Button><Icon name="face" size={24} /><Text>Profile</Text></Button></FooterTab></Footer></StyleProvider>// commonColor.js// FooterfooterHeight: 55,footerDefaultBg: '#ffffff',// FooterTabtabBarTextColor: '#FFF',tabBarTextSize: platform === 'ios' ? 14 : 16,activeTab: platform === 'ios' ? '#007aff' : '#fff',sTabBarActiveTextColor: '#007aff',tabBarActiveTextColor: '#fff',tabActiveBgColor: platform === 'ios' ? '#1569f4' : '#1569f4',

here is the result:Result

I've tried edit FooterTab.js directly but no changed at all.

The only changes that can happen on render is tabActiveBgColor: platform === 'ios' ? '#1569f4' : '#1569f4'. And I don't even know why only this code is working, I not even set any active on FooterTab.

What I expected is when I set active the button and text become white.

Any Solution?

Exceptions with ReactNative and AndroidX

$
0
0

I am trying to integrate React-Native into my existing Android project and I see the exception below. I have followed all the steps written here.

There is nothing I can find online after hours of searching.

Here is the full exception log:

 java.lang.ClassCastException: com.example.myapplication.ReactActivity cannot be cast to androidx.fragment.app.FragmentActivity    at com.facebook.react.modules.dialog.DialogModule.getFragmentManagerHelper(DialogModule.java:245)    at com.facebook.react.modules.dialog.DialogModule.onHostResume(DialogModule.java:177)    at com.facebook.react.bridge.ReactContext$1.run(ReactContext.java:174)    at android.os.Handler.handleCallback(Handler.java:873)    at android.os.Handler.dispatchMessage(Handler.java:99)    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)    at android.os.Looper.loop(Looper.java:193)    at android.app.ActivityThread.main(ActivityThread.java:6669)    at java.lang.reflect.Method.invoke(Native Method)    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Here is the screenshot

enter image description here

I just have an native activity that has a button that redirects me to my ReactActivity which is exactly the same as mentioned in the integration guide above. Any help is appreciated!

MainActivity Code:

import android.app.Activity;import android.content.Intent;import android.net.Uri;import android.os.Build;import android.os.Bundle;import android.provider.Settings;import android.view.View;import android.widget.Button;import android.widget.Toast;public class MainActivity extends Activity {private static final int OVERLAY_PERMISSION_REQ_CODE = 1212;@Overrideprotected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.activity_main);    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {        if (!Settings.canDrawOverlays(this)) {            Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,                    Uri.parse("package:"+ getPackageName()));            startActivityForResult(intent, OVERLAY_PERMISSION_REQ_CODE);        }    }    Button button = findViewById(R.id.button);    button.setOnClickListener(new View.OnClickListener() {        @Override        public void onClick(View view) {            goToReactActivity();        }    });}private void goToReactActivity() {    Intent intent = new Intent(this, ReactActivity.class);    startActivity(intent);}@Overrideprotected void onActivityResult(int requestCode, int resultCode, Intent data) {    if (requestCode == OVERLAY_PERMISSION_REQ_CODE) {        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {            if (!Settings.canDrawOverlays(this)) {                Toast.makeText(this,"You cannot open the React Native app as you have denied the permission",                        Toast.LENGTH_SHORT).show();            }        }    }}}

ReactActivity Code:

import android.app.Activity;import android.os.Bundle;import android.view.KeyEvent;import com.facebook.react.ReactInstanceManager;import com.facebook.react.ReactRootView;import com.facebook.react.common.LifecycleState;import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;import com.facebook.react.shell.MainReactPackage;import com.facebook.soloader.SoLoader;public class ReactActivity extends Activity implements DefaultHardwareBackBtnHandler {private ReactRootView mReactRootView;private ReactInstanceManager mReactInstanceManager;@Overrideprotected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    mReactRootView = new ReactRootView(this);    SoLoader.init(this, false);    mReactInstanceManager = ReactInstanceManager.builder()            .setApplication(getApplication())            .setCurrentActivity(this)            .setBundleAssetName("index.android.bundle")            .setJSMainModulePath("index.android")            .addPackage(new MainReactPackage())            .setUseDeveloperSupport(BuildConfig.DEBUG)            .setInitialLifecycleState(LifecycleState.RESUMED)            .build();    // The string here (e.g. "MyReactNativeApp") has to match    // the string in AppRegistry.registerComponent() in index.js    mReactRootView.startReactApplication(mReactInstanceManager, "MyApplication", null);    setContentView(mReactRootView);}@Overridepublic void invokeDefaultOnBackPressed() {    super.onBackPressed();}@Overrideprotected void onPause() {    super.onPause();    if (mReactInstanceManager != null) {        mReactInstanceManager.onHostPause(this);    }}@Overrideprotected void onResume() {    super.onResume();    if (mReactInstanceManager != null) {        mReactInstanceManager.onHostResume(this, this);    }}@Overrideprotected void onDestroy() {    super.onDestroy();    if (mReactInstanceManager != null) {        mReactInstanceManager.onHostDestroy(this);    }}@Overridepublic void onBackPressed() {    if (mReactInstanceManager != null) {        mReactInstanceManager.onBackPressed();    } else {        super.onBackPressed();    }}@Overridepublic boolean onKeyUp(int keyCode, KeyEvent event) {    if (keyCode == KeyEvent.KEYCODE_MENU && mReactInstanceManager != null) {        mReactInstanceManager.showDevOptionsDialog();        return true;    }    return super.onKeyUp(keyCode, event);}}

AndroidManifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"      xmlns:tools="http://schemas.android.com/tools"      package="com.example.myapplication"><uses-permission android:name="android.permission.INTERNET"/><uses-permission android:name="android.permission.ACTION_MANAGE_OVERLAY_PERMISSION" /><uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /><application android:allowBackup="true"             android:label="@string/app_name"             android:icon="@mipmap/ic_launcher"             android:roundIcon="@mipmap/ic_launcher_round"             android:usesCleartextTraffic="true"             android:supportsRtl="true"             android:appComponentFactory="androidx"             tools:replace="android:appComponentFactory"             android:theme="@style/AppTheme"><activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/><activity android:name=".MainActivity"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity><activity            android:name=".ReactActivity"            android:label="@string/app_name"            android:theme="@style/Theme.AppCompat.Light.NoActionBar"></activity></application>

Viewing all 28482 articles
Browse latest View live


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