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

React-navigation works fine in debug but not in release mode

$
0
0

I am facing a problem since few weeks, I am using react-navigation in my react-native app, when I test on my device in debug mode I navigate properly between screens but when I build a signed apk, the navigation does not work anymore. I try everything but nothing is working.

I am using react-native 0.61.2, react-navigation 4.0.10

This is my app/build.gradle file

project.ext.react = [
    entryFile: "index.js",
    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 = true

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = true

/**
 * 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.lumennui"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk true  // 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'
        }
        release {
            if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                storeFile file(MYAPP_UPLOAD_STORE_FILE)
                storePassword MYAPP_UPLOAD_STORE_PASSWORD
                keyAlias MYAPP_UPLOAD_KEY_ALIAS
                keyPassword MYAPP_UPLOAD_KEY_PASSWORD
            }
        }
    }
    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.release
            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 project(':react-native-splash-screen')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-video')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules

    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 use
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 my android/gradle.build file

// 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.4.2")

        // 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://jitpack.io' }
    }
}

This my root navigation file :

import React from 'react';
import { createAppContainer, createSwitchNavigator } from "react-navigation";
import Chat from "../screens/Chat";
import Welcome from "../screens/Welcome";

const rootNav = createSwitchNavigator({
        welcome: {screen: Welcome},
        chat: {screen: Chat},
    },
    {
        initialRouteName: 'welcome'
    }
);
const RootNavigation = createAppContainer(rootNav);

export default RootNavigation;

my app.js file :

import React from 'react';
import RootNavigation from "./navigations/RootNavigation"
import SnackbarProvider from "./components/SnackBar";

export default class App extends React.Component {

	render(){
		return (
            <SnackbarProvider><RootNavigation/></SnackbarProvider>
		);
	}
}

Welcome.js file:

import React from 'react'
import Header from "../components/Header"
import axios from 'axios'
import '../constants/serverAdress'
import {withSnackbar} from "../components/SnackBar"
import {
    Button,
    ImageBackground,
    Tile,
    Overlay,
    TextInput,
    Title,
    Subtitle,
    Text,
    Card,
    Caption,
    Image,
    View
} from "@shoutem/ui"
import luminy from '../assets/images/luminy.jpg'
import luminy2 from '../assets/images/luminy2.jpg'
import {KeyboardAvoidingView, ScrollView} from "react-native";
import { Provider, Portal, Modal} from "react-native-paper";
import moi from '../assets/images/moi.jpg'
import SplashScreen from 'react-native-splash-screen'

class Welcome extends React.Component {

    constructor(props) {
        super(props)
        this.state = {
            pseudo: '',
            visible: false
        }
        this.onSubmit = this.onSubmit.bind(this)
    }

    _showModal = () => this.setState({ visible: true });
    _hideModal = () => this.setState({ visible: false });

    function

    componentDidMount() {
        SplashScreen.hide()
    }

    onSubmit(e){
        e.preventDefault()
        const { snackbar, navigation } = this.props
        axios.post(`${SERVER_ADRESS}/register`, { pseudo: this.state.pseudo })
        .then(res => {
            if(res.data.status !== undefined){
                snackbar.showMessage(res.data.message)
            } else {
                navigation.navigate('chat', {
                    id : res.data._id,
                    pseudo: this.state.pseudo
                })
            }
        })
        .catch(error => {
            console.log(error)
        })
    }
    render() {
        return (<KeyboardAvoidingView
                behavior="padding"
                style={{flex: 1}}><Header title="Welcome" help helpAction={this._showModal}/><ImageBackground
                    styleName="large"
                    source={luminy2}><Tile><Overlay styleName="image-overlay"><Title styleName="sm-gutter-horizontal">Bienvenue sur LumEnnui</Title><Subtitle>Saisis ou crée ton pseudo et commence à  .....</Subtitle></Overlay></Tile></ImageBackground><ImageBackground
                    styleName="large"
                    source={luminy}><TextInput
                        placeholder={'Pseudo'}
                        onChangeText={(text) => this.setState({pseudo: text})}
                    /><Button
                        styleName="secondary"
                        style={{ marginTop: 20}}
                        onPress={this.onSubmit}><Text>ACCEDER</Text></Button></ImageBackground>
                {/*Modal section*/}<Provider><Portal><Modal visible={this.state.visible} onDismiss={this._hideModal}><Card style={{ width: 200, height: 400}}><Image
                                    styleName="medium-avatar"
                                    source={moi}
                                /><View styleName="content"><ScrollView><Subtitle>
                                           lorum ipsum</Subtitle>
                                        {/*<Subtitle style={{ color: 'red'}}>
                                            lorum ipsum</Subtitle>*/}<Caption>Créé par Mama DEMBELE aka Pakendux</Caption></ScrollView></View></Card></Modal></Portal></Provider></KeyboardAvoidingView>
        );
    }
}
export default withSnackbar(Welcome)

