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

wix react-native-navigation change tab animation

$
0
0

Is there any way to animate the transition between screens with bottomTabs layout in react-native-navigation?

expected behavior:

enter image description here

react-native: 0.61.1

react-native-navigation: 3.2.0

{
    bottomTabs: {
        id: 'BottomTabs',
        children: [
            {
                stack: {
                    children: [
                        {
                            component: {
                                id: 'tab1',
                                name: 'Tab2Screen',
                            },
                        },
                    ],
                    options: {
                        bottomTab: {
                            icon: homeIcon,
                            text: 'Tab1'
                        },
                    },
                },
            }, {
                stack: {
                    children: [
                        {
                            component: {
                                id: 'tab2',
                                name: 'Tab2Screen',
                            },
                        },
                    ],
                    options: {
                        bottomTab: {
                            icon: 'homeIcon',
                            text: 'Tab2'
                        },
                    },
                },
            },
        ],
    }
}

Could not find method compile() for arguments [com.android.support:appcompat-v7:25.0.0]

$
0
0

Trying to build a react native project, and cannot compile appcompat

Could not find method compile() for arguments [com.android.support:appcompat-v7:25.0.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 21
        compileSdkVersion = 28
        targetSdkVersion = 27
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        compile 'com.android.support:appcompat-v7:25.0.0'
        compile 'com.android.support:support-annotations:25.0.0'
        compile 'com.android.support:design:25.0.0'
    }
}

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
            url "$rootDir/../node_modules/expo-camera/android/maven"
        }
    }
}


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

UPDATE changing to implementation yields

