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

Splash screen GIF in react native

$
0
0

I am making an application with react native with native code of android and ios, in the application specifications a splash screen with a GiF is required, I have already inserted the required dependencies of the documentation of react native

dependencies {
  // If your app supports Android versions before Ice Cream Sandwich (API level 14)
  implementation 'com.facebook.fresco:animated-base-support:1.3.0'

  // For animated GIF support
  implementation 'com.facebook.fresco:animated-gif:2.0.0'

  // For WebP support, including animated WebP
  implementation 'com.facebook.fresco:animated-webp:2.1.0'
  implementation 'com.facebook.fresco:webpsupport:2.0.0'

  // For WebP support, without animations
  implementation 'com.facebook.fresco:webpsupport:2.0.0'
}

GIF support works correctly within the screen / components. However, when I try to place the GIF on the splash screen it doesn't work, there is a static image of the GIF

import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;

public class SplashActivity extends AppCompatActivity {
     @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            Intent intent = new Intent(SplashActivity.this, MainActivity.class);
            startActivity(intent);
            finish();
        }
}


<?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item>
            <bitmap
                    android:gravity="center"
                    android:src="@drawable/splash_screen2"/>
        </item>
    </layer-list>

How can I place a splash screen in gif format?


RNCamera Error:TypeError: CameraManager.checkIfRecordAudioPermissionsAreDefined is not a function

$
0
0

[Unhandled promise rejection: TypeError: CameraManager.checkIfRecordAudioPermissionsAreDefined is not a function. (In 'CameraManager.checkIfRecordAudioPermissionsAreDefined()', 'CameraManager.checkIfRecordAudioPermissionsAreDefined' is undefined)]

return (
  <View>
    <Text>Welcome to React Native QRScanner!</Text>

    <RNCamera
      ref={ref => {
        this.camera = ref;
      }}
      style={{
        flex: 1,
        width: '100%'
      }}
      androidRecordAudioPermissionOptions={{
        title: 'Permission to use audio recording',
        message: 'We need your permission to use your audio',
        buttonPositive: 'Ok',
        buttonNegative: 'Cancel',
      }}
      onBarCodeRead={this.barcodeRecognized}
    >

    </RNCamera>
  </View>
);

React native MapView indoor level picker working on iOS but not Android

$
0
0

When using the mapView, part of the react-native-map library, the indoor level picker toggle works on ios devices, when zoomed in on certain buildings, but does not work at all on android devices.

<MapView
  style={styles.mapStyle}
  provider="google"
  showsUserLocation={true}
  region={props.region}
  zoomEnabled={true}
  showsIndoorLevelPicker={true}
  showsIndoors={true}
  showsMyLocationButton={true}
/>

How do I get it to work?

React-native - Stuck on splash screen on android with debug apk

$
0
0

None of the solutions provided to existing questions help. I have no issues with iOS and running on my android device with the development server. But debug-apk is stuck on the splash screen and I can't see anything on the logcat.

Related issue (&package): https://github.com/crazycodeboy/react-native-splash-screen/issues/331

App.js

...
import SplashScreen from 'react-native-splash-screen';
...
componentDidMount() {
    // Alert.alert('Done', 'Hide splash!'); doesn't trigger
    SplashScreen.hide();
}

AndroidManifest.xml

<activity
    android:name=".SplashActivity"
    android:theme="@style/SplashTheme"
    android:label="@string/app_name">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>

  <activity
      android:name=".MainActivity"
      android:label="@string/app_name"
      android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
      android:windowSoftInputMode="adjustResize"
      android:exported="true">
  </activity>

MainActivity.java

import org.devio.rn.splashscreen.SplashScreen;
import android.os.Bundle;

public class MainActivity extends ReactActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        SplashScreen.show(this);
        super.onCreate(savedInstanceState);
    }
...

SplashActivity.java

...
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;

public class SplashActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
        finish();
    }
}

Expo React Native app with React Navigation 5, crashes on Android when touching initial screen from Navigator

$
0
0

