我在执行
npx create-react-native-library react-native-awesome-module
本地模块库工程到yarn example android的时候碰到很多坑,现在一一记录下。
1.Execution failed for task ‘:app:stripDebugDebugSymbols’. > No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi
问题原因:没有指定ndk版本,需要在build.gradle指定下即可
2.SDK location not found. Define location with an ANDROID_SDK_ROOT environment
原因:在执行最开始命令生成的android库工程的时候,没有生成local.properties,这里面指定了sdk.dir,需要从其他工程拷贝一个过来即可
3.yarn android启动应用后app显示unable to load script
需要在example目录下,执行下面的命令
npx 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
注意 index.js 我这边是index.tsx,改一下即可