ERROR: Could not find method implementation() for arguments [com.android.support:appcompat-v7:25.0.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler

Google cloud platform image URL doesn't work on web, but works on react-native app

$
0
0

I'm using a react-native app to upload images on Google Cloud Platform (all images are from phone storage, Android). In general, everything works fine, but sometimes happens that some photos aren't uploaded correctly.

Using the Google Cloud platform console I am able to generate an URL for each asset stored on it (e.g. https://32asd0a234239032439420432-apidata.googleusercontent.com/download/storage/...)

If I'm trying to access this URL from chrome browser (or any other web browser) I only get a blank image with a white bordered square like in the image below.

https://imgur.com/9LXnXID.png

If I pass the exact same URL to the uri parameter of FastImage component for react-native, then the image is displayed on the mobile without problems.

Does anyone else encountered this problem? Any info is helpful :)

Estou tentando compliar um projeto react e me deparo com este erro, alguém já passou por isso?

$
0
0

Em tempo: já configurei corretamente as variáveis de ambiente, inclusive uma aplicação ionic compila sem problemas. já instalei android-studio e já aceitei as licencas do android.

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag. Jetifier found 1030 file(s) to forward-jetify. Using 8 workers... info Starting JS server... info Launching emulator... error Failed to launch emulator. Reason: Emulator exited before boot.. warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch. info Installing the app...

FAILURE: Build failed with an exception.

  • What went wrong: A problem occurred configuring project ':app'.

    Failed to notify project evaluation listener. Uninitialized object exists on backward branch 142 Exception Details: Location: com/android/build/gradle/internal/pipeline/VariantInfoImpl.(Lcom/android/build/gradle/internal/scope/VariantScope;)V @200: goto Reason: Error exists in the bytecode Bytecode: 0000000: 2b12 3cb8 0034 2a2b b900 4201 0059 1244 0000010: b800 47b6 004d b900 5201 002b b900 5401 0000020: 0059 1256 b800 472b b900 4201 0059 1244 0000030: b800 47b6 005a c000 5c59 125e b800 47b9 0000040: 0061 0100 5912 63b8 0047 2bb9 0042 0100 0000050: 5912 44b8 0047 b600 6759 1269 b800 47c0 0000060: 006b 4d3a 0e3a 0d36 0c3a 0b03 3e2c 3a04 0000070: bb00 6d59 2c10 0ab8 0073 b700 76c0 0078 0000080: 3a05 0336 0619 04b9 007c 0100 3a07 1907 0000090: b900 8101 0099 0036 1907 b900 8501 003a 00000a0: 0819 0519 08c0 0087 3a09 3a0f 0336 0a19 00000b0: 0959 1289 b800 47b9 008a 0100 3a10 190f 00000c0: 1910 b900 8e02 0057 a7ff c619 05c0 0090 00000d0: 3a0f 190b 150c 190d 190e 190f c000 6bb8 00000e0: 0096 2bb9 0042 0100 5912 44b8 0047 b600 00000f0: 5ac0 005c 5912 5eb8 0047 b900 9801 00b7 0000100: 009a b1 Stackmap Table: full_frame(@142,{UninitializedThis,Object[#62],Object[#107],Integer,Object[#107],Object[#120],Integer,Object[#126],Top,Top,Top,UninitializedThis,Integer,Object[#169],Object[#169]},{}) same_frame(@203)

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

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.

  • What went wrong: A problem occurred configuring project ':app'.

    Failed to notify project evaluation listener. Uninitialized object exists on backward branch 142 Exception Details: Location: com/android/build/gradle/internal/pipeline/VariantInfoImpl.(Lcom/android/build/gradle/internal/scope/VariantScope;)V @200: goto
    Reason: Error exists in the bytecode Bytecode: 0000000: 2b12 3cb8 0034 2a2b b900 4201 0059 1244 0000010: b800 47b6 004d b900 5201 002b b900 5401 0000020: 0059 1256 b800 472b b900 4201 0059 1244 0000030: b800 47b6 005a c000 5c59 125e b800 47b9 0000040: 0061 0100 5912 63b8 0047 2bb9 0042 0100 0000050: 5912 44b8 0047 b600 6759 1269 b800 47c0 0000060: 006b 4d3a 0e3a 0d36 0c3a 0b03 3e2c 3a04 0000070: bb00 6d59 2c10 0ab8 0073 b700 76c0 0078 0000080: 3a05 0336 0619 04b9 007c 0100 3a07 1907 0000090: b900 8101 0099 0036 1907 b900 8501 003a 00000a0: 0819 0519 08c0 0087 3a09 3a0f 0336 0a19 00000b0: 0959 1289 b800 47b9 008a 0100 3a10 190f 00000c0: 1910 b900 8e02 0057 a7ff c619 05c0 0090 00000d0: 3a0f 190b 150c 190d 190e 190f c000 6bb8 00000e0: 0096 2bb9 0042 0100 5912 44b8 0047 b600 00000f0: 5ac0 005c 5912 5eb8 0047 b900 9801 00b7 0000100: 009a b1 Stackmap Table: full_frame(@142,{UninitializedThis,Object[#62],Object[#107],Integer,Object[#107],Object[#120],Integer,Object[#126],Top,Top,Top,UninitializedThis,Integer,Object[#169],Object[#169]},{}) same_frame(@203)

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

at checkExecSyncError (child_process.js:629:11)
at execFileSync (child_process.js:647:13)
at runOnAllDevices (C:\Projetos\LeitorReact\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at process._tickCallback (internal/process/next_tick.js:68:7)

Expo app crashes only in Android when trying to navigate from a screen to the other using a Button

$
0
0

I created a stack navigator in react native and then used it from my home screen to go to the next screen using a button, when the button is clicked I am calling

props.navigation.navigate('SS2');

SS2 is the screen I want to go to.

This is working perfectly in iOS using the expo to run the app, however this is not the case for android, I have tried Android v8.0 and v9.0, in both of them expo crashed after the button was clicked.

There is no error message thrown at the expo server / terminal, the app just crashes and closes itself.

Here are the .js files I am using:

package.json:

   {
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "expo": "^35.0.0",
    "expo-linear-gradient": "^7.0.1",
    "native-base": "^2.13.8",
    "package.json": "^2.0.1",
    "react": "16.8.3",
    "react-dom": "16.8.3",
    "react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
    "react-native-elements": "^1.2.6",
    "react-native-fs": "^2.16.1",
    "react-native-gesture-handler": "^1.4.1",
    "react-native-ionicons": "^4.6.3",
    "react-native-vector-icons": "^6.6.0",
    "react-native-web": "^0.11.7",
    "react-navigation": "^4.0.10",
    "react-navigation-stack": "^1.10.3"
  },
  "devDependencies": {
    "babel-preset-expo": "^7.1.0"
  },
  "private": true
}

App.js:

import React from 'react';

import MainNavigator from './navigation/SingUpNavigator';

export default class App extends React.Component {
  render() {
    return (
      <MainNavigator />
    );
  }
}

SingUpNavigator.js:

import React from 'react';
import { createAppContainer } from 'react-navigation';
import { createStackNavigator } from 'react-navigation-stack';

import LoginRegisterScreen from '../screens/LoginRegisterScreen';
import SS2 from '../screens/register/SS2';

const MainNavigator = createStackNavigator(
    {
      Home: {
        screen: LoginRegisterScreen
      },
      LoginRegisterScreen: {
        screen: LoginRegisterScreen
      },
      SS2: {
        screen: SS2
      }
    },
    {
      headerMode: 'none'
    }
  )

  export default createAppContainer(MainNavigator);

LoginRegisterScreen.js:

 ... 
<MainButton title="REGISTER" onPress={() => { props.navigation.navigate('SS2')}}/>;
 ...

Realm react-native Cannot find module 'fs-extra'

$
0
0

I'm getting this error while running on iOS Simulator. I tried many solutions but none works.

Error: Cannot find module 'fs-extra'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/usr/local/lib/node_modules/realm/scripts/download-realm.js:21:12)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Command /bin/sh failed with exit code 1


** BUILD FAILED **


The following build commands failed:
    PhaseScriptExecution Download\ Core /MyProject/ios/build/MyProject/Build/Intermediates.noindex/RealmJS.build/Debug-iphonesimulator/RealmJS.build/Script-F63FF2C51C12462600B3B8E0.sh

Even I tried to run Realm on empty new project but still the issue remains same.

It will be great if anyone encountered this issue.

More information

Realm JavaScript 3.3.0

react-native-cli: 2.0.1

react-native: 0.61.2

Is it possible to navigate from an Android Native screen to a React Native component?

$
0
0

I'm a beginner to react Native, and I've been given a task to integrate an existing Android Native project. So far, I can navigate from React Native to Android Native just fine. I learned that it's possible to send data from Android Native to RN by calling a listener from the RN side, and when the AN side calls an emit function, it can call functions from JS encased in that listener. But I can't seem to find a workaround to re-render a component itself from AN. Calling the listener in render() and componentDidMount() doesn't seem to work.

I guess I don't have to post the source code since it's similar to this repository, which is pretty much my guide so far.

Uncaught Error: Invariant Violation & Screen Orientation

$
0
0

I'm somewhat new to React / React Native and after updating a project from a previous version of Expo, I keep running into odd "uncaught errors" with what seems to be Expo's Screen Orientation that holds the app back from loading.

Based on Expo's documentation (listed below), I've attempted to rewrite how the app is enforcing a specific screen orientation on load, but I keep running into errors.

https://docs.expo.io/versions/latest/sdk/screen-orientation/#screenorientationallowasyncorientationlock

ScreenOrientation.lockAsync(ScreenOrientation.Orientation.LANDSCAPE);
    if (!this.state.isReady) {
      return <Expo.AppLoading />;
    }

ScreenOrientation.lockAsync(ScreenOrientation.Orientation.LANDSCAPE_LEFT);
    return (

Originally, the application loaded in landscape and locked, but now the app is getting held up on a "invariant violation" error. To view a screenshot of the error that's being produced, please check out the link below.

https://imgur.com/a/Uw4fnCI


what are the minimum maximum values of react native geolocation gps accuracy

$
0
0

I want to know what are the minimum and maximum values of gpa accuracy in react native Geolocation. I already have got the gpa accuracy float value.I want to know what are the minimum and maximum values of gpa accuracy.

error: package com.android.annotations does not exist

$
0
0

I have the following class

import com.android.annotations.NonNullByDefault;

@NonNullByDefault
public final class Log {
    ...
}

and here is my build.gradle file (some parts omitted)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '24.0.1'

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 2
        versionName "0.2"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

}

dependencies {    
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.android.support:support-annotations:25.0.0'
    compile 'com.android.support:design:25.0.0'
}

In Android Studio there is no warning raised for my class

enter image description here

However when I try to build and run my app I get this error from gradle

Information:Gradle tasks [:app:clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:assembleDebug]
Warning:[options] bootstrap class path not set in conjunction with -source 1.7
/home/puter/git-repos/TaskManager3/app/src/main/java/com/treemetrics/taskmanager3/util/Log.java
Error:(3, 31) error: package com.android.annotations does not exist
Error:(7, 2) error: cannot find symbol class NonNullByDefault
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Information:Total time: 21.021 secs
Information:3 errors
Information:1 warning
Information:See complete output in console

How to fix Facebook error "Platform Policy 8.2" in app with expo

$
0
0

Received this alert from Facebook today:

Your app doesn’t comply with the following: Platform Policy 8.2: Native iOS and Android apps that implement Facebook Login must use our official SDKs for Login. Please make sure your Android app is using the most recent version of out SDK for Login.

Specifically, it violates this policy: https://developers.facebook.com/policy#7-2-photo (Android apps should use the default login behavior defined by the SDK, which may use the web-view Login dialog. On iOS, only kiosk apps may use a web-view Login dialog.) Facebook requests to fix it in 6 days, in other way the app will be subject to enforcement.

The issue is that we didn’t apply any changes to Facebook login on our own. The last thing that we did was updating expo version to “31.0.7", it went to Play Store on Jan, 15, 11:19. Before that we had version 30.

We need help with this. Could it be an Expo issue or something else?

Can't locate source of fatal exception due to obfuscation in React Native app

$
0
0

I am trying to debug a crash reported by Firebase Crashlytics found in the latest version of my app.

The error seems somewhat obfuscated (despite having uploaded a ProGuard mapping file) and based on the vagueness of the error I am struggling to pinpoint the issue.

I fully understand the Text strings must be rendered within a <Text> component error description - but this error didn't show up in testing and seems to be something to do with the latest release build.

If anyone knows any tips as to how I can pinpoint where this fatal exception is occurring, I would appreciate it.

All I can determine is that the error occurs in a subview of a ScrollView component. Is there anything else that can be taken from this message to help me determine the cause?

Invariant Violation: Invariant Violation: Text strings must be rendered within a component. This error is located at: in RCTView in RCTView in RCTView in RCTView in RCTScrollView in h in RCTView in n in _ in p in RCTView in RCTView in l in RCTView in n in RCTView in u in RCTView in u in PanGestureHandler in n in S in P in p in RCTView in u in RCTView in u in n in n in E in RCTView in n in RCTView in u in PanGestureHandler in n in L in RCTView in n in t in P in v in RCTView in n in A in s in Unknown in RCTView in RCTView in c This error is located at: in A in s in Unknown in RCTView in RCTView in c, stack: v@82:187 Pa@82:69549 _a@82:68342 Ea@82:66044 Ea@-1 xa@82:64787 xa@-1 pn@82:25281 dn@82:25187 Ue@82:81498 Me@82:13499 Fe@82:13672 receiveEvent@82:14058 value@23:3518 @23:822 value@23:2772 value@23:794 value@-1

proguard-rules.pro:

-keep class io.invertase.firebase.** { *; }
-dontwarn io.invertase.firebase.**

-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**

# Crashlytics
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception

could not generate APK on react native : :app:lintVitalRelease

$
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?

How to display data from API in React Native without error undefined property?

$
0
0

I always get undefined property error when I use dataSource[0].first_name in displaying.

export default class Profile extends React.Component {

    constructor(props) {
        super(props)
        this.state = {
            dataSource: []
        }
    }
    async componentDidMount() {
        const response = await fetch('http://api url goes here /api/v1/getUserInfo/40', {
            method: 'GET',
            headers: {
                'authorization': 'token ' + global.storeToken,
            }
        })
            .then((response) => {
                return response;
            })
            .catch((error) => {
                alert('Error!' + error)
            })

        const json = await response.json();
        this.setState({
            isLoading: false,
            dataSource: [json],
        });
    }

    render() {
        const { dataSource } = this.state;

        return (
            <Container>
                <Header span style={styles.headerStyle}>
                    <Body style={{ justifyContent: "center" }}>
                        <Label style={styles.labelNickname}></Label>
                        <Label style={styles.labelUserID}> {dataSource[0].first_name}</Label>
                    </Body>
                </Header>
            </Container>
        );
    };
}

The api content is:

{
    "id": 40,
    "email": "kk@gmail.com",
    "first_name": "Kagura",
    "last_name": "Kinomoto",
    "birth_date": "1990-01-01T00:00:00.000Z"
}

There's always error.

TypeError: Cannot read property 'first_name' of undefined

This error is located at:
    in Profile (at SceneView.js:9)
    in SceneView (at StackViewLayout.tsx:898)
    in RCTView (at View.js:35)
    in View (at StackViewLayout.tsx:897)
   etc...

What's weird is it worked yesterday after all the console logs and stuff. I only hibernated the laptop, when I tried to run it again today, the error came back.

React Native two drawers on one screen

$
0
0

I have an app that needs to be able to use two drawer navigators, one on the left and on on the right side of the header.

I am at the point where I can get both drawers to open with the slide gesture, however I need to be able to open it programmatically. I have found the navigation.openDrawer() function only works with one of the drawers and not the other because it is only able to use one of the navigation props (whichever comes first) from my drawer navigators.

Below are my rendering functions:

const LeftStack = createStackNavigator(
  {
    LeftDrawerStack
  },
  {
    navigationOptions: ({navigation}) => ({
      headerLeft: (<TouchableOpacity onPress={() => navigation.openDrawer()}><Icon style={{marginLeft: 10}} name='menu'/></TouchableOpacity>
      )
    })
  }
);

const RightStack = createStackNavigator(
  {
    RightDrawerStack
  },
  {
    navigationOptions: ({navigation}) => ({
      headerRight: (<TouchableOpacity onPress={() => navigation.openDrawer()}><Icon style={{marginRight: 10}} name='ios-bulb'/></TouchableOpacity>
      )
    })
  }
);

export const RouteStack = createStackNavigator(
  {
    screen: LoginScreen,
    navigationOptions: ({navigation}) => ({
      header: null
    }),
    LeftStack,
    RightStack
  }
);

and here are my drawer routes:

export const LeftDrawerStack = createDrawerNavigator(
  {
    Dashboard: {
      screen: DashboardScreen
    },
    History: {
      screen: HistoryScreen
    },
    Privacy: {
      screen: PrivacyPolicyScreen
    },
    TermsAndConditions: {
      screen: TermsAndConditionsScreen
    }
  }, {
    initialRouteName: 'Dashboard',
    contentComponent: LeftDrawerScreen
  }
);

export const RightDrawerStack = createDrawerNavigator(
  {
    LeftDrawerStack,
    Settings: {
      screen: SettingsScreen
    }
  }, {
    drawerPosition: 'right',
    contentComponent: RightDrawerScreen
  }
);

Here is a picture of what I have the navigation looking like so far, however both of the hamburger menus are opening up the same menu on the right instead of one menu on their respective sides.

layout picture

I may be missing some parts but I will be sure to post more info if I forgot any!


React native Android App wont't build and displays the following error

$
0
0

PFA image for reference.

Screenshot Real Device

  • One Plus 6
  • Oxygen OS

My app/build.gradle

apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js",
    bundleInRelease: true,
    enableHermes: true,
]

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

def enableSeparateBuildPerCPUArchitecture = true

def enableProguardInReleaseBuilds = true

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
    }

    lintOptions { 
        checkReleaseBuilds false
    }

    defaultConfig {
        applicationId "com.****.**"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 206
        versionName "2.1"
        multiDexEnabled true
        missingDimensionStrategy 'react-native-camera', 'general'

    }

    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 {            
            // minifyEnabled true
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
            // shrinkResources true
            zipAlignEnabled true
            useProguard enableProguardInReleaseBuilds
        }

        // 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, "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) * 1048600 + defaultConfig.versionCode
                }
            }
        }
    }

    packagingOptions {
        pickFirst '**/armeabi-v7a/libc++_shared.so'
        pickFirst '**/x86/libc++_shared.so'
        pickFirst '**/arm64-v8a/libc++_shared.so'
        pickFirst '**/x86_64/libc++_shared.so'
        pickFirst '**/x86/libjsc.so'
        pickFirst '**/armeabi-v7a/libjsc.so'        
    }

}