Problem: On android, I open the app and reach the navigator's initial screen, then touch it and it crashes completely (doesn't show errors).

Package.json:

"dependencies": {
    "@apollo/react-hooks": "^3.1.3",
    "@expo/vector-icons": "^10.0.6",
    "@react-native-community/masked-view": "0.1.5",
    "@react-native-community/netinfo": "^4.6.0",
    "@react-navigation/bottom-tabs": "^5.0.5",
    "@react-navigation/drawer": "^5.0.5",
    "@react-navigation/native": "^5.0.5",
    "@react-navigation/stack": "^5.0.9",
    "@react-navigation/tabs": "0.0.0-alpha.12",
    "add": "^2.0.6",
    "apollo-boost": "^0.4.7",
    "apollo-cache-inmemory": "^1.5.1",
    "apollo-client": "^2.6.8",
    "apollo-link": "^1.2.11",
    "apollo-link-error": "^1.1.10",
    "apollo-link-http": "^1.5.16",
    "apollo-link-state": "^0.4.2",
    "apollo-link-ws": "^1.0.17",
    "aws-amplify": "^2.2.2",
    "aws-amplify-react": "^3.1.6",
    "aws-amplify-react-native": "^3.2.0",
    "aws-appsync": "^3.0.2",
    "aws-appsync-react": "^3.0.2",
    "aws-sdk": "^2.610.0",
    "expo": "^36.0.0",
    "expo-font": "^8.0.0",
    "expo-image-manipulator": "^8.0.0",
    "expo-image-picker": "^8.0.2",
    "graphql": "^14.6.0",
    "graphql-tag": "^2.10.1",
    "install": "^0.13.0",
    "moments": "0.0.2",
    "native-base": "^2.13.8",
    "npm": "^6.13.7",
    "react": "16.12.0",
    "react-apollo": "^3.1.3",
    "react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
    "react-native-clear-app-cache": "^1.0.4",
    "react-native-elements": "^1.2.7",
    "react-native-gesture-handler": "~1.5.0",
    "react-native-image-grid": "^1.0.0",
    "react-native-reanimated": "~1.4.0",
    "react-native-responsive-screen": "^1.3.1",
    "react-native-safe-area-context": "0.6.0",
    "react-native-safe-area-view": "^1.0.0",
    "react-native-screens": "2.0.0-alpha.12",
    "react-native-star-rating": "^1.1.0",
    "react-native-svg": "^9.13.3",
    "react-native-svg-transformer": "^0.14.3",
    "react-native-table-component": "^1.2.1",
    "react-native-thumbnail-grid": "^0.3.0",
    "react-native-vector-icons": "^6.6.0",
    "react-ratings-declarative": "^3.4.1",
    "subscriptions-transport-ws": "^0.9.16",
    "uuid": "^3.4.0",
    "yarn": "^1.21.1"
    },

Navigator:

import React from "react";
import SignUp from "./SignUp/SignUp";
import SignIn from "./SignIn"
import { createStackNavigator } from '@react-navigation/stack';

const Stack = createStackNavigator();

const AuthRouter = () => {

    return(
        <Stack.Navigator>
             <Stack.Screen name="SignIn" component={SignIn} options={{ title: 'Ingresar' }} />
             <Stack.Screen name="SignUp" component={SignUp} options={{ title: 'Registro' }} />
        </Stack.Navigator>
    )
}


export default AuthRouter;

App.js:

if(loading) return <Loading/>
else return (
    <ApolloProvider client={apolloClient}>
        <NavigationContainer>
            <AuthRouter/>
        </NavigationContainer>
    </ApolloProvider>
)

