1、
import com.facebook.react.*.*** not resolved,找到依赖包下android/build.gradle下面
implementation "com.facebook.react:react-native:+" 改成
implementation ("com.facebook.react:react-native:0.61.5") { force = true }
注意:标红的根据自己项目的react-native版本号进行修改,
出现此问题的原因是react-native,用+找不到具体的版本了,
2、SyntaxError: Unexpected token ':'. Expected a ')' or a ',' after a parameter declaration.
第一种解决办法:把依赖包 metro-react-native-babel-preset
from 0.58.0
to 0.59.0
to resolve it。
如果还不生效,请清理缓存,yarn( yarn start --reset-cache
),npm(npx react-native start --reset-cache),最后重启服务即可
第二种解决办法:把babel.config.js从
module.exports = { presets: ['module:metro-react-native-babel-preset'], };
改成
module.exports = { presets: [['module:metro-react-native-babel-preset', { unstable_disableES6Transforms: true }]], };
如果还不生效,请清理缓存,yarn( yarn start --reset-cache
),npm(npx react-native start --reset-cache),最后重启服务即可
3、com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
C:\Users\xxx\.gradle\caches\transforms-2\files-2.1\30504f40a9bfe3e88ce032af09250a1b\core-1.7.0\res\values\values.xml:105:5-114:25: AAPT: error: resource android:attr/lStar not found.
将报错依赖包下的android/build.gradle里面的
implementation "com.facebook.react:react-native:+" 改成
implementation ("com.facebook.react:react-native:0.61.0") { force = true }
注意:标红的根据自己项目的react-native版本号进行修改,
4、C:/Users/xxx/.gradle/caches/transforms-2/files-2.1/3ad34e1964c1adfe868383dc5611f34a/jetified-react-native-0.71.0-rc.0-release-api.jar!/META-INF/ReactAndroid_release.kotlin_module: Module was compiled with an incompatible ve
rsion of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.0.
将依赖包下面的android/build.gradle里面的kotlin版本改成最新的版本,我改的是
1.5.31