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

Wait till reScanAndLoadWifiList returns available wifi networks in react-native

$
0
0

I am using react-native-android-wifi library in my react-native project for fetching available WiFi networks, here's what I am doing currently,

1. Check if wifi is enabled or not, if not then enable it

  wifi.isEnabled(isEnabled => {
    if (!isEnabled) {
      wifi.setEnabled(true);
    }
  });

2. Fetch all nearby WiFi networks available and show it to the screen

  wifi.reScanAndLoadWifiList(
    wifiStringList => {
      var wifiArray = JSON.parse(wifiStringList);
      console.log("Detected wifi networks - ", wifiArray);
    },
    error => {
      console.log(error);
    }
  );

Here the issue which I am facing is, the first time wifiStringList returns an empty array, but if I try refreshing, then it gives me list of WiFi's. How can I wait till wifiStringList has the list of available WiFi's. I know putting a setTimeout of around 3-5 secs will solve the issue, but I want to know what's the other approach rather than using setTimeout. Please tell me how can I achieve the desired result? Thanks a lot.


How to fix Execution failed for task ':app:processDebugManifest' in React Native?

$
0
0

I find an error when run the project, I try to look for many examples but fail all, this is the detail of error:

D:\myApp\android\app\src\debug\AndroidManifest.xml:22:18-91 Error:
        Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
        is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
        Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:5-117 to override.

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.


> Task :app:processDebugManifest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
        is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
        Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:5-117 to override.

Please anyone help me to solve this problem.

Thanks

React Native - Some Styles in screen do not load unless i manually save screen file again

$
0
0

I've been battling with this for sometime now, One particular Screen in my react native application loads without some of the styles when i run the application the first time. I have to manually save that screen.js file (which is already saved) in my editor before the app refreshes and load all of the styles on that screen. I tried bundling an unsigned apk to see if the screen will have all the styles loaded in the bundled apk but still doesn't.

So the initial build loads just part of the styles and then saving that particular file again (which is already saved) refreshes the screen with all the styles loaded. I think this is kind of odd and i'll appreciate all the help i can get.

Also i'll like to mention that, the screen giving me this issue is in a BottomTabNavigator and the only part of the screen giving me this issue is the Flatlist Component i'm using to render a list of items on the screen. The other components on the screen render just fine.

This is the code for the screen giving me problems

import React from 'react'
import { StyleSheet, View, Text, Image, TouchableOpacity, FlatList } from 'react-native'
import MeetingItem from './meetingItem'

const MeetingsScreen = ({navigation, data})=>{
return <View style={styles.container}>
    <View style={styles.cardContainer}>
        <View style={styles.groupContainer}>
        <Text style={styles.groupTitle} numberOfLines={1}>Groups Masters A </Text>
        <View style={styles.groupDetailsContainer}>
            <Text style={styles.groupDetailsText}><Text>Facilitator: </Text>Frederick Bans</Text>
            <View style={styles.groupNumberContainer}>
                <Text style={styles.groupNumber}>25</Text>
                <Image source={require('../assets/group-white.png')} style={styles.groupIcon}/>
            </View>
        </View>
        </View>
    </View>
    <FlatList 
            data={[1,2,3,4,5,6,7,8,9,11,10,12,13,14,15,16,17,18]}
            renderItem={({item})=> (<TouchableOpacity onPress={()=>navigation.navigate("Chat")}>
            <MeetingItem/>
        </TouchableOpacity>)}
            keyExtractor={item => item.toString()}
            ListFooterComponent={<View style={{marginTop: 100}}/>}
            showsVerticalScrollIndicator={false}
        />  
        {/* <MeetingItem/>
        <MeetingItem/>
        <MeetingItem/>
     */}
</View>
}

MeetingsScreen.navigationOptions = ()=>({
    title: "",
    headerRight: (<TouchableOpacity style={{
        marginRight: 10,
        fontSize: 15, 
        borderColor: "white", 
        borderWidth: 1,
        padding: 4
    }}>
        <Text style={{color: "white"}}>Create Meeting</Text>
    </TouchableOpacity>)
})