(I simplified some things that weren't important for the problem)

I know it's the Navigator as I tried with single screens and it doesn't crash. I already dived every issue related. Checked the react navigation 5 troubleshooting too.

Any ideas? Thanks!

React Native npm run eject error when i try to emulate my app in an android emulator

$
0
0

I'm going to create a very simple react native app according to the instructions given in Here

when I get to the point where we eject the app to use in android device or android studio emulator i get the following error:

enter image description here

i do what this page says step by step. i've installed react native and react native cli and all the required files. can anyone please help me with this.

making react native to use a Android simulator located at other computer

$
0
0

Is there a way to configure

npx react-native run-android

to use a virtual Android device in another computer? I need this because for a given project I can run

npm start
npx react-native

from a docker container but I need to use an android simulator located inside the host but outside the container.

Thanks

Sharing a single ReactInstanceManager between multiple instances of React native activities

$
0
0

I integrated React Native into a native Android app and I create new instances of React Native activities from the native code.

Here is the code for the class that wraps ReactInstanceManager:

public class ReactNativeInstanceWrapper
{

private static ReactNativeInstanceWrapper instance = new ReactNativeInstanceWrapper();

public static ReactNativeInstanceWrapper getInstance() {
        return instance;
    }

    private ReactInstanceManager reactInstanceManager;

    public ReactInstanceManager GetReactInstanceManager()
    {
        return reactInstanceManager;
    }

    public ReactInstanceManager Rebuild(Application application)
    {
        Boolean isDebugBuild = AppBuildType.IsBuildConfigDebug(application.getBaseContext());

        reactInstanceManager = null;
        synchronized (this) {
            reactInstanceManager = ReactInstanceManager.builder()
                    .setApplication(application)
                    .setBundleAssetName("index.android.bundle")
                    .setJSMainModuleName("index.android")
                    .addPackage(new MainReactPackage())
                    .addPackage(new ReactIntegrationPackage())
                    .addPackage(new PickerPackage())
                    .addPackage(new LinearGradientPackage())
                    .setUseDeveloperSupport(isDebugBuild)
                    .setInitialLifecycleState(LifecycleState.BEFORE_CREATE)
                    .build();
        }

        if (!reactInstanceManager.hasStartedCreatingInitialContext())
        {
            reactInstanceManager.createReactContextInBackground();
        }

        return reactInstanceManager;
    }

I want parse a js bundle while the app is loading and cache it, which makes loading of React Native much faster. The problem is that it looks like sharing a ReactInstanceManager between multiple activities cause some problems.

For example, in one case, if I open a Share sheet in one of my activites and than come back to my RN activity and close it, I can't open a dialog in a new RN activity. It throws a WindowManager$BadTokenException, which probably means that it tries to attach it to an activity that doesn't exist.

In a RN activity, here is how I create ReactRootView in OnCreate:

  this.ReactRootView = new ReactRootView(this);
    setContentView(this.ReactRootView);

    ReactNativeInstanceWrapper reactNativeInstanceWrapper = ReactNativeInstanceWrapper.getInstance();
    this.ReactInstanceManager = reactNativeInstanceWrapper.GetReactInstanceManager();
    if (this.ReactInstanceManager == null) {
      this.ReactInstanceManager = ReactNativeInstanceWrapper.getInstance().Rebuild(getApplication());
    }
    this.ReactRootView.startReactApplication(this.ReactInstanceManager, reactNativeComponent, initialProps);

ReactInstanceManager is supposed to set a new activity in OnResume:

  @Override
  protected void onResume()
  {
    super.onResume();

    if (this.ReactInstanceManager != null) {
      this.ReactInstanceManager.onHostResume(this, this);
    }
  }

But it looks like it still keeps references to an old activity somewhere.

So, what I ended up doing is destroying and rebuilding the instance of ReactInstanceManager every time I leave a RN activity. It's not a perfect option, but it works.

I would like to find a way to create and persist a single instance of ReactInstanceManager instead if recreating it every time in background.

  • react-native -v: 0.42.3
  • node -v: v6.11.0
  • npm -v: 5.2.0
  • platform: Android

React native version mismatch: native version: 0.61.5, javascript version: 0.57.7

$
0
0

I have a react-native app, which does not use expo. I get the following error:

 React Native version mismatch.
                             │ 
                             │ JavaScript version: 0.57.7
                             │ Native version: 0.61.5
                             │ 
                             └ Make sure that you have rebuilt the native code. If the problem persists try clearing the Watchman and packager caches with `watchman watch-del-all && react-native start --reset-cache`.

I have done everything mentioned in this question and nothing has worked so far.

I have updated react-native version to 0.61.5 . It is installed and it is also mentioned in package.json. I have also updated all packages in packages.json.

The project also uses react-navigation. In @react-navigation file in node modules, in native/package.json file, it is the only place that "react-native": "^0.57.7", is mentioned under devDependencies. I have installed the latest react-navigation, 4.0.10.

Add replies to Android notifications while using react-native-firebase

$
0
0

Android 7.0 introduced the ability for users to enter text directly into a notification in order to respond to it, without opening the app. I am using the react-native-firebase project in order to receive push notifications in my React Native app.

Based on the documentation it seems like this functionality is supported -- specifically, AndroidNotification.addAction and AndroidAction.addRemoteInput would seem to indicate that this is possible.

However, I can't find any examples on how to correctly implement this feature. Is this feature supported in a React Native project using react-native-firebase?

React Native version mismatch - only when compiled in Android Studio - works in METRO

$
0
0

I recently updated my react native app to version 0.61.5. The old version was 0.59.3

Everything was working fine while I was doing the upgrades. Then, I tried to make a signed APK and submit for beta testing to Android Store. That APK did not work on any of my android devices. It just gave a blank white screen on open - javascript failed.

Later, I was able to replicate the error, and get actual and virtual devices to show this red screen (see image), even for testing, whenever the app is built exclusively in Android Studio.

Error reads: console.error: "React Native version mismatch.

JavaScript version: 0.59.3 Native version: 0.61.5 etc...

When I "npm run start" in the terminal, outside Android Studio, it starts up the Metro bundler. Then everything works fine, both real and virtual devices. Somehow the Metro bundler is able to reconcile something but Android Studio's bundler is not.

Since Android Studio's APK generator uses it's native javascript bundler, I need to figure out why this is happening, and fix it.

I have tried - clearing caches, deleting the project, invalidating caches, watchmen etc. - adding implementation ("com.facebook.react:react-native:0.61.5") {force = true} (in build.gradle) - many other solutions given for this error message found on stack overflow...

2 days on this. No idea.

screenshot

react-native vs reactXP

$
0
0

I have started developing an application for all the three platforms (web, ios and android) with single code base.

I came across these two libraries and I want to know which one is better and why?

Also, I came across a lot of open source react-native projects, For example React Navigation, Lottie.

Can I integrate react-navigation (or any popular react-native module) in my react-native-web or reactXP application?

Please provide your inputs and TIA.

How to solve "libmain.so not found" while using Unity as a library in Android application with latest AndroidX Versions out of ReactNative

$
0
0

We have a ReactNative application that has integrated Unity based on react-native-unity-view successfully as a library for quite a long time. However, after most recent updates on ReactNative regarding AndroidX and latest SDK-changes, we're running into the issue "libmain.so not found". This exception happens on the very first attempt to display a Unity-View.

There is a similar issue on SO, please don't mark as duplicate as our approach might be different and particulary since we give many many more details here.

There is a running and still working example on GitHub (based on ReactNative 0.57): https://github.com/f111fei/react-native-unity-demo. As long as this project is based on ReactNative 0.57 and its appropriate gradle-settings, everything works fine. But as soon as we upgrade to the latest ReactNative version (and even 0.60 for example), which gives us an android-folder that is very different against to the older one), the issue happens with a crash of the application. (We also tried to set up everything from scratch to exclude the possibility that this issue was due to upgrades. With RN 0.57 everything still works fine, with RN 0.60 and above not)

The exception is as follows:

E Unity   : Failed to load 'libmain.so', the application will terminate.
D AndroidRuntime: Shutting down VM
E AndroidRuntime: FATAL EXCEPTION: main
E AndroidRuntime: Process: com.rnunitydemo, PID: 16887
E AndroidRuntime: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.rnunitydemo-bKGyotdcwjVnBxuR9zLE4Q==/base.apk"],nativeLibraryDirectories=[/data/app/com.rnunitydemo-bKGyotdcwjVnBxuR9zLE4Q==/lib/arm64, /data/app/com.rnunitydemo-bKGyotdcwjVnBxuR9zLE4Q==/base.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]]] couldn't find "libmain.so"

First I'm going to list the android-folder and gradle-files from most recent version, where the crash happens. After that, I will list the files where everything works fine:

Not working (newer) Version

./android/build.gradle:

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")
    }
}

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' }
    }
}