Thank a lot in advance for your help


Cannot read property 'navigate' of undefined - React Native Navigation

$
0
0

I am currently working on a app which works with react native and I tried to make a flow using react-navigation working on this tutorial but I am having trouble at the point of running my project, I've done a lot of research and i just cant get to the solution, first for all I am using react-native-cli: 2.0.1 and react-native: 0.48.3, this is my code:

App.js:

import React, { Component } from 'react';
import { Text, Button, View } from 'react-native';
import {
    StackNavigator,
} from 'react-navigation';

class App extends Component {
    static navigationOptions = {
        title: 'Welcome',
    };

    render() {
        console.log(this.props.navigation);
        const { navigate } = this.props.navigation;
        return (
            <View>
                <Text>Go to maps!</Text>
                <Button
                    onPress={() => navigate('Map')}
                    title="MAP"
                />
            </View>
        );
    }
}

export default App;

my Router.js

import {
    StackNavigator,
  } from 'react-navigation';

  import MapMarker from './MapMarker';
  import App from './App';

  export const UserStack = StackNavigator({
    ScreenMap: 
    {
        screen: MapMarker,
        navigationOptions:
        {
            title: "Map",
            header:null
        },
    },
    ScreenHome: 
    {
        screen: App,
        navigationOptions:
        {
            title: "Home",
            headerLeft:null
        },
    },
});

As you can see this is a pretty basic App which i just cant make work, this is a screenshot of my error on the simulator:

Whoops

I would really really appreciate if you guys could help me with this. Thanks.

react-native .58.1 cannot build Android release

$
0
0

I want to build Android release but I keep getting the same error no matter what I try.

Here is the error output

/app/build/generated/assets/react/release/index.android.bundle
bundle: Done writing bundle output
bundle: Copying 9 asset files
bundle: Done copying assets