const styles = StyleSheet.create({
    container:{
        flex: 1
    },
    headerRight:{
        marginRight: 10,
        fontSize: 15, 
        borderColor: "white", 
        borderWidth: 1,
        padding: 4
    },
    cardContainer:{
        height: 90,
        borderRadius: 0,
        justifyContent: "center",
        backgroundColor: "#067b7a",
        elevation: 3
    },
    groupIcon:{
        width: 30,
        height: 20
    },
    groupContainer:{
        marginHorizontal: 15
    },
    groupDetailsContainer:{
        flexDirection: "row",
        justifyContent: "space-between",
        marginTop: 10,
    },
    groupDetailsText:{
        color: "white",
        flex: 0.7,
        opacity: 0.7

    },
    groupNumberContainer:{
        flexDirection: "row",
        alignItems: "center",
        flex: 0.2
    },
    groupNumber:{
        fontSize: 15,
        marginRight: 5,
        color: "white"
    },
    groupTitle:{
        fontSize: 21,
        color: "white",
    }
})

export default MeetingsScreen;

And this is the code for the meetingItem I'm rendering in the FlatList

import React from 'react'
import { View, Text, StyleSheet } from 'react-native'

const MeetingItem = ({navigation})=>{
    return <View style={styles.container}>
        <View style={styles.dateContainer}>
            <Text style={styles.dateText}>13th Oct 2017</Text>
        </View>

        <View style={styles.titleContainer}>
        <Text style={styles.titleText} numberOfLines={2}>Second Meeting of the month</Text>
        </View>

    </View>
}

styles = StyleSheet.create({
    container:{
        flex: 1,
        flexDirection: "row",
        height: 70,
        justifyContent: "space-around",
        marginVertical: 10,
        marginHorizontal: 10
    }, 
    dateContainer:{
        flex: 0.3,
        borderTopLeftRadius: 4,
        borderBottomLeftRadius: 4,
        justifyContent: "center",
        alignItems: "center",
        padding: 10,
        borderWidth: 1,
        borderColor: "#bdbdbd"
    },
    titleContainer:{
        flex: 0.7,
        borderBottomRightRadius: 4,
        borderTopRightRadius: 4,
        justifyContent: "center",
        alignItems: "center",
        padding: 10,
        borderWidth: 1,
        borderColor: "#bdbdbd"
    },
    dateText:{
        textAlign: "center",
        fontSize:19
    },
    titleText:{
        textAlign: "center",
        fontSize: 16
    }

})

export default MeetingItem;

Thanks in advance for the assistance.

React Native - How to make KeyboardAvoidingView inside a ScrollView work for all devices?

$
0
0

enter image description here

I am building a chat UI in react native and am having an issue with using KeyboardAvoidingView inside of a ScrollView. When selecting the TextInput the height between the input field and keyboard seems to vary based on the device I am using. How do I standardize this so that it works equally for all devices?

import React from 'react'
import { StyleSheet, View, Text, TextInput, ScrollView, KeyboardAvoidingView, Platform } from 'react-native'
import Message from './message'


export default class Messages extends React.Component {
  static navigationOptions = ({ navigation }) => ({
    headerTitle: 'Messages',
    headerStyle: {
      backgroundColor: 'rgb(0,0,0)',
    },
    headerTitleStyle: {
      fontSize: 20,
      color: 'rgb(255,255,255)'
    },
    headerTintColor: 'rgb(0,122,255)',
  })

  state = {
    messages: [
      {
        message: 'yeah its not working',
        userId: 1,
        userName: 'Client'
      },
      {
        message: 'what isnt working...',
        userId: 2,
        userName: 'Sean'
      },
      {
        message: 'it, all of it',
        userId: 1,
        userName: 'Client'
      },
      {
        message: 'were on it',
        userId: 3,
        userName: 'Matt'
      },
      {
        message: 'fjdklsajfklsdjafkdjslkafjkdsjal;fdks;lajfdklsjldjskfja;sfjasdfjasdjlkfaj',
        userId: 3,
        userName: 'Matt'
      },
      {
        message: 'great!',
        userId: 1,
        userName: 'Client'
      },
      {
        message: 'blah',
        userId: 1,
        userName: 'Client'
      },
      {
        message: 'derp',
        userId: 2,
        userName: 'Sean'
      },
      {
        message: 'merh!',
        userId: 2,
        userName: 'Sean'
      },
       {
        message: 'help pls',
        userId: 2,
        userName: 'Sean'
      },
    ]
  }