./android/settings.gradle:

rootProject.name = 'rnunitydemo'

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)

include ":UnityExport"
project(":UnityExport").projectDir = file("./UnityExport")


include ':app'

./android/app/build.gradle:

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"

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

def jscFlavor = 'org.webkit:android-jsc:+'

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.rnunitydemo"
        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 {
            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 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
    }
}

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)

./android/UnityExport/build.gradle:

// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath("com.android.tools.build:gradle:3.4.2")
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }
}

apply plugin: 'com.android.library'


dependencies {
    api fileTree(include: ['*.jar'], dir: 'libs')
}

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.2'

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 28
        ndk {
            abiFilters 'armeabi-v7a', 'x86'
        }
        multiDexEnabled true
        versionCode 1
        versionName '0.1'
    }

    lintOptions {
        abortOnError false
    }

    aaptOptions {
        noCompress = ['.unity3d', '.ress', '.resource', '.obb']
        ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    }

    buildTypes {
        debug {
            minifyEnabled false
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
            signingConfig signingConfigs.debug
            jniDebuggable true
        }
        release {
            minifyEnabled false
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
            signingConfig signingConfigs.debug
        }
    }

    packagingOptions {
        doNotStrip '*/armeabi-v7a/*.so'
        doNotStrip '*/x86/*.so'
    }


}