> Task :app:bundleReleaseResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:bundleReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
  Output:  /Users/abdul-elah/Projects/characters/characters/android/app/build/intermediates/merged_manifests/release/processReleaseManifest/merged/AndroidManifest.xml:19: error: resource mipmap/ic_launcher (aka com.characters:mipmap/ic_launcher) not found.
  /Users/abdul-elah/Projects/characters/characters/android/app/build/intermediates/merged_manifests/release/processReleaseManifest/merged/AndroidManifest.xml:19: error: resource string/app_name (aka com.characters:string/app_name) not found.
  /Users/abdul-elah/Projects/characters/characters/android/app/build/intermediates/merged_manifests/release/processReleaseManifest/merged/AndroidManifest.xml:19: error: resource mipmap/ic_launcher (aka com.characters:mipmap/ic_launcher) not found.
  /Users/abdul-elah/Projects/characters/characters/android/app/build/intermediates/merged_manifests/release/processReleaseManifest/merged/AndroidManifest.xml:19: error: resource style/AppTheme (aka com.characters:style/AppTheme) not found.
  /Users/abdul-elah/Projects/characters/characters/android/app/build/intermediates/merged_manifests/release/processReleaseManifest/merged/AndroidManifest.xml:27: error: resource string/app_name (aka com.characters:string/app_name) not found.
  /Users/abdul-elah/Projects/characters/characters/android/app/build/intermediates/merged_manifests/release/processReleaseManifest/merged/AndroidManifest.xml:54: error: resource xml/provider_paths (aka com.characters:xml/provider_paths) not found.
  /Users/abdul-elah/Projects/characters/characters/android/app/build/intermediates/merged_manifests/release/processReleaseManifest/merged/AndroidManifest.xml:59: error: resource style/Theme.AppCompat.Light.NoActionBar (aka com.characters:style/Theme.AppCompat.Light.NoActionBar) not found.
  /Users/abdul-elah/Projects/characters/characters/android/app/build/intermediates/merged_manifests/release/processReleaseManifest/merged/AndroidManifest.xml:67: error: resource integer/google_play_services_version (aka com.characters:integer/google_play_services_version) not found.
  error: failed processing manifest.

  Command: /Users/abdul-elah/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.1-4818971-osx.jar/5141019c42220d362e7004555d4c86c4/aapt2-3.2.1-4818971-osx/aapt2 link --proto-format\
          -I\
          /usr/local/share/android-sdk/platforms/android-28/android.jar\
          --manifest\
          /Users/abdul-elah/Projects/characters/characters/android/app/build/intermediates/merged_manifests/release/processReleaseManifest/merged/AndroidManifest.xml\
          -o\
          /Users/abdul-elah/Projects/characters/characters/android/app/build/intermediates/linked_res_for_bundle/release/bundleReleaseResources/bundled-res.ap_\
          --auto-add-overlay\
          -0\
          apk\
          --no-version-vectors
  Daemon:  AAPT2 aapt2-3.2.1-4818971-osx Daemon #0

* 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 1m 35s
46 actionable tasks: 3 executed, 43 up-to-date

here is my manifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.characters">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher"
      android:allowBackup="false"
      android:theme="@style/AppTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        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>

</manifest>

I tried editing the compilesdkversion and the react-native-device-info; I tried several solutions, the app is working perfectly on debug mode, but not when I try to run ./gradlew bundleRelease

React Native Android build failed due to error : Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED

$
0
0

I ran react-native run-android command while my android emulator was already running on macOS but I got this error below: Got this error in the terminal while building

This is my android/app/build.gradle below:

apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js",
    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.realyze"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
    }
    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"
        }
    }
    // 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 project(':@react-native-community_datetimepicker')
    implementation project(':react-native-gesture-handler')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'
    implementation 'com.google.firebase:firebase-analytics:17.2.0'
    implementation 'com.google.firebase:firebase-auth:19.1.0'
    implementation project(path: ":@react-native-firebase_auth")
    implementation project(path: ":@react-native-firebase_database")
    implementation project(':react-native-datetimepicker')
    implementation project(path: ":@react-native-firebase_firestore")

    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 use
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)
apply plugin: 'com.google.gms.google-services'

Please help me solve this issue as I am completely stuck with the development of my app.

This error only occurred when I installed the Firebase cloud firestore dependency in my project before that I was using Realtime Database and all was good but I realized I needed that I needed Cloud Firestore for my projects requirements.

Thank you

Can't get setBackgroundMessageHandler to work

$
0
0

In react-native-firebase v6, I can't get setBackgroundMessageHandler to work in my app. Notifications are received just fine but the handler is not executed.

I have done it like in the guide to no avail.

import { AppRegistry } from 'react-native';
import messaging from '@react-native-firebase/messaging';
import AsyncStorage from '@react-native-community/async-storage';
import App from './App';
import { name as appName } from './app.json';

AppRegistry.registerComponent(appName, () => App);

messaging().setBackgroundMessageHandler(async ({ data: { title, message } }) => {
    console.log('in background');
    // Save the notification locally
    const notificationList = JSON.parse(await AsyncStorage.getItem('@SM_NOTIFICATIONS')) || [];
    notificationList.push({ title, message, isRead: false });
    await AsyncStorage.setItem('@SM_NOTIFICATIONS', JSON.stringify(notificationList));
});