  renderMessages = (messages) => {
    return messages.map((data, i) => <Message data={data} key={i}/>)
  } 

  render() {
    return (
      <ScrollView 
        style={styles.container}
        ref={ref => this.scrollView = ref}
        onContentSizeChange={(contentWidth, contentHeight)=> {this.scrollView.scrollToEnd({animated: true})}}
      >
        <KeyboardAvoidingView
          behavior={Platform.OS == 'ios' ? "position" : null}
        >
          <View>
              {this.renderMessages(this.state.messages)}
              <View style={styles.textBox}>
                <TextInput 
                  style={styles.textInput}
                  placeholder='Reply...'
                  placeholderTextColor={'rgb(216,216,216)'}
                  returnKeyType='done'
                  autoCapitalize='none'
                  selectionColor='#3490dc'
                  multiline={true}
                  blurOnSubmit={true}
                />
              </View>  
          </View>
        </KeyboardAvoidingView>
      </ScrollView>
      )
  }
}



const styles = StyleSheet.create({
    container: {
        //flex: 1,
        backgroundColor: 'rgb(0,0,0)'
    },
    textInput: {
        color: 'rgb(255,255,255)',
        fontSize: 18,
    },
    textBox: {
      borderColor: '#242F39',
      borderWidth: 2,
      borderRadius: 2, 
      padding: 10,
      paddingLeft: 16,
      marginTop: 10,
      backgroundColor: '#0A151F'
    }
})

React native firebase integration with expo bare apps

$
0
0

I am having an interesting problem. I have a react native expo project, bare minimum so it doesn't use any of expo servers and all, and its pure react native project included with react-native-unimodules. So now I want to integrate react-native-firebase in it, IOS was successful but on android I am facing multiple issues, Let's start from the beginning.

1: First I tried to do react-native link firebase..., then i rechecked that all the linking has been done, eg checked settings.gradle, MainApplicaiton.java etc etc, once everything was in the place, after running react-native run-android. The first issue i get it

Could not find method platform() for arguments [com.google.firebase:firebase-bom:21.1.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Okay, So I researched a bit, and everywhere I see, there is a single solution to this, upgrading gradle. So I upgraded gradle to 5.1.1 and even tried few others, After upgrading the error I get it is.

Cannot add task 'wrapper' as a task with that name already exists

So again I researched a bit, and then I tried removing it or adding this solution Cannot add task 'wrapper' as a task with that name already exists It worked (Kind of), now I have another error.

After all this, When i try to compile, I get this one.

ERROR: Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91

I tried to troubleshoot this one too, adding googlePlayServices, firebase in my ext and so on. Nothing works though.

So now I am stuck and its very important to integrate react-native-firebase along with unimodules.

Help would be appreciated. I will post some info about my app here, this stage would be before I tried integrating anything. android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 21
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"

    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.2'

        // 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 { url 'https://maven.google.com' }
        maven { url "https://www.jitpack.io" }

    }
}


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

My dependencies

dependencies {
    implementation project(':@react-native-firebase_app')
    implementation project(':appcenter-analytics')
    implementation project(':appcenter')
    implementation project(':react-native-splash-screen')
    implementation project(':react-native-sms-retriever')
    implementation project(':react-native-image-crop-picker')
    implementation project(':@sentry-react-native') 

    implementation project(':react-native-config')
    implementation project(':react-native-onesignal')
    implementation project(':react-native-code-push')
    implementation project(':@react-native-community_async-storage')
    implementation project(':react-native-reanimated')
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-vector-icons')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    compile 'com.google.android.gms:play-services-maps:8.1.0'
    compile 'com.google.android.gms:play-services-plus:8.1.0'
    addUnimodulesDependencies()
}

react-native info

React Native Environment Info:
    System:
      OS: macOS 10.15.1
      CPU: (4) x64 Intel(R) Core(TM) i5-8210Y CPU @ 1.60GHz
      Memory: 86.16 MB / 8.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 12.6.0 - /usr/local/bin/node
      Yarn: 1.17.3 - /usr/local/bin/yarn
      npm: 6.10.2 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    IDEs:
      Android Studio: 3.5 AI-191.8026.42.35.5791312
      Xcode: 11.2.1/11B53 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.10 => 0.59.10 
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-create-library: 3.1.2
      react-native-git-upgrade: 0.2.7

