标签: react-native-android

内存不足应用程序崩溃React Native

使用React Native 0.33几秒钟后,应用程序停止(仅在Android上测试)

看看android日志我得到:

在此输入图像描述

我不知道如何检查问题.

reactjs react-native react-native-android

4
推荐指数
2
解决办法
7884
查看次数

在react-native中的图像视图中从相机获取最近点击的图像

我正在我的反应原生应用程序中实现相机.我希望在点击后在同一屏幕上的小图像视图中显示该相机最近拍摄的图像.但我没有得到如何访问最近点击的图像.每当通过手机点击任何新图像时,它都会被赋予一个默认的随机名称,我如何在图像视图的源代码中引用它?请告诉我一些方法.我的代码是

 class Incident extends Component {
    constructor(props)
    {  super(props)

        this.state=  {path:"",show:false,video:Camera.constants.CaptureMode.video,camera:Camera.constants.CaptureMode.camera}    
      }
    render() {
      return (
              <View style={styles.container}>
             <View style={{flex:72}}>
             <Camera
              ref={(cam) => {
               this.camera = cam;
                }}
              style={styles.preview}
               aspect={Camera.constants.Aspect.fill}
              captureMode={this.state.camera}>

          </Camera>

  </View>
  <View style={{flex:8,opacity:0.5,backgroundColor:'black'}}>

    {()=>this.showClickedImage()}

  </View>


  <View style={{flex:10,flexDirection:'row',justifyContent:'space-between',backgroundColor:'#f3396b'}}>
  <TouchableOpacity style={{flex:33,flexDirection:'column', alignItems: 'center',paddingTop:10}}>
  <Image style={styles.icon} source={require('./Images/menu.png')}/>
  <Text>Home</Text>
  </TouchableOpacity>



  <TouchableOpacity style={{flex:34,flexDirection:'column', height:70,alignItems: 'center',borderColor:'#dd1e52',borderWidth:1,paddingTop:5}} 
                               onPress={()=>this.takePicture()}>
  <Image style={{width:50,height:50}} source={require('./Images/capture.png')}/>

  </TouchableOpacity>





  <TouchableOpacity style={{flex:33,flexDirection:'column', alignItems: 'center',paddingTop:10}}>
  <Image style={styles.icon} source={require('./Images/profile.png')}/>
  <Text>Profile</Text>
  </TouchableOpacity>


  </View>
  </View>
);
      }

      showClickedImage()
  { 
        return <View style={{flex:1,height:40,width:40, borderWidth:1,borderColor:'black'}}>
               <Image style={{width:40,height:40}} source= {{uri: …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-camera react-native-android

4
推荐指数
1
解决办法
3459
查看次数

React Native:Native模块AppStateModule尝试覆盖模块名称AppState的AppStateModule

我有一个工作的iOS反应本机应用程序(反应本机v 0.38).我试图在android中运行相同的应用程序. 在此输入图像描述 我手动链接了所有这些库(我现在在iOS中使用):

react-native-camera
react-native-code-push
react-native-device-info
react-native-google-analytics-bridge
react-native-i18n
react-native-push-notification
react-native-restart
react-native-sqlite-storage
Run Code Online (Sandbox Code Playgroud)

Settings.gradle:

include ':app'
include ':react-native-sqlite-storage'
project(':react-native-sqlite-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sqlite-storage/src/android')
include ':react-native-restart'
project(':react-native-restart').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-restart/android')
include ':react-native-push-notification'
project(':react-native-push-notification').projectDir = file('../node_modules/react-native-push-notification/android')
include ':app', ':react-native-i18n'
project(':react-native-i18n').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-i18n/android')
include ':react-native-google-analytics-bridge', ':app'
project(':react-native-google-analytics-bridge').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-analytics-bridge/android')
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir,   '../node_modules/react-native-camera/android')
Run Code Online (Sandbox Code Playgroud)

build.gradle:

// Top-level build file where you can add …
Run Code Online (Sandbox Code Playgroud)

javascript android react-native react-native-android

4
推荐指数
1
解决办法
2655
查看次数

为什么shadowColor:'...' - 不适用于Android上的"react-native-drawer"组件的抽屉样式?

可能有人知道为什么"shadowColor"属性不适用于Android上的抽屉样式?(iOS看起来一切都好)

重现/编码片段/截图的步骤

<Drawer
 type="overlay"
 ...
 styles={{
  drawer: {shadowColor: 'black', shadowOpacity: 0.8, shadowRadius: 2}
   ...
 }}   
>
Run Code Online (Sandbox Code Playgroud)

截图

环境

react-native-drawer版本:2.3.0

React Native版本:0.41.2

平台(iOS,Android或两者兼而有之?):Android

设备信息模拟器/设备? - 模拟器Android 4.1(API16),模拟器Android 7.1.1(API25)

OS版本? - MacOS 10.12.3

调试/发布? - 调试

react-native react-native-android

4
推荐指数
1
解决办法
1398
查看次数

在react-native中调用其他组件的函数

如何在react-native中调用其他组件的函数?

我有这个自定义组件,它在另一个地方呈现另一个组件和一个图像按钮.当点击图像时,我想从另一个组件调用一个函数.执行下面的示例时,我得到了undefined is not an object (evaluating this.otherComponent.doSomething')

export default class MainComponent extends Component {

  _onPressButton() {
    this.otherComponent.doSomething();
  }

  render() {
    return (
      <View style={styles.container}>
        <TagContainer style={styles.flow_container} ref={(instance) => this.otherComponent = instance}>
        </TagContainer>
        <TouchableHighlight onPress={this._onPressButton}><Image source={require('./img/ic_add.png')} style={styles.add_tags_button_view} /></TouchableHighlight>
      </View>
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

和

export default class OtherComponent extends Component {

    addTag() {
        this.state.tags = this.state.tags.push("plm");
        console.log('success..');
    }

    ....
}
Run Code Online (Sandbox Code Playgroud)

javascript react-native react-native-android

4
推荐指数
2
解决办法
1万
查看次数

如何设置或配置Android的反应导航选项卡以适应

我有一个使用react native的标签导航,react-navigation 我的5个标签在Android上太过于挤压但看起来很适合iOS.如何设置标签的样式以适应Android?我可以将标签水平滚动吗?我想我记得在某个地方看过 - 那是标准的android行为吗?

react-native-android react-navigation

4
推荐指数
1
解决办法
1万
查看次数

React Native:如何在Android上更改最近的应用背景标题颜色?

我想使用react-native更改最近的应用程序视图中的背景标题颜色(当您按下Android上的概述方形按钮时).

您可以在下面的图像中看到Facebook应用程序具有蓝色背景颜色,但我的比特币FOMO计算器应用程序具有默认的灰色.

最近的应用视图

谢谢

react-native react-native-android

4
推荐指数
1
解决办法
1677
查看次数

在Android上增加react-native中滑块的大小

有没有一种方法可以使滑块的按钮/拇指(绿色圆圈)更大,以设置高度和宽度。在iOS中,它看起来不错,但在Android上却很小。

在此处输入图片说明

slider react-native react-native-android

4
推荐指数
1
解决办法
4178
查看次数

反应原生变换 - 错误找不到预设"babel-preset-react-native-stage-0

我开始弹出世博会,经过这么多的努力,我能够解决所有构建问题.当我使用'sudo react-native run-android'运行应用程序时,我开始收到以下错误

错误:

The development server returned response code 500
Bundling `index.android.js`  [development, non-minified, hmr disabled]  
0.0% (0/1), failed.
error: bundling failed: "TransformError: 

/Development/SourceCode/MobileApp/index.android.js: 
Couldn't find preset \"babel-preset-react-native-stage-0/decorator-support\" relative to directory \"/Development/SourceCode/MobileApp\""
Run Code Online (Sandbox Code Playgroud)

我尝试了在github和SO中给出的几乎所有可能的修复

  1. 卸载最新版本的babel-preset-react-native并重新安装sudo yarn add babel-preset-react-native@2.1.0
  2. 清除缓存Yarn Cache,npm缓存
  3. 删除构建文件夹,删除npm模块并重新安装所有模块
  4. 很少有人通过移除守望者来解决问题,但我根本不使用守望者.
  5. 添加.babelrc提到装饰器支持预设如下,此修复也无法正常工作.

.babelrc 文件看起来像这样

    {
      "presets": [
        "react-native",
        "babel-preset-react-native-stage-0/decorator-support"
      ],
      "env": {
        "development": {
          "plugins": [
            "transform-react-jsx-source"
          ]
        }
      }
    }
Run Code Online (Sandbox Code Playgroud)

这些修复都不适合我.使用babel-preset-react-native@2.1.0也没有解决问题,因为这是主要的修复.

babel reactjs babeljs react-native react-native-android

4
推荐指数
1
解决办法
4959
查看次数

react-native启动意外令牌

使用react-native时,我在启动命令时遇到错误.第63行的文件 projectName /node_modules/@babel/core/lib/transformation/file/file.js给出了错误

constructor(options, {
                     ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Module._extensions..js (module.js:417:10)
    at Object.require.extensions.(anonymous function) [as .js] (/home/cread/WHOOP-ReactNative/whoopApp/node_modules/babel-register/lib/node.js:152:7)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/cread/WHOOP-ReactNative/whoopApp/node_modules/@babel/core/lib/index.js:123:36)
    at Module._compile (module.js:410:26)
Run Code Online (Sandbox Code Playgroud)

这是我的package.json文件

{
  "name": *name*,
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.3.0-alpha.2",
    "react-native": "0.54.2",
    "react-native-elements": "^0.19.1",
    "react-native-keyboard-aware-scroll-view": "^0.5.0",
    "react-native-modal-dropdown": "^0.6.2",
    "react-native-sound": "0.10.9",
    "react-native-vector-icons": "^4.5.0",
    "react-navigation": "^1.5.8"
  },
  "devDependencies": …
Run Code Online (Sandbox Code Playgroud)

javascript babeljs react-native react-native-android

4
推荐指数
1
解决办法
909
查看次数