Nothing happened beside the incoming notifications. I expected the code to save the incoming notifications in AsyncStorage.

could not generate APK on react native

$
0
0

I create a key with this command :

keytool -genkey -v -keystore first-key.keystore -alias first-key-alias -keyalg RSA -keysize 2048 -validity 1000

and add this to gradle file :

signingConfigs {
        release {
            storeFile file('/home/mohamadreza/keys/first-key.keystore')
            storePassword '1234567890'
            keyAlias = 'first-key-alias'
            keyPassword 'qq-2012'
        }
    }
    buildTypes {
        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.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

then I run this command:
cd android && ./gradlew assembleRelease

I got this error:

Could not determine the dependencies of task ':app:lintVitalRelease'.
> Could not resolve all task dependencies for configuration ':app:lintClassPath'.
   > Could not find com.android.tools.lint:lint-gradle:26.4.2.
     Searched in the following locations:
...

my classpath : classpath('com.android.tools.build:gradle:3.4.2')

how can I fix it?

Strange react-native warnings/errors

$
0
0

While working on an existing app, I have encountered a number of warning/errors:

1:

warning #1

2:

warning #2

3:

error #1

4:

error #2

5:

error #3

The yellow warnings seems to go away after dismissing them, however, I have to reload the app to get rid of the errors.

Here is the list of my dependencies:

"dependencies": {
  "@react-native-community/async-storage": "1.5.0",
  "@react-native-community/netinfo": "3.2.1",
  "axios": "0.18.0",
  "clock-format-utility": "0.0.5",
  "jsc-android": "241213.2.0",
  "lodash": "4.17.5",
  "moment": "2.22.2",
  "moment-timezone": "0.5.14",
  "prop-types": "15.6.1",
  "react": "16.8.6",
  "react-native": "0.59.8",
  "react-native-actionsheet": "2.2.2",
  "react-native-alphabetlistview": "0.3.0",
  "react-native-calendar-strip": "1.3.8",
  "react-native-calendars": "1.212.0",
  "react-native-camera": "2.9.0",
  "react-native-communications": "2.2.1",
  "react-native-datepicker": "1.72",
  "react-native-deprecated-custom-components": "0.1.2",
  "react-native-device-info": "2.1.2",
  "react-native-document-picker": "2.3.0",
  "react-native-drawer-layout": "2.0.0",
  "react-native-flurry-sdk": "3.2.0",
  "react-native-geolocation-service": "2.0.0",
  "react-native-global-props": "1.1.5",
  "react-native-image-crop-picker": "0.26.1",
  "react-native-image-manipulator": "0.1.0",
  "react-native-maps": "0.24.2",
  "react-native-masked-text": "1.6.5",
  "react-native-modal-dropdown": "0.6.1",
  "react-native-navbar": "2.1.0",
  "react-native-permissions": "1.1.1",
  "react-native-pinch": "0.1.0",
  "react-native-progress": "3.4.0",
  "react-native-push-notification": "3.1.9",
  "react-native-root-toast": "3.0.2",
  "react-native-segmented-control-tab": "3.2.2",
  "react-native-signature-pad": "0.1.0",
  "react-native-splash-screen": "3.2.0",
  "react-native-statusbar-alert": "0.4.0",
  "react-native-swipe-list-view": "1.5.8",
  "react-native-svg": "9.5.1",
  "react-native-touch-id": "4.4.1",
  "react-native-vector-icons": "6.6.0",
  "react-native-webview": "5.12.0",
  "react-native-wheel-picker-android": "2.0.5",
  "react-redux": "6.0.1",
  "redux": "3.7.2",
  "redux-logger": "3.0.6",
  "redux-thunk": "2.2.0",
  "rn-fetch-blob": "0.10.15",
  "uuid": "3.3.2"
}

"devDependencies": {
  "@babel/core": "7.4.5",
  "@babel/runtime": "7.4.5",
  "babel-eslint": "10.0.1",
  "babel-jest": "24.8.0",
  "babel-plugin-root-import": "6.2.0",
  "eslint": "5.16.0",
  "eslint-plugin-babel": "5.3.0",
  "eslint-plugin-react": "7.12.4",
  "eslint-plugin-react-native": "3.6.0",
  "jest": "24.8.0",
  "metro-react-native-babel-preset": "0.54.1",
  "react-test-renderer": "16.8.3"
}

Does anyone have any tips on how to get rid of warnings/errors above completely?

Problem of getting Gradle resource in react-native

$
0
0

After I get start react-native according to its official tutorial. I have not been able run a simple app. this is the error that I've got:

FAILURE: Build failed with an exception.

BUILD FAILED in 6s

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.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

BUILD FAILED in 6s

at checkExecSyncError (child_process.js:621:11)
at execFileSync (child_process.js:639:15)
at runOnAllDevices (F:\android\AwesomeProject\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at buildAndRun (F:\android\AwesomeProject\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
at F:\android\AwesomeProject\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12
at processTicksAndRejections (internal/process/task_queues.js:85:5)
at async Command.handleAction (F:\android\AwesomeProject\node_modules\@react-native-community\cli\build\index.js:164:9)

Cannot read property 'map' of undefined in react native metro builder

$
0
0

I get that problem after the app have successfuly run on my device. I don't understand whats the problem. Here is the error

 bundling failed: TypeError: Cannot read property 'map' of undefined
at resolveDependencies (D:\Projects\twitterBot\node_modules\metro\src\DeltaBundler\traverseDependencies.js:423:18)
at D:\Projects\twitterBot\node_modules\metro\src\DeltaBundler\traverseDependencies.js:275:33
at Generator.next (<anonymous>)
at asyncGeneratorStep (D:\Projects\twitterBot\node_modules\metro\src\DeltaBundler\traverseDependencies.js:87:24)
at _next (D:\Projects\twitterBot\node_modules\metro\src\DeltaBundler\traverseDependencies.js:107:9)
at process._tickCallback (internal/process/next_tick.js:68:7)

When I run "react-native run-android" for the first time, I got error "javax.net.ssl.SSLHandshakeException: Received fatal alert: access_denied"

Event clicks on android CustomView controls - React Native

$
0
0

Im rendering a android layout.xml file on react native.while trying to implement events on views inside layout.xml on android.I'm not able to acheive it

my customview.xml layout.

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height='40dp'
    android:orientation="horizontal">
    <TextView android:id="@+id/multipleCameraText"
        android:layout_marginTop="20dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello, Text View from Native"
        />

        <Button android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:height="40dp"
            android:layout_height="wrap_content"
            android:text="Button 1"

            />
        <Button android:id="@+id/button2"
            android:layout_marginLeft="20dp"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:height="40dp"
            android:text="Button 2"

            />
</LinearLayout>

my customview.java

package com.typesproject;

import android.content.Context;
import android.widget.LinearLayout;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.events.RCTEventEmitter;


public class CustomView2 extends LinearLayout {
        private Context context;
        public CustomView2(Context context) {
            super(context);
            this.context=context;
            this.init();
        }

        public void init() {
            //modified here.
            inflate(context, R.layout.customview2, this);
        }

        public void onReceiveNativeEvent() {
            WritableMap event = Arguments.createMap();
            event.putString("message", "MyMessage");
            ReactContext reactContext = (ReactContext)getContext();
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
                    getId(),
                    "topChange",
                    event);
        }
    }

I want to implement button clicks on two buttons(button1 and button2) and change text inside text view(multipleCameraText).

my customViewManager.java

package com.typesproject;

import android.view.View;

import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.views.image.ReactImageView;

import javax.annotation.Nonnull;

public class CustomViewManager extends SimpleViewManager<CustomView> {

    public  static final String Custom_View="CustomView";

    @Nonnull
    @Override
    public String getName() {
        return Custom_View;
    }

    @Nonnull
    @Override
    protected CustomView createViewInstance(@Nonnull ThemedReactContext reactContext) {
        return new CustomView(reactContext);
    }
}

Please let me know how we can achieve separate events for buttons and textview.

How can we read device status in react native? (eg: phone in call , sleep mode, etc...)

$
0
0

I just need to read the status of the phone eg: in phone call /sleep mode etc ... is there any way to read all the status ?

Stuck when run react-native application

React Native Task :react-native-maps:compileDebugJavaWithJavac FAILED

$
0
0

I installed react-native-maps but when i run react-native run-android i got this error:

C:\Users\Emre\example\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:12: error: package androidx.core.view does not exist
import androidx.core.view.GestureDetectorCompat;
                         ^
C:\Users\Emre\example\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:13: error: package androidx.core.view does not exist
import androidx.core.view.MotionEventCompat;
                         ^
C:\Users\Emre\example\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:22: error: package androidx.core.content.PermissionChecker does not exist
import androidx.core.content.PermissionChecker.checkSelfPermission;
                                              ^
C:\Users\Emre\example\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:74: error: package androidx.core.content does not exist
import static androidx.core.content.PermissionChecker.checkSelfPermission;
                                   ^
C:\Users\Emre\example\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:74: error: static import only from classes and interfaces
import static androidx.core.content.PermissionChecker.checkSelfPermission;
^
C:\Users\Emre\example\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:109: error: cannot find symbol
  private final GestureDetectorCompat gestureDetector;
                ^
  symbol:   class GestureDetectorCompat
  location: class AirMapView
C:\Users\Emre\example\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:161: error: cannot find symbol
    gestureDetector = new GestureDetectorCompat(reactContext, new GestureDetector.SimpleOnGestureListener() {
                          ^
  symbol:   class GestureDetectorCompat
  location: class AirMapView
C:\Users\Emre\example\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:422: error: cannot find symbol
    return checkSelfPermission(getContext(), PERMISSIONS[0]) == PackageManager.PERMISSION_GRANTED
           ^
  symbol:   method checkSelfPermission(Context,String)
  location: class AirMapView
C:\Users\Emre\example\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:423: error: cannot find symbol
        || checkSelfPermission(getContext(), PERMISSIONS[1]) == PackageManager.PERMISSION_GRANTED;
           ^
  symbol:   method checkSelfPermission(Context,String)
  location: class AirMapView
C:\Users\Emre\example\node_modules\react-native-maps\lib\android\src\main\java\com\airbnb\android\react\maps\AirMapView.java:956: error: cannot find symbol
    int action = MotionEventCompat.getActionMasked(ev);
                 ^
  symbol:   variable MotionEventCompat
  location: class AirMapView
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
10 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-maps:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated 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.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BU¦LD FAILED in 3s
19 actionable tasks: 2 executed, 17 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.

react-native link react-native-maps works for only ios. I linked it manually but it is not working.

"react-native": "0.59.9", "react-native-maps": "0.26.1",

What do i need to do to solve it?

Check device for VoLTE support - ReactNative

$
0
0

I'm searching for a way to detect device is support VoLTE or not from my developed app using react native. Search on internet and couldn't find a correct answer. Could some one guide me to find out correct way of doing it.


Official API for grabbing app version on Google PlayStore

$
0
0

I know Apple has this API I can hit:

http://itunes.apple.com/lookup?bundleId={id}

However, for the PlayStore, I'm looking for something similar, rather than parsing the app page

https://play.google.com/store/apps/details?id={id}

and then looking for the <div> that contains itemprop="softwareVersion"

There are a few questions about this here on SO and elsewhere on the web, but they are outdated, and make reference to unofficial APIs.

How to react all android notifications in react native similar to onNotificationPosted method in android

$
0
0

I'm looking for a solution where I can read all the android notification on the phone of different apps only after read notifications permission is given by the user with react-native.

I've achieved this easily using the native android method

public void onNotificationPosted(StatusBarNotification sbn) {
   // Do whatever I want once the new notification is posted
}

What is the appropriate method in react-native to achieve the same behavior or how can I use the same native android method in the react-native app?

Thank you for any kind of help in advance. I really appreciate it.

React-Native Detect App running on Foreground

$
0
0

How do you go about detecting what app is currently running on the foreground when using react-native.

My RN app will be running in the background and needs to be able to detect the launch of specific apps within the phone. For example if the user opens game, how would i go about detecting what the app opened is (app package id).

I read that android native has this feature, through reading this stack overflow question detect apps running in foreground

I would like to know if there is a process similar in react-native, help would be much appreciated.

Thanks.

Push notification not receiving some Android 9 background

$
0
0

I am trying to catch the problem with Expo React Native SDK 34 in push notification service. In most android 9 devices i have a couple of problems, but the weirdest is that in push notification is receiving in foreground but not in background and obviously that is a huge problem because is the way we have to let users knows something to trigger the open app.

I have already tried installing Sentry (error catcher) to see if there is a problem but nothing happended.

I also tried to put a button with label to see the permission of the push, in this case the permission said "granted" and that seems obvious because we receive the push in foreground, but also check the permission display in the android config and all seems good.... super weird.

Another fact is that in some cases, those phones neither receive instagram push notification... so maybe is a react native issue?

Then when i saw the Google Play Console errors logs the output for some devices with the android 9 was =>

Android output problem:


java.lang.RuntimeException: 
  at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4000)
  at android.app.ActivityThread.handleResumeActivity (ActivityThread.java:4032)
  at android.app.servertransaction.ResumeActivityItem.execute (ResumeActivityItem.java:51)
  at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:145)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:70)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1976)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:193)
  at android.app.ActivityThread.main (ActivityThread.java:6912)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:860)