Could not find version matches com.google.android.gms:play-services-base:[15.0.1,16.0.0)

$
0
0

I am using expo - expokit( react-native) to develop my app. Don't know why it failed when build app. I have checked the the same error on Stack overflow but none of them is solved my problem

Here is the error.

org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:154)
org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.gradle.internal.exceptions.LocationAwareException: Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
    at org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:74)
Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve com.google.android.gms:play-services-basement:[15.0.0, 16.0.0).
Required by:
    project :app > com.facebook.android:audience-network-sdk:5.1.1
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.DynamicVersionResolver.resolve(DynamicVersionResolver.java:122)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainDependencyToComponentIdResolver.resolve(RepositoryChainDependencyToComponentIdResolver.java:72)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.ComponentResolversChain$DependencyToComponentIdResolverChain.resolve(ComponentResolversChain.java:150)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.SelectorState.resolve(SelectorState.java:170)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.selectors.SelectorStateResolver.buildResolveResults(SelectorStateResolver.java:103)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.selectors.SelectorStateResolver.resolveSelectors(SelectorStateResolver.java:79)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.selectors.SelectorStateResolver.selectBest(SelectorStateResolver.java:53)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.performSelection(DependencyGraphBuilder.java:232)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.performSelectionSerially(DependencyGraphBuilder.java:213)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.resolveEdges(DependencyGraphBuilder.java:200)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.traverseGraph(DependencyGraphBuilder.java:155)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.resolve(DependencyGraphBuilder.java:126)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultArtifactDependencyResolver.resolve(DefaultArtifactDependencyResolver.java:123)
    at org.gradle.api.internal.artifacts.ivyservice.DefaultConfigurationResolver.resolveGraph(DefaultConfigurationResolver.java:167)
    at org.gradle.api.internal.artifacts.ivyservice.ShortCircuitEmptyConfigurationResolver.resolveGraph(ShortCircuitEmptyConfigurationResolver.java:89)
    at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver.resolveGraph(ErrorHandlingConfigurationResolver.java:73)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$5.run(DefaultConfiguration.java:533)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveGraphIfRequired(DefaultConfiguration.java:524)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveToStateOrLater(DefaultConfiguration.java:509)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.access$1800(DefaultConfiguration.java:123)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationTaskDependency.visitDependencies(DefaultConfiguration.java:1514)
    ... 96 more
Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Failed to list versions for com.google.android.gms:play-services-basement.
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingModuleComponentRepository$ErrorHandlingModuleComponentRepositoryAccess.listModuleVersions(ErrorHandlingModuleComponentRepository.java:126)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.DynamicVersionResolver$VersionListResult.process(DynamicVersionResolver.java:536)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.DynamicVersionResolver$VersionListResult.resolve(DynamicVersionResolver.java:521)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.DynamicVersionResolver$RepositoryResolveState.resolve(DynamicVersionResolver.java:290)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.DynamicVersionResolver.findLatestModule(DynamicVersionResolver.java:177)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.DynamicVersionResolver.findLatestModule(DynamicVersionResolver.java:169)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.DynamicVersionResolver.resolve(DynamicVersionResolver.java:111)
    ... 121 more
Caused by: org.gradle.api.resources.ResourceException: Unable to load Maven meta-data from https://jcenter.bintray.com/com/google/android/gms/play-services-basement/maven-metadata.xml.
    at org.gradle.api.internal.artifacts.repositories.maven.MavenMetadataLoader.load(MavenMetadataLoader.java:54)
    at org.gradle.api.internal.artifacts.repositories.maven.MavenVersionLister.listVersions(MavenVersionLister.java:48)
    at org.gradle.api.internal.artifacts.repositories.metadata.DefaultMavenPomMetadataSource.listModuleVersions(DefaultMavenPomMetadataSource.java:73)
    at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver.doListModuleVersions(ExternalResourceResolver.java:210)
    at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver.access$200(ExternalResourceResolver.java:90)
    at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver$RemoteRepositoryAccess.listModuleVersions(ExternalResourceResolver.java:440)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository$ResolveAndCacheRepositoryAccess.listModuleVersions(CachingModuleComponentRepository.java:360)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingModuleComponentRepository$ErrorHandlingModuleComponentRepositoryAccess.listModuleVersions(ErrorHandlingModuleComponentRepository.java:121)
    ... 127 more
