本文中所有问题的安卓环境是
“react”:”16.8.3”
“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’中引用
解决方法:
找到目标文件中的
import {PropTypes } from ‘react’
替换成
Import PropTypes from ‘prop-types’
再将项目中的
React.PropTypes.
替换成
PropTypes.
最后不要忘了安装prop-types包
Could not resolve project :react-native-camera
和Cannot choose between the following configurations of project :react-native-camera:
- generalDebugRuntimeElements
- mlkitDebugRuntimeElements
在android/app/build.gradle文件中的defaultconfig下添加
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 that
your 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中添加
http://schemas.android.com/apk/res/android"
xmlns:tools="http://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中添加
multiDexEnabledtrue
跟V4有关的问题
在app的build.gradle的dependencies中添加
implementation'com.android.support:support-v4:28.0.0'