本文中全部问题的安卓环境是 “react”:”16.8.3”node
“react-native”:”0.59.9”
“React-native-camera”:”^3.3.1"
复制代码
undefined is not an object(evaluating '_react2.PropTypes.oneOfType’) 碰到这样的问题缘由在于PropTypes的引用,react从16版本开始,已经将PropTypes功能移出来了,能够从第三方包'prop-types’中引用react
解决方法:android
找到目标文件中的react-native
import {PropTypes } from ‘react’
复制代码
替换成api
Import PropTypes from ‘prop-types’
复制代码
再将项目中的app
React.PropTypes.
复制代码
替换成maven
PropTypes.
复制代码
最后不要忘了安装prop-types包 yarn add prop-typeside
Could not resolve project :react-native-camera和Cannot choose between the following configurations of project :react-native-camera:gradle
在android/app/build.gradle文件中的defaultconfig下添加ui
missingDimensionStrategy 'react-native-camera', 'general’
复制代码
在android/build.gradle里添加
allprojects {
repositories {
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
}
}
复制代码
Unable toloadscript.Make sure you're either running a metro server(run 'react-nativestart' ) or thatyour bundle 'index.android.bundle' is packaged correctly for release. 项目目录/android/app/build.gradle里添加下面三个
project.ext.react = [
bundleInDebug:true,
bundleInAlpha:true,
bundleInBeta:true
]
复制代码
org.gradle.api.tasks.TaskExecutionException:Exectuin failed for task
在AndroidManifest中
schemas.android.com/apk/res/and…"
xmlns:tools="schemas.android.com/tools" //添加这个
package="cn.tuniu.guide">
复制代码
<application tools:node="replace//添加这个
tools:node="replace"彻底替换低优先级元素
Error: Program type already present: android.support.v4.app.INotificationSideChannel 向gradle.properties添加如下内容:
android.enableJetifier=true
android.useAndroidX=true
复制代码
android.app.Application cannot be cast to com.facebook.react.ReactApplication 在AndroidManifest.xml文件中添加
<application
android:name=".MainApplication”
复制代码
跟multiDex有关的问题 在app的build.gradle的defaultconfig中添加
multiDexEnabled : true
跟V4有关的问题 在app的build.gradle的dependencies中添加
implementation'com.android.support:support-v4:28.0.0'
以此记录引入react-native-camera插件碰到的问题,iOS端并无任何报错,Android端不熟悉,花了本人两天时间