dependencies {
    implementation project(':react-native-splash-screen')
    implementation project(':@react-native-community_async-storage')
    implementation project(':react-native-gesture-handler')
    implementation project(':@react-native-community_netinfo')
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.annotation:annotation:1.0.2'
    implementation fileTree(include: ['*.jar'], dir: 'libs')   
    implementation 'com.facebook.react:react-native:+'
    implementation 'com.android.support:multidex:1.0.1'

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

    // From node_modules
    implementation 'com.google.android.gms:play-services-auth-api-phone:16.0.0'
    implementation 'com.google.android.gms:play-services-identity:16.0.0'
    implementation 'com.google.android.gms:play-services-auth:16.0.0'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'com.android.volley:volley:1.1.1'
    implementation 'com.google.code.gson:gson:2.8.5'
    // Firebase dependencies
    implementation project(':react-native-firebase')
    implementation "com.google.android.gms:play-services-base:17.0.0"

    implementation "com.google.firebase:firebase-core:17.0.0"
    implementation "com.google.firebase:firebase-messaging:19.0.0"

    implementation project(':@mauron85_react-native-background-geolocation')
    implementation(project(':react-native-maps')){
       exclude group: 'com.google.android.gms', module: 'play-services-base'
       exclude group: 'com.google.android.gms', module: 'play-services-maps'
   }

}