All these files above lead to a crash ("libmain.so not found") as soon as Unity will be launched.

Working (older) Version

In our previous version, as it can be found on GitHub, everything went fine:

./android/build.gradle:

buildscript {
    ext {
        buildToolsVersion = "27.0.3"
        minSdkVersion = 16
        compileSdkVersion = 27
        targetSdkVersion = 26
        supportLibVersion = "27.1.1"
    }
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        google()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        flatDir {
            dirs project(':UnityExport').file('libs')
        }
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}

./android/settings.gradle:

rootProject.name = 'rnunitydemo'
include ':react-native-unity-view'
project(':react-native-unity-view').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-unity-view/android')

include ":UnityExport"
project(":UnityExport").projectDir = file("./UnityExport")

include ':app'

./android/app/build.gradle:

apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

def enableSeparateBuildPerCPUArchitecture = false

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

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "com.rnunitydemo"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }

    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }

    signingConfigs {
        release {
            // storeFile file(MYAPP_RELEASE_STORE_FILE)
            // storePassword MYAPP_RELEASE_STORE_PASSWORD
            // keyAlias MYAPP_RELEASE_KEY_ALIAS
            // keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }

    buildTypes {
        debug {
            manifestPlaceholders = [
                "DEBUGGABLE": "true"
            ]
        }
        release {
            manifestPlaceholders = [
                "DEBUGGABLE": "false"
            ]
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    // 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:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            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 {
    compile project(':react-native-unity-view')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
}

// 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'
}

./android/UnityExport/build.gradle:

(same as above)

There are some other reports according to this issue in the official Unity2D-Forums, but without any working solution. According to a comment we are aware of using the very same abiFilter-Setting in both build.gradle-Files (this from our app and the build-gradle from UnityExport), but it didn't solve the issue either.

Can someone help please?

** Update **

System information of development machine:

System:
    OS: macOS Mojave 10.14.6
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 112.35 MB / 32.00 GB
    Shell: 5.0.11 - /usr/local/bin/bash

  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 23, 25, 26, 27, 28, 29
      Build Tools: 23.0.1, 25.0.0, 25.0.1, 25.0.2, 26.0.1, 27.0.3, 28.0.3, 29.0.0, 29.0.2
      System Images: android-29 | Google APIs Intel x86 Atom
      Android NDK: 20.0.5594570
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5900203
    Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild
  Binaries:
    Node: 10.17.0 - /usr/local/opt/node@10/bin/node
    Yarn: 1.16.0 - /usr/local/bin/yarn
    npm: 6.11.3 - /usr/local/opt/node@10/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.61.4 => 0.61.4
  npmGlobalPackages:
    react-native-cli: 2.0.1

React Native - how to trim a string

$
0
0

I want to delete the whitespaces from the beginning and the end of a string. For example, given a string " Test ", I would like to receive "Test". I have tried JavaScript's methods and also some npm libraries, but they don't seem to work with React Native? Any thoughts?

enter image description here

React Native build fails on building a new build type other than debug/release

$
0
0

I am trying to prepare a staging release build but by my build is failing. It gives me a huge list of errors. I have modified my build.gradle to add a staging environment. I am not sure why this is happening as my debug and release build works fine.

I used yarn android --variant=stagingrelease to generate the build and run on my physical android device. Using React-Native: 0.61.5.

Some of the errors are as follows

FAILURE: Build failed with an exception.

* What went wrong: Could not determine the dependencies of task ':app:preStagingreleaseBuild'.
> Could not resolve all task dependencies for configuration ':app:stagingreleaseRuntimeClasspath'.
   > Could not resolve project :@react-native-community_masked-view.
     Required by:
         project :app
      > Unable to find a matching variant of project :@react-native-community_masked-view:
          - Variant 'debugApiElements' capability Furry:@react-native-community_masked-view:unspecified:
              - Incompatible attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Variant 'debugRuntimeElements' capability Furry:@react-native-community_masked-view:unspecified:
              - Incompatible attribute:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'releaseApiElements' capability Furry:@react-native-community_masked-view:unspecified:
              - Incompatible attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Variant 'releaseRuntimeElements' capability Furry:@react-native-community_masked-view:unspecified:
              - Incompatible attribute:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
   > Could not resolve project :react-native-bootsplash.
     Required by:
         project :app
      > Unable to find a matching variant of project :react-native-bootsplash:
          - Variant 'debugApiElements' capability Furry:react-native-bootsplash:unspecified:
              - Incompatible attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Variant 'debugRuntimeElements' capability Furry:react-native-bootsplash:unspecified:
              - Incompatible attribute:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'releaseApiElements' capability Furry:react-native-bootsplash:unspecified:
              - Incompatible attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Variant 'releaseRuntimeElements' capability Furry:react-native-bootsplash:unspecified:
              - Incompatible attribute:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
   > Could not resolve project :react-native-config.
     Required by:
         project :app
      > Unable to find a matching variant of project :react-native-config:
          - Variant 'debugApiElements' capability Furry:react-native-config:unspecified:
              - Incompatible attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Variant 'debugRuntimeElements' capability Furry:react-native-config:unspecified:
              - Incompatible attribute:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'releaseApiElements' capability Furry:react-native-config:unspecified:
              - Incompatible attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Variant 'releaseRuntimeElements' capability Furry:react-native-config:unspecified:
              - Incompatible attribute:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
   > Could not resolve project :react-native-gesture-handler.
     Required by:
         project :app
      > Unable to find a matching variant of project :react-native-gesture-handler:
          - Variant 'debugApiElements' capability Furry:react-native-gesture-handler:unspecified:
              - Incompatible attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Variant 'debugRuntimeElements' capability Furry:react-native-gesture-handler:unspecified:
              - Incompatible attribute:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'releaseApiElements' capability Furry:react-native-gesture-handler:unspecified:
              - Incompatible attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Variant 'releaseRuntimeElements' capability Furry:react-native-gesture-handler:unspecified:
              - Incompatible attribute:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
   > Could not resolve project :react-native-reanimated.
     Required by:
         project :app
      > Unable to find a matching variant of project :react-native-reanimated:
          - Variant 'debugApiElements' capability com.swmansion.reanimated:react-native-reanimated:unspecified:
              - Incompatible attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Variant 'debugRuntimeElements' capability com.swmansion.reanimated:react-native-reanimated:unspecified:
              - Incompatible attribute:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'releaseApiElements' capability com.swmansion.reanimated:react-native-reanimated:unspecified:
              - Incompatible attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Variant 'releaseRuntimeElements' capability com.swmansion.reanimated:react-native-reanimated:unspecified:
              - Incompatible attribute:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
   > Could not resolve project :react-native-safe-area-context.
     Required by:
         project :app
      > Unable to find a matching variant of project :react-native-safe-area-context:
          - Variant 'debugApiElements' capability Furry:react-native-safe-area-context:unspecified:
              - Incompatible attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Variant 'debugRuntimeElements' capability Furry:react-native-safe-area-context:unspecified:
              - Incompatible attribute:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'releaseApiElements' capability Furry:react-native-safe-area-context:unspecified:
              - Incompatible attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Variant 'releaseRuntimeElements' capability Furry:react-native-safe-area-context:unspecified:
              - Incompatible attribute:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
   > Could not resolve project :react-native-screens.
     Required by:
         project :app
      > Unable to find a matching variant of project :react-native-screens:
          - Variant 'debugApiElements' capability com.swmansion.rnscreens:react-native-screens:unspecified:
              - Incompatible attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Variant 'debugRuntimeElements' capability com.swmansion.rnscreens:react-native-screens:unspecified:
              - Incompatible attribute:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'debug'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Variant 'releaseApiElements' capability com.swmansion.rnscreens:react-native-screens:unspecified:
              - Incompatible attributes:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
                  - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
          - Variant 'releaseRuntimeElements' capability com.swmansion.rnscreens:react-native-screens:unspecified:
              - Incompatible attribute:
                  - Required com.android.build.api.attributes.BuildTypeAttr 'stagingrelease' and found incompatible value 'release'.
              - Other attributes:
                  - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
                  - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
                  - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.

Snippets of android/app/build.gradle

project.ext.envConfigFiles = [
        debug: ".env",
        release: ".env.production",
        stagingrelease: ".env.staging",
]
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

project.ext.react = [
    entryFile: "index.js",
    enableHermes: false,  // clean and rebuild if changing
]

apply from: "../../node_modules/react-native/react.gradle"

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = true

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.furry"
        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"
        }
        stagingrelease {
            initWith release
        }
    }