Caused by: java.lang.IllegalStateException: 
  at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1592)
  at android.app.ContextImpl.startService (ContextImpl.java:1547)
  at android.content.ContextWrapper.startService (ContextWrapper.java:664)
  at host.exp.exponent.experience.BaseExperienceActivity.registerForNotifications (BaseExperienceActivity.java:258)
  at host.exp.exponent.experience.ExperienceActivity.onResume (ExperienceActivity.java:256)
  at android.app.Instrumentation.callActivityOnResume (Instrumentation.java:1434)
  at android.app.Activity.performResume (Activity.java:7300)
  at android.app.ActivityThread.performResumeActivity (ActivityThread.java:3992)
  at android.app.ActivityThread.handleResumeActivity (ActivityThread.java:4032)
  at android.app.servertransaction.ResumeActivityItem.execute (ResumeActivityItem.java:51)
  at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:145)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:70)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1976)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:193)
  at android.app.ActivityThread.main (ActivityThread.java:6912)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:860)

My handler of notification is with expo-notifications. I also tried with channel id in android because i know a couple of changes were made and channelId is the key, but did not work either.

_handleNotification = (notification) => {
    //TODO exec un post para guardar el js notification. SI android 9 + android version + background status or foreground.
    if (Platform.OS === 'android') {
      Notifications.createChannelAndroidAsync('chat-messages', {
        name: 'Chat messages',
        sound: true,
        vibrate: true,
        priority: 'max',
        vibrate: [0, 250, 250, 250]
      });
    }
    this.setState({ pushNotification: notification }, () => {
      if (!this.state.pushNotification.data.show_message || this.state.pushNotification.data.refresh) {
        this.getNews();
      } else if (this.state.pushNotification.data.show_message) {
        Alert.alert(notification.data.titulo.toString(), notification.data.cuerpo.toString());
      } else {
        console.log('no hizo nadachr');
      }
    });

  };

Build failed with an exception react-native

$
0
0

got this error when running this command react-native run-android

I even tried so many things to deal with this like degrade your Java SDK version from 13 to 11, but nothing solved the issue.

here is the information about the error.

  • Where: Build file 'G:\react\react-native\albums\android\app\build.gradle'

  • What went wrong: Could not compile build file 'G:\react\react-native\albums\android\app\build.gradle'.

    startup failed: General error during semantic analysis: Unsupported class file major version 57

Thank you in advance.

Viewing all 29519 articles
Browse latest View live


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