// 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 plugin: 'com.google.gms.google-services'
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

My Top Level build.gradle file


buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
        googlePlayServicesVersion = "11+"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.4.1")
        classpath 'com.google.gms:google-services:4.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url ("$rootDir/../node_modules/react-native/android")            
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

    }
}

/*
To resolve the gradle dependency issue
*/
subprojects {
    afterEvaluate {
        project ->
            if (project.hasProperty("android")) {
            android {
            compileSdkVersion = 28
            buildToolsVersion = "28.0.3"
            }
        }
    }
}
subprojects {
  project.configurations.all {
     resolutionStrategy.eachDependency { details ->
        if (details.requested.group == 'com.android.support'&& !details.requested.name.contains('multidex') ) {
           details.useVersion "28.0.3"
        }
     }
  }
}

My package.json dependencies

"dependencies": {
    "@mauron85/react-native-background-geolocation": "^0.6.3",
    "@react-native-community/async-storage": "^1.5.1",
    "@react-native-community/geolocation": "^2.0.2",
    "@react-native-community/netinfo": "^3.2.1",
    "@types/react-native-vector-icons": "^6.4.2",
    "@typescript-eslint/eslint-plugin": "^2.2.0",
    "@typescript-eslint/parser": "^2.2.0",
    "buffer": "^5.2.1",
    "d3-shape": "^1.3.5",
    "deepmerge": "^3.2.0",
    "lottie-react-native": "^3.1.0",
    "moment": "^2.24.0",
    "object-path": "^0.11.4",
    "prop-types": "^15.7.2",
    "query-string": "^6.5.0",
    "react": "16.8.6",
    "react-native": "0.60.5",
    "react-native-android-location-services-dialog-box": "^2.8.2",
    "react-native-camera": "^3.0.0",
    "react-native-cli": "^2.0.1",
    "react-native-copilot": "^2.4.5",
    "react-native-datepicker": "^1.7.2",
    "react-native-device-info": "1.6.1",
    "react-native-document-picker": "^2.2.0",
    "react-native-elements": "^1.1.0",
    "react-native-exit-app": "^1.0.0",
    "react-native-fetch-blob": "^0.10.8",
    "react-native-firebase": "~5.5.6",
    "react-native-fs": "^2.13.3",
    "react-native-gesture-handler": "^1.3.0",
    "react-native-google-signin": "^2.0.0",
    "react-native-image-picker": "^0.28.0",
    "react-native-image-resizer": "^1.0.1",
    "react-native-image-zoom-viewer": "^2.2.25",
    "react-native-linear-gradient": "^2.5.4",
    "react-native-loader": "^1.2.1",
    "react-native-loading-spinner-overlay": "^1.0.1",
    "react-native-maps": "^0.26.1",
    "react-native-material-dropdown": "^0.11.1",
    "react-native-permissions": "^1.1.1",
    "react-native-picker-select": "^6.1.0",
    "react-native-privacy-snapshot": "^1.0.0",
    "react-native-qrcode-scanner": "^1.2.1",
    "react-native-shared-preferences": "^1.0.0",
    "react-native-simple-toast": "0.0.8",
    "react-native-snackbar": "^2.0.2",
    "react-native-splash-screen": "^3.2.0",
    "react-native-svg": "^9.4.0",
    "react-native-user-defaults": "^0.1.5",
    "react-native-vector-icons": "^6.6.0",
    "react-native-webview": "^5.12.1",
    "react-redux": "^5.0.6",
    "react-roka-components": "^1.0.1",
    "redux": "^3.0.0",
    "redux-devtools-extension": "^2.13.8",
    "redux-form": "^7.4.2",
    "url": "^0.11.0",
    "url-parse": "^1.4.7",
    "uuid": "^3.3.2",
    "whatwg-fetch": "^2.0.4"
  },