Caused by: org.gradle.api.resources.ResourceException: Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-basement/maven-metadata.xml'.
    at org.gradle.internal.resource.ResourceExceptions.failure(ResourceExceptions.java:74)
    at org.gradle.internal.resource.ResourceExceptions.getFailed(ResourceExceptions.java:57)
    at org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor.copyToCache(DefaultCacheAwareExternalResourceAccessor.java:201)
Caused by: org.gradle.internal.resource.transport.http.HttpRequestException: Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-basement/maven-metadata.xml'.
    at org.gradle.internal.resource.transport.http.HttpClientHelper.performRequest(HttpClientHelper.java:96)
    ... 157 more

Here is the app/build.gradle

buildscript {
  repositories {
    google()
    maven { url 'https://maven.fabric.io/public' }
    maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
    maven { url 'https://maven.google.com'}
  }

  dependencies {
    classpath 'io.fabric.tools:gradle:1.26.1'
    classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1, 0.99.99]'
  }

defaultConfig {
    applicationId 'com.youmed.info'
    minSdkVersion safeExtGet("minSdkVersion", 21)
    targetSdkVersion safeExtGet("targetSdkVersion", 28)
    versionCode 13
    versionName '1.2.2'
    multiDexEnabled true
  }
dependencies {

  implementation 'com.android.support:multidex:1.0.1'
  implementation "androidx.annotation:annotation:1.1.0"
}
.....
// This has to be down here for some reason
apply plugin: 'com.google.gms.google-services'
}

Here is the project/build.gradle

buildscript {
  ext {
    minSdkVersion = 21
    targetSdkVersion = 28
    compileSdkVersion = 28
    buildToolsVersion = '28.0.0'
    supportLibVersion = '28.0.0'
    kotlinVersion = '1.3.21'
  }
  repositories {
    google()
    jcenter()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:3.3.2'
    classpath 'com.google.gms:google-services:3.2.1'
  }
}
allprojects {
  repositories {
google()
    jcenter()
    maven { url "https://jitpack.io" }
    maven { url 'https://maven.google.com'}
}
}

Anyone know How to solve this problem

Stacked TouchableOpacity inside another TouchableOpacity is not clickable

$
0
0