dependencies {
    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"

    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}


apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
project.ext.vectoricons = [
    iconFontNames: [ 'MaterialIcons.ttf', 'MaterialCommunityIcons.ttf' ]
]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

android/build.gradle

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' }
    }
}

proguard-rules.pro

# Add any project specific keep options here:
-keep class com.furry.BuildConfig { *; }

Dependencies in package.json

"dependencies": {
        "@react-native-community/masked-view": "^0.1.6",
        "@react-navigation/native": "^5.0.7",
        "@react-navigation/stack": "^5.0.8",
        "axios": "^0.19.2",
        "libphonenumber-js": "^1.7.44",
        "react": "16.9.0",
        "react-native": "0.61.5",
        "react-native-bootsplash": "^1.2.1",
        "react-native-config": "^0.12.0",
        "react-native-gesture-handler": "^1.6.0",
        "react-native-reanimated": "^1.7.0",
        "react-native-safe-area-context": "^0.7.3",
        "react-native-screens": "^2.0.0-beta.10",
        "react-native-sms-retriever": "^1.1.1",
        "react-native-svg": "^11.0.1",
        "react-native-vector-icons": "^6.6.0",
        "realm": "4.0.0-beta.0",
        "recyclerlistview": "2.0.13-alpha.1"
    },