Steps taken to resolve :

1) Tried using the same version of dependencies (17.0.0) for "com.google.firebase:firebase-core" and "com.google.firebase:firebase-messaging" as suggested in the below link.

No class Def Error

But the gradle build failed with the following error

CONFIGURE FAILED in 1m 0s In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[16.0.0]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

Dependency failing: com.google.firebase:firebase-messaging:17.0.0 -> com.google.firebase:firebase-iid@[16.0.0], but firebase-iid version was 19.0.0.

The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the artifact with the issue.

-- Project 'app' depends onto com.google.firebase:firebase-messaging@{strictly 17.0.0}

-- Project 'app' depends onto com.google.firebase:firebase-iid@{strictly 19.0.0}

null is not an object (evaluating 'I.setJSAnimations')

$
0
0

I'm developing a react-native app that use React-viro for augmented reality. My app works fine in develop mode, but when I try to build it on my phone by android studio or 'react-native run-android', it say that the build is succesful but when the app open on my phone it show the error: "null is not an object (evaluating I.setJSAnimations"), and when i build the APK the app crash instantly. I don't know how to individuate the problem, any help?

my build.gradle file:


import com.android.build.OutputFile

/**
 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
 * and bundleReleaseJsAndAssets).
 * These basically call `react-native bundle` with the correct arguments during the Android build
 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
 * bundle directly from the development server. Below you can see all the possible configurations
 * and their defaults. If you decide to add a configuration block, make sure to add it before the
 * `apply from: "../../node_modules/react-native/react.gradle"` line.
 *
 * project.ext.react = [
 *   // the name of the generated asset file containing your JS bundle
 *   bundleAssetName: "index.android.bundle",
 *
 *   // the entry file for bundle generation
 *   entryFile: "index.android.js",
 *
 *   // whether to bundle JS and assets in debug mode
 *   bundleInDebug: false,
 *
 *   // whether to bundle JS and assets in release mode
 *   bundleInRelease: true,
 *
 *   // whether to bundle JS and assets in another build variant (if configured).
 *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
 *   // The configuration property can be in the following formats
 *   //         'bundleIn${productFlavor}${buildType}'
 *   //         'bundleIn${buildType}'
 *   // bundleInFreeDebug: true,
 *   // bundleInPaidRelease: true,
 *   // bundleInBeta: true,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // the root of your project, i.e. where "package.json" lives
 *   root: "../../",
 *
 *   // where to put the JS bundle asset in debug mode
 *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
 *
 *   // where to put the JS bundle asset in release mode
 *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in debug mode
 *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in release mode
 *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
 *
 *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
 *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
 *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
 *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
 *   // for example, you might want to remove it from here.
 *   inputExcludes: ["android/**", "ios/**"],
 *
 *   // override which node gets called and with what additional arguments
 *   nodeExecutableAndArgs: ["node"],
 *
 *   // supply additional arguments to the packager
 *   extraPackagerArgs: []
 * ]
 */

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

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