Even though this document (https://facebook.github.io/react-native/docs/gesture-responder-system.html) states, that touch events are passed down to the children and are only consumed by a parent, if the child doesn't react on the event, I face the issue, that a TouchableOpacity nested inside another TouchableOpacity doesn't react properly on touches.

My structure is like follows

<ScrollView>
  <TouchableOpacity onPress={() => console.log('This is printed always')}>
    <View>
      <Text>I can click here</Text>
      <TouchableOpacity onPress={() => console.log('This is printed never')}>
        <Text>I can click here but the outer onPress is called instead of the inner one</text>
      </TouchableOpacity>
    </View>
  </TouchableOpacity>
</ScrollView>

The same happens for Buttons inside TouchableOpacitys: Clicking the Buttons calls the onPress method of the parent TouchableOpacity

Am I overseeing something?

how can i reduce expo build ios size, it is around 188 MB,

$
0
0

I have successfully run the expo build: ios command but the resultant IPA file is close to 188MB which is really strange as the app has only a few pages with listViews etc. What may be the reason for such a huge size? The same build size for Android is only about 22MB.


Is it possible to change Android targetSdkVersion after release?

$
0
0

I have built a mobile app by using React Native and published to google play store few days ago. I am trying to change targetSdkVersion to 27 from current version which is 28. I wonder this is possible even though I have already published to play store.

Current version

Current version is like this and I am trying to change these like below.

buildToolsVersion "27.0.3"
minSdkVersion 16
compileSdkVersion 27
targetSdkVersion 27
supportLibVersion "27.0.3"

Install a PFX/SSL certificate downloaded from the server on Android/iOS device in a React Native app?

$
0
0

I am building a React Native application that downloads an SSL certificate file or a PFX from the server or a remote file storage. After getting this file, I want to install this certificate onto the device so that only my app can access it. I want to use this certificate to facilitate secure API calls to another server that talks HTTPS. I am assuming that I should use the Keychain on iOS and Keystore on Android for storing the certificate but I am not sure if it enables me to store a PFX. And after storing it, how do I use it for the API calls that I make subsequently?

error Option "--entry-file" is missing. Run CLI with --verbose flag for more details

$
0
0

I tried to install native react and when I enter the command npm run android-windows there;s error.

How to solve this?

This is my packages.json

{ "name": "Fyp", "version": "0.0.1", "private": true, "scripts": { "start": "react-native start", "test": "jest", "lint": "eslint .", "android-windows": "react-native bundle --platform android --dev false npm run android-windows--entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && react-native run-android" }, "dependencies": { "react": "16.8.6", "react-native": "0.60.5" }, "devDependencies": { "@babel/core": "7.5.5", "@babel/runtime": "7.5.5", "@react-native-community/eslint-config": "0.0.3", "babel-jest": "24.9.0", "eslint": "6.3.0", "jest": "24.9.0", "metro-react-native-babel-preset": "0.54.1", "react-test-renderer": "16.8.6" }, "jest": { "preset": "react-native" } }

This is the error

error Option "--entry-file" is missing. Run CLI with --verbose flag for more details. Error: Option "--entry-file" is missing at C:\Users\user\Fyp\node_modules\react-native\node_modules@react-native-community\cli\build\tools\assertRequiredOptions.js:51:13 at Array.forEach () at assertRequiredOptions (C:\Users\user\Fyp\node_modules\react-native\node_modules@react-native-community\cli\build\tools\assertRequiredOptions.js:40:11) at Command.handleAction (C:\Users\user\Fyp\node_modules\react-native\node_modules@react-native-community\cli\build\cliEntry.js:159:42) at Command.listener (C:\Users\user\Fyp\node_modules\commander\index.js:315:8) at Command.emit (events.js:209:13) at Command.parseArgs (C:\Users\user\Fyp\node_modules\commander\index.js:651:12) at Command.parse (C:\Users\user\Fyp\node_modules\commander\index.js:474:21) at setupAndRun (C:\Users\user\Fyp\node_modules\react-native\node_modules@react-native-community\cli\build\cliEntry.js:210:24) at Object.run (C:\Users\user\Fyp\node_modules\react-native\node_modules@react-native-community\cli\build\cliEntry.js:173:11) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! Fyp@0.0.1 android-windows: react-native bundle --platform android --dev false npm run android-windows--entry-file index.js --bundle-output android/app/src/main/ass ets/index.android.bundle --assets-dest android/app/src/main/res && react-native run-android npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the Fyp@0.0.1 android-windows script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\user\AppData\Roaming\npm-cache_logs\2019-09-06T15_03_19_543Z-debug.log

How can i call a function in React native when onDestroy method is called in Android Studio?

$
0
0

I want to save my last visited screen by the user in Async Storage before the user exits the application. As there is no lifecycle event in react-native to look for an app being closed, I want to trigger a function in react-native when OnDestroy event occurs in android.

Print a document html directly with react-native-print

$
0
0

The device I refer to is the Sunmi V2 PRO.
I imported and linked the react-native-print library in my project.

When I start the RNPrint.print () function passing my html string, it does not print directly, but goes to a screen where I can choose other printers (there is only one) or download the pdf. Is there a way to skip this screen and start printing directly?

I simply call this in my function:

await RNPrint.print({ html })

Is there a way to arrange OS home screen app icons through an app and if so how?

$
0
0

I'd like to arrange os homescreen app icons through my app but I'm not sure if that's even possible. Is there a way to do this and if so, how?

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?


Verify phone number(Otp verification) using react-native-firebase

$
0
0

I am using react-native-firebase v^5.5.6. Now i want to just verify my phone number using firebase. To verify phone number i am using

firebase.auth().verifyPhoneNumber(phoneNumber).on('state_changed', (phoneAuthSnapshot) => {

switch (phoneAuthSnapshot.state) {

  case firebase.auth.PhoneAuthState.CODE_SENT: // or 'sent'
    console.log('code sent');

    break;
  case firebase.auth.PhoneAuthState.ERROR: // or 'error'
    console.log('verification error');

    break;

  // ---------------------
  // ANDROID ONLY EVENTS
  // ---------------------
  case firebase.auth.PhoneAuthState.AUTO_VERIFY_TIMEOUT: // or 'timeout'
    console.log('auto verify on android timed out');

    break;
  case firebase.auth.PhoneAuthState.AUTO_VERIFIED: // or 'verified'

    console.log('auto verified on android');
    console.log(phoneAuthSnapshot);

    break;
}
}, (error) => {

console.log(error);
}, (phoneAuthSnapshot) => {

console.log(phoneAuthSnapshot);
});

Using this method i got message state sent but always got code null

Response:

{verificationId: "AM5PThDkqMZC-alBDWvnn97ABxlVlFIZpEhN55sVLeR0b3_yar…rq9IksEpNBvU8tgv5kaE5CvWfIVv-Jn7YCNqVXtBrzD75j6og", code: null, error: null, state: "sent"}

Please help me.

Many thanks in advance

React Native app crashes on initial install when first opened

$
0
0

I have a react native app that crashes the first time after it is downloaded from the play store.

After it crashes, you can open it again, and it works fine.

It is only affected the first time it opens.

This is the log from when it crashes the first time:

[09:48:54] D | ReactNative ▶︎ [CodePush] Loading JS bundle from "assets://index.android.bundle"

[09:48:54] D | ReactNative ▶︎ ReactInstanceManager.ctor()

[09:48:54] D | ReactNative ▶︎ ReactInstanceManager.createReactContextInBackground()
                           └ ReactInstanceManager.recreateReactContextInBackgroundInner()

After that, it crashes.

Could not sign in Google account on android emulator with react-native app

$
0
0

I have react-native app, and it works thru Google account. And when i launch my app on android emulator i can not sign in Google account. Get an error: "There was a problem communicating with Google servers. Try again later". My steps to reproduction:

  • Reinstalled app and android emulator.
  • Cleaned app and emulator cache.
  • Checked different emulators model with different API.
  • Tried to sign in Google account in android emulator from google chrome, from Settings => Accounts => Add Account => Google.

And all this steps is not working for me. Every time the same situation: the process of loading, spinner is launching about a minute, and after get an error: "Could not sign in". Can somebody help me please.

enter image description here

How to register touches from a nested View with an offset? [Android specific]

$
0
0

In the code below you can see a View with a panResponder assigned to it. The View is nested in a wrapper, although it's rendered with an offset that pushes half of the View outside the wrapper. The problem is that the View isn't responding to touches (in this case — scrolling) when they're being made outside the wrapper.

So the View touches are being registered inside the wrapper, but not outside, despite the fact that the View is actually located inside the wrapper.

How can I make touches work even outside the wrapper?

import React from 'react';
import {
  StyleSheet,
  View,
  PanResponder,
} from 'react-native';

const App = () => {
  const panResponder = PanResponder.create({
    onStartShouldSetPanResponder: () => true,
    onPanResponderMove: (e, g) => {
      console.log(g.dy)
    }
  });

  return (
    <View style={styles.container}>
      <View style={styles.wrapper}>
        <View style={styles.pan} {...panResponder.panHandlers}/>
      </View>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    justifyContent: 'center',
    alignItems: 'center',
  },
  wrapper: {
    width: 100,
    height: 100,
    backgroundColor: 'black',
  },
  pan: {
    width: 50,
    height: 50,
    position: 'absolute',
    bottom: -25,
    backgroundColor: 'darkviolet',
    alignSelf: 'center',
  },
});

Expo app crashes only in android when keyboard appears

$
0
0

I have login screen in my app. When user focuses TextInput keyboard appears. Then Expo App crashes immediately.

How do I fix this error?

I was able to make a screenshot during crash:

enter image description here

Version of my device/app:

  • Samsung J3;
  • Android 9;
  • expo SDK 35;
  • Expo Android App version 2.13.1.
Viewing all 28479 articles
Browse latest View live


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