react-native: command not found

$
0
0

I am getting -bash: react-native: command not found error while creating react-native project.

Below are the additional info

1. brew --version
   homebrew 0.9.9
2  brew info watchman
   watchman `enter code here`stable 4.50
   /usr/local/Cellar/watchman/4.4.0
3. brew info flow
   stable 0.24.1
   /usr/local/Cellar/flow/0.24.1
4. brew info node
   stable 6.1.0
   /usr/local/Cellar/node/6.1.0
5. npm -version
   3.8.6
6. echo $PATH
/Users/Ashok/.rbenv/shims:/Users/Ashok/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

I tried suggested steps from the below link but still i am getting same error.

  1. react-native-command-not-found

I don't have any "npm" directory which they have specified in the solution

Ashoks-MacBook-Pro:share Ashok$ ls
aclocal     doc     info        ruby-build  zsh
autoconf    emacs       man     systemtap

But i found npm file exist in below location.

/usr/local/Cellar/node/6.1.0/etc/bash_completion.d

I uninstalled react-native and installed again but still i am facing same issue.

React Native App keeps closing after opening it without crashing

react-native-vector-icons/AntDesign could not be found within the project-Android

$
0
0

I am facing following issue.

Error: Unable to resolve module `react-native-vector-icons/AntDesign` from `node_modules/react-native-elements/src/helpers/getIconType.js`: react-native-vector-icons/AntDesign could not be found within the project.