android {
       compileSdkVersion 28
   buildToolsVersion '28.0.3'
    flavorDimensions "platform"

signingConfigs {
        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
            }
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
    compileSdkVersion 28
        minSdkVersion 23
        targetSdkVersion 28
        multiDexEnabled true
    buildToolsVersion '28.0.3'
 multiDexEnabled true
        applicationId "com.namedSportAR"
        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"
        }
    }
        productFlavors {
        ar {
            resValue 'string', 'app_name', 'ViroSample-ar'
            buildConfigField 'String', 'VR_PLATFORM', '"GVR"' //default to GVR
        }
        gvr {
            resValue 'string', 'app_name', 'ViroSample-gvr'
            buildConfigField 'String', 'VR_PLATFORM', '"GVR"'
        }
        ovr {
            resValue 'string', 'app_name', 'ViroSample-ovr'
            applicationIdSuffix '.ovr'
            buildConfigField 'String', 'VR_PLATFORM', '"OVR_MOBILE"'
        }
    }
    buildTypes {
        release {
        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:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            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-firebase_app')
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.facebook.react:react-native:+'
    // implementation project(':arcore_client')
    // implementation project(':gvr_common')
    // implementation project(path: ':viro_renderer')
    // implementation project(path: ':react_viro')
    implementation 'com.google.android.exoplayer:exoplayer:2.7.1'
   // implementation 'com.google.protobuf.nano:protobuf-javanano:2.7.1'
    implementation 'com.amazonaws:aws-android-sdk-core:2.7.7'
    implementation 'com.amazonaws:aws-android-sdk-ddb:2.7.7'
    implementation 'com.amazonaws:aws-android-sdk-ddb-mapper:2.7.7'
    implementation 'com.amazonaws:aws-android-sdk-cognito:2.7.7'
    implementation 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.7.7'
    implementation 'com.android.support:multidex:1.0.0'
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use

my app.js file:

/*
 * Copyright (c) 2017-present, Viro, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

import React, { Component } from 'react';
import {
  AppRegistry,
  Text,
  View,
  StyleSheet,
  PixelRatio,
  TouchableHighlight,
  Image,
  Icon
} from 'react-native';

import {
  ViroVRSceneNavigator,
  ViroARSceneNavigator
} from 'react-viro';


var sharedProps = {
  apiKey:"2803D6A6-AAFE-4CAB-823F-E7433072671D",
}

// Sets the default scene you want for AR and VR
var InitialARScene = require('./src/PlayScene');


var UNSET = "UNSET";
var VR_NAVIGATOR_TYPE = "VR";
var AR_NAVIGATOR_TYPE = "AR";

// This determines which type of experience to launch in, or UNSET, if the user should
// be presented with a choice of AR or VR. By default, we offer the user a choice.
var defaultNavigatorType = UNSET;

export default class ViroSample extends Component {
  constructor() {
    super();

    this.state = {
      navigatorType : defaultNavigatorType,
      sharedProps : sharedProps
    }
    this._getExperienceSelector = this._getExperienceSelector.bind(this);
    this._getARNavigator = this._getARNavigator.bind(this);
    this._getVRNavigator = this._getVRNavigator.bind(this);
    this._getExperienceButtonOnPress = this._getExperienceButtonOnPress.bind(this);
    this._exitViro = this._exitViro.bind(this);
  }

  // Replace this function with the contents of _getVRNavigator() or _getARNavigator()
  // if you are building a specific type of experience.
  render() {
    if (this.state.navigatorType == UNSET) {
      return this._getExperienceSelector();
    } else if (this.state.navigatorType == VR_NAVIGATOR_TYPE) {
      return this._getVRNavigator();
    } else if (this.state.navigatorType == AR_NAVIGATOR_TYPE) {
      return this._getARNavigator();
    }
  }

  // Presents the user with a choice of an AR or VR experience
  _getExperienceSelector() {
    return (
      <View style={localStyles.outer} >


        <View style={localStyles.inner} >
        <Image
                  style={{marginTop: 50, marginBottom: 50, width: 200, height: 50}}
          source={require('./assets/logo.png')}
          />    
 <TouchableHighlight style={localStyles.buttons}
            onSubmit={this._getExperienceButtonOnPress(AR_NAVIGATOR_TYPE)}
            underlayColor={'#68a0ff'} >

            <Text style={localStyles.buttonText}>realtà aumentata</Text>
          </TouchableHighlight>


        </View>
      </View>
    );
  }

  // Returns the ViroARSceneNavigator which will start the AR experience
  _getARNavigator() {
    return (
      <ViroARSceneNavigator {...this.state.sharedProps}
        initialScene={{scene: InitialARScene}} />
    );
  }

  // Returns the ViroSceneNavigator which will start the VR experience
  _getVRNavigator() {
    return (
      <ViroVRSceneNavigator {...this.state.sharedProps}
        initialScene={{scene: InitialVRScene}} onExitViro={this._exitViro}/>
    );
  }

  // This function returns an anonymous/lambda function to be used
  // by the experience selector buttons
  _getExperienceButtonOnPress(navigatorType) {
    return () => {
      this.setState({
        navigatorType : navigatorType
      })
    }
  }

  // This function "exits" Viro by setting the navigatorType to UNSET.
  _exitViro() {
    this.setState({
      navigatorType : UNSET
    })
  }
}

var localStyles = StyleSheet.create({
  viroContainer :{
    flex : 1,
    backgroundColor: "#EF7D1A",
  },
  outer : {
    flex : 1,

    alignItems:'center',
    backgroundColor: "#EF7D1A",
  },
  inner: {
    flex : 1,

    alignItems:'center',
    backgroundColor: "#EF7D1A",
  },
  titleText: {
    paddingTop: 30,
    paddingBottom: 20,
    color:'black',
    textAlign:'center',
    fontSize : 25
  },
  buttonText: {
    color:'black',
    textAlign:'center',
    fontSize : 20
  },
  buttons : {
    height: 80,
    width: 150,
    paddingTop:20,
    paddingBottom:20,
    marginTop:250, 
    justifyContent: 'center',

    alignItems:'center',
    backgroundColor:'#EF7D1A',
    borderRadius: 10,
    borderWidth: 1,
    borderColor: '#000000',
  },
  exitButton : {
    height: 50,
    width: 100,
    paddingTop:10,
    paddingBottom:10,
    marginTop: 10,
    marginBottom: 10,
    backgroundColor:'#68a0cf',
    borderRadius: 10,
    borderWidth: 1,
    borderColor: '#fff',
  }
});

module.exports = ViroSample

my PlayScene.js file:

'use strict';

import React, { Component } from 'react';

import {StyleSheet,Linking} from 'react-native';

import {
  ViroBox,
  ViroARScene,
  ViroText,
  ViroConstants,
  Viro3DObject,
  ViroAmbientLight,
  ViroMaterials,
  ViroARTrackingTargets,
  ViroARImageMarker,
  ViroAnimations

} from 'react-viro';

export default class HelloWorldSceneAR extends Component {

  constructor() {
    super();

    // Set initial state here
    this.state = {
      text : "Initializing AR..."
    };

    // bind 'this' to functions
    this._onInitialized = this._onInitialized.bind(this);
  }

  render() {
    return (
      <ViroARScene  onTrackingUpdated={this._trackingUpdated}>

      <ViroAmbientLight color="#FFFFFF" />
      <ViroARImageMarker target={'logo'} onAnchorFound={this._onAnchorFound}    onAnchorRemoved={this._onAnchorRemoved} pauseUpdates={this.state.pauseUpdates}>

      <Viro3DObject onLoadEnd={this._onModelLoad}
      onClick={this.loadInBrowser}
        source={require('./assets/ns/AMINONAM-obj.obj')}
        resources={[
                   require('./assets/ns/AMINONAM.mtl'),
                   require('./assets/ns/TEX_OK.jpg'),
                   require('./assets/ns/WHITE.jpg'),
                   require('./assets/ns/arancio.jpg'),
          ]}
       highAccuracyEvents={true}
        position={[0, 0.02, 0]} // we place the object in front of us (z = -1)
        scale={[0.001, 0.001, 0.001]} // we reduce the size of our Marmelab logo object
        animation={
          {name:'popup', 
          run:true},
          {name:'ruota',
        loop:true, 
        run:true}
                            }
        rotation={[0, 0, 0]}
        type="OBJ"

    />
      </ViroARImageMarker>
      </ViroARScene>
    );
  }
  loadInBrowser = () => {
    Linking.openURL('https://www.namedsport.com/it/').catch(err => console.error("Couldn't load page", err));
  };  

  _onInitialized(state, reason) {
    if (state == ViroConstants.TRACKING_NORMAL) {
      this.setState({
        text : "NamedSport!"
      });
    } else if (state == ViroConstants.TRACKING_NONE) {
      // Handle loss of tracking
    }
  }
}

ViroAnimations.registerAnimations({

  ruota:{properties:{rotateY:360,},  
        easing:"Linear", duration: 10000},
});


 ViroARTrackingTargets.createTargets({
       logo: {
           type: 'Image',
           source: require('./assets/namedsport-box.jpg'), // source of the target image
           orientation: 'Up', // desired orientation of the image
           physicalWidth: 0.07, // with of the target in meters (10 centimeters in our case)
       },
   });

var styles = StyleSheet.create({
  helloWorldTextStyle: {
    fontFamily: 'Arial',
    fontSize: 30,
    color: '#ffffff',
    textAlignVertical: 'center',
    textAlign: 'center',  
  },
});

module.exports = HelloWorldSceneAR;



Why do my Mapbox Symbol Layer icons go transparent with MapboxGL React Native?

$
0
0

I'm using MapboxGL React Native library on my Android emulator.

I am successfully showing icons for my features using Symbol Layers. I would like to show an alternative icon image when a pin is selected. However, at the moment when a pin is selected they are changing to be slightly transparent which is not what I intend.

Additionally, when I zoom in on the map it starts to show the correct images.

What am I doing wrong?

Please see the code below.

import MapboxGL from "@react-native-mapbox-gl/maps"
import pinImage from '../../Assets/Images/pin.png'
import pinSelectedImage from '../../Assets/Images/pinSelected.png'


const layerStyles = {
  pin: {
    iconImage: pinImage,
    iconSize: 0.3,
    iconOpacity: 1,
    iconAllowOverlap: true,
    iconIgnorePlacement: true
  },
  pinSelected: {
    iconImage: pinSelectedImage,
    iconSize: 0.3,
    iconOpacity: 1,
    iconAllowOverlap: true,
    iconIgnorePlacement: true
  }
}

class ExampleScreen extends React.Component {
  constructor() {
    super()

    this.state = {
      selectedPinID: null
    }
  }

  buildFeatureCollection() {
    return {
      "type": "FeatureCollection",
      "features": this.props.m.map( m => {
        return {
          type: "Feature",
          id: m.id,
          properties: {
            id: m.id,
            m: m.fields,
            isSelected: this.state.selectedPinID === m.id
          },
          geometry: {
            type: "Point",
            coordinates: [ x, y ],
          }
        }
      })
    }
  }

  onPress( e ) {
    const feature = e.nativeEvent.payload;
    this.setState({ selectedPinID: feature.properties.id })
  }

  render() {
    const featureCollection = this.buildFeatureCollection();

    console.log("FC", featureCollection)

    return (
               <MapboxGL.MapView 
                  style={styles.map}
                  >
                  <MapboxGL.UserLocation />   
                  <MapboxGL.Camera 
                    zoomLevel={12} 
                    followUserLocation={false} 
                    followUserMode='normal' 
                    centerCoordinate={[0.1275000, 51.5074000]} />

                  <MapboxGL.ShapeSource
                    id="symbolLocationSource"
                    hitbox={{ width: 30, height: 30 }}
                    shape={featureCollection}
                    onPress={this.onPress}
                  >
                    <MapboxGL.SymbolLayer
                      id="pin"
                      filter={['==', 'isSelected', false]}
                      style={layerStyles.pin}
                    />
                    <MapboxGL.SymbolLayer
                      id="pinSelected"
                      filter={['==', 'isSelected', true]}
                      style={layerStyles.pinSelected}
                    />

                  </MapboxGL.ShapeSource>
                </MapboxGL.MapView>
     )
  }
}

GoogleSignIn.signInAsync() from library expo-google-sign-in resolves to undefined on Android

$
0
0

Some details:

  • I am using expo, more specifically expo SDK 35.
  • I am using the library expo-google-sign-in.
  • The functionality seems to be working on IOS, but not on Android.
  • This is a managed expo app, not a bare/ejected one.

On Android, when I call GoogleSignIn.signInAsync(), the dialogue appears, and seems to work as it is supposed to, but the promise returned by the function resolves to undefined.

Here is a simplified extract from my code (where I don’t show alerts and various other stuff that I don’t think is central to my question/problem):

import * as GoogleSignIn from 'expo-google-sign-in'

...

let clientId = *cencored*
// If I understand the documentation correctly this parameter
// isn't really necessary on Android, but I've provided one anyway.
// Actually, I've tried several different ones.

await GoogleSignIn.initAsync({
    clientId,
    scopes: ['profile', 'email']
})

await GoogleSignIn.askForPlayServicesAsync()

const result = await GoogleSignIn.signInAsync()
// ^ dialogue opens and looks normal/working,
// but the variable named "result" ends up being undefined

Here is my app.json (along with a few comments that of course aren’t included in the actual file):

{
    "expo": {
        "version": "0.0.61",
        "android": {
            "package": "com.toleio.no",
            "googleServicesFile": "./google-services.json",
            // ^ I've also downloaded an actual file of this type from firebase
            "versionCode": 61,
            "config": {
                "googleSignIn": {
                    "apiKey": *cencored*,
                    // ^ If I understand the documentation correctly
                    // this is uneccecary, but I added it just in case.
                    // I created it on https://console.developers.google.com/apis/credentials?project=signlab-prod
                    // and selecting Create credentials -> API key.
                    // I also tried a build where I tried "Web API key"
                    // from console.firebase.google.com.
                    "certificateHash": *cencored*
                    // ^ I don't know what this parameter is for exactly,
                    // and if I understand the documentation correctly it's
                    // irrellevant/unnececcary. But what I put here is the
                    // has that is called "Google Certificate Hash (SHA-1)"
                    // when I do the console command "expo fetch:android:hashes"
                }
            }
        },
        "sdkVersion": "35.0.0",
        "facebookAppId": *cencored*,
        "facebookDisplayName": "Toleio!",
        "facebookScheme": *cencored*,
        "name": "Toleio",
        "description": "Making Sign Language Available for Everyone",
        "slug": "toleio-app-norwegian",
        "privacy": "unlisted",
        "ios": {
            "bundleIdentifier": "com.toleio.no",
            "supportsTablet": true,
            "usesAppleSignIn": true,
            "config": {
                "googleSignIn": {
                    "reservedClientId": : *cencored*
                }
            }
        },
        "scheme": "toleio",
        // ^ I don't properly/fully understand what this parameter does,
        // and don't know if it might be relevant somehow
        "platforms": [
            "ios",
            "android"
        ],
        "orientation": "portrait",
        "icon": "./assets/icon.png",
        "splash": {
            "image": "./assets/iconWithPadding.png",
            "resizeMode": "contain",
            "backgroundColor": "#ffffff"
        },
        "updates": {
            "fallbackToCacheTimeout": 30000
        },
        "assetBundlePatterns": [
            "**/*"
        ],
        "packagerOpts": {
            "assetExts": [
                "ttf",
                "mp4",
                "dae",
                "obj",
                "amf",
                "3mf",
                "3ds",
                "jpg",
                "assimp",
                "fbx",
                "pmd",
                "vmd",
                "ply",
                "stl",
                "vtk",
                "vtp",
                "sea",
                "gltf",
                "bin"
            ]
        }
    },
    "hooks": {
        "postPublish": [
            {
                "file": "sentry-expo/upload-sourcemaps",
                "config": {
                    "organization": "signlab",
                    "project": "toleio-app",
                    "authToken": : *cencored*
                }
            }
        ]
     }
  }

