React Native 常见问题(持续更新,欢迎补充)

萌新在学习React Native中,遇到了不少的问题,都心平气和(气的要死)的解决了,特此帮助一下其他的同学。

错误一

React.Children.only expected to receive  a single React element child.

这个问题我是在用Touchable相关组件的时候碰到的,意思是只接受一个子组件,在组件外套一个View标签就好了。

错误二

Could not connect to development server.

服务器没起来,重新启动一下就ok。

错误三

invariant violation:expected a component class,got[object object]

自定义组件首字母大写

错误四

CFBundleIdentifier", Does Not Exist

原因据说是reactnative的问题

我的成功解决方案:react-native upgrade 

错误五

 

Super expression error must either be null or a function,not undefined

 

 

检查一下 

import React,{Component} from 'react';看看是不是写错了

错误六

 java.lang.RuntimeException: unable to load script from assets 'index.android bundle'  ,make sure your bundle is packaged correctly or youu're runing a packager server

 

解决方法:

第一步:先在工作目录创建:android/app/src/main 目录下创建一个  assets空文件夹

第二步:react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

解决成功显示:

Loading dependency graph, done.
bundle: start
bundle: finish
bundle: Writing bundle output to: android/app/src/main/assets/index.android.bundle
bundle: Copying 53 asset files
bundle: Done writing bundle output
bundle: Done copying assets

错误七 安卓摇一摇无法打开调试菜单栏

 

 

@Override
public boolean getUseDeveloperSupport() {
  return BuildConfig.DEBUG;//
  return true;
}

错误八 

error: Duplicate file

Original is here. The version qualifier may be implied

android>app>src>main>res>drawable 里边图片删掉

错误九

Failed to execute aapt

debug可以 release报错

android.enableAapt2=false gradle.properties

gradle.build

// 解决方案开始
subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion     //do this in android/app/build.gradle too
                buildToolsVersion rootProject.ext.buildToolsVersion     //do this in android/app/build.gradle too
            }
        }
    }
}
// 解决方案结束
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值