Package.json

{
  "name": "GeoLocation",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-community/geolocation": "^2.0.2",
    "react": "16.9.0",
    "react-native": "0.61.5",
    "react-native-elements": "^1.2.7",
    "react-native-fused-location": "^1.1.1",
    "react-native-get-location": "^1.4.2",
    "react-native-vector-icons": "^4.6.0"
  },
  "devDependencies": {
    "@babel/core": "7.8.4",
    "@babel/runtime": "7.8.4",
    "@react-native-community/eslint-config": "0.0.5",
    "babel-jest": "24.9.0",
    "eslint": "6.8.0",
    "jest": "24.9.0",
    "metro-react-native-babel-preset": "0.56.4",
    "react-test-renderer": "16.9.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

I have done all the steps which mentioned in following link.

Unable to resolve module 'react-native-vector-icons/AntDesign''

Could not find support-compat.aar (com.android.support:support-compat:26.1.0)

$
0
0

im trying to use spinkit react native library and its working on ios but when i export it on android i get this log

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
   > A problem occurred configuring project ':react-native-spinkit'.
      > Could not find support-compat.aar (com.android.support:support-compat:26.1.0).
        Searched in the following locations:
            https://jcenter.bintray.com/com/android/support/support-compat/26.1.0/support-compat-26.1.0.aar

any ideas?

React Native bridging Android sending back base64string

$
0
0

I have a module in Java that will should send back a base64string which will be coming from some small image (out of context of the question). The call is successful and doesn't throw any error but does not return the value.

Disclaimer: this is my first time on Java mobile development so please be easy on me.

Java: (for testing it out, i used the built-in resources of the build)

    @ReactMethod
    public void scan(Callback successCallback, Callback errorCallback) {
        try {

            InputStream inputStream = _reactContext.getResources().openRawResource(+ R.mipmap.ic_launcher);
            int size = inputStream.available();
            byte[] bytes = new byte[size];

            BufferedInputStream buf = new BufferedInputStream(inputStream);
            buf.read(bytes, 0, bytes.length);

            ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
            BufferedOutputStream out = new BufferedOutputStream(bytesOut);
            copy(buf, out);

            successCallback.invoke(new String(bytesOut.toByteArray(), "UTF-8"));
        }
        catch (Exception e) {
            errorCallback.invoke(e.getMessage());
        }
    }

I have a feeling that some of the calls i'm doing here is async which only happens to be done after the callback.

If you have any reference i can look at, i am more than happy to read it.

JS:

import {NativeModules} from 'react-native';

NativeModules.FingerprintModule.scan(
  success => console.log(success),
  error => console.error(error)
);

Additional Info: It clearly goes to the success function.

Thanks a lot in advance!

Viewing all 29524 articles
Browse latest View live


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