The article React Native Google Sign-In with Expo, and the documentation, presents things as if using firebase isn’t just a way of making expo-google-sign-in work but the way of making it work (or at least that’s my interpretation when reading). However, I might remember incorrectly, but I think I remember being able to extract a token from GoogleSignIn.signInAsync() on IOS before doing anything with firebase. I don’t have a good understanding of exactly what role firebase is supposed to play in making expo-google-sign-in work, and am a bit confused. (Is firebase perhaps used simply because it’s the easiest way of generating a google-services.json-file? 🤔)

Anyway, I did try to use firebase. When clicking “Add project” from https://console.firebase.google.com/ I chose an existing one (the one that is used for google login on the website corresponding to our app, and has been used with expo-google-app-auth with varying success in previous iterations of our app).

enter image description here

This is the project from console.developers.google.com that I merged with:

enter image description here

Some images from the merged firebase project:

enter image description hereenter image description hereenter image description here

I did download the google-services.json-file, and added it to the root of my project. I don’t understand the content of that file, but I see that several of the client IDs from my console.developers.google.com-project are included in it.

The following alerts undefined for me on Android (but perhaps that’s normal on Android, the documentation did seem to suggest that this test was for IOS):

import { AppAuth } from 'expo-app-auth'
const { URLSchemes } = AppAuth
alert(URLSchemes)

As a sidenote (that may or may not be relevant): When adding Facebook-login I added “Facebook Key Hash” from “expo fetch:android:hashes” on developers.facebook.com. This, however, did not make the login work on my phone (it did however work on the phone of my friend). It only started working on my own phone once I added the facebook key hash from an error message that I was shown on my phone when trying to use Facebook login.

  • Do any of you see at once what I’ve done wrong?
  • Is there some step I should have done, but don’t mention?
  • Do you have suggestions for things you would try if you were me?
  • Do you have questions that potentially could bring us closer to a solution?

I have some suspicion that the problem could be with the library (as opposed to my implementation), and that the library's documentation is wrong/misleading. I go more into detail about this here: https://forums.expo.io/t/does-google-authentication-work-on-android-sdk-35/28754. I'm therefore also very interested in feedback/info that could help in regards to that:

  • Are there anyone here who can confirm that they’ve gotten google authentication to work on Android?
  • And are there anyone here who can confirm that they’ve gotten google authentication to work on Android with expo-SDK 35?
  • Are there anyone here who have gotten google authentication to work on Android with this library, but with an ejected/bare app - not a managed one?

I've been stuck on this for a week or so, arguably more 😟

Any help (be that a solution, or just a pointer) would be greatly appreciated! 🙂

Building React native app with android studio

$
0
0

I am new to Android Studio and I need some general information regarding SDK versions etc. Basically, my react-native app has a bunch of third-party components like:

react-native-device-info => build.gradle => compileSdkVersion 23, buildToolsVersion 23.0.1

react-native-extra-dimensions-android => build.gradle => compileSdkVersion 23, buildToolsVersion 23.0.1

But I am using the most up-to-date SDK in Android Studio 29 with build tools 29.0.5

The application was written quite a while back. I am getting a lot of errors whilst building the application. Should the SDK versions be the same and will using AndroidX in android studio cause problems?

Viewing all 29519 articles
Browse latest View live


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