赞
踩
升级到android studio 3.6.1遇到Unsupported Modules Detected的问题的解决方法:
现象就是每次打开项目时,都会提示如下警告:
Unsupported Modules Detected: Compilation is not supported for following modules:
android-lottie-react-native, android-react-native-image-crop-picker,
lottie-react-native-src-android-lottie-react-native,
node_modules-react-native-dialog-android-react-native-dialog~1, node_modules-react-native-dialog-android-react-native-dialog~2,
lottie-react-native-src-android-lottie-react-native~2, node_modules-react-native-image-crop-picker-android-react-native-image-crop-picker,
lottie-react-native-src-android-lottie-react-native~1, node_modules-react-native-image-crop-picker-android-react-native-image-crop-picker~2
而且项目中会出现多余的module文件夹,且不可删除。经过多次尝试,发现是因为升级到android studio 3.6.1以后,react native项目中依赖的module里重新build之后多出了一些xxx.iml文件,直接删除掉项目的.idea文件夹和删除掉.iml文件都还是会出现;
而多出的xxx.iml文件内容如下,此为build错误的情况下出现的:
- <?xml version="1.0" encoding="UTF-8"?>
- <module version="4">
- <component name="NewModuleRootManager">
- <orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
- <orderEntry type="sourceFolder" forTests="false" />
- </component>
- </module>
这里有一个误区就是,我一开始删除的是react native根项目中的.idea文件夹,所以无效。直接删除android文件夹下的.idea文件夹应该是直接有效的。或者不想都删除的话,
可以只更改 .idea/modules.xml,把多余的未成功build的module记录删除即可。
更改前:
- <?xml version="1.0" encoding="UTF-8"?>
- <project version="4">
- <component name="ProjectModuleManager">
- <modules>
- <module fileurl="file://$PROJECT_DIR$/../node_modules/lottie-react-native/src/android/lottie-react-native.iml" filepath="$PROJECT_DIR$/../node_modules/lottie-react-native/src/android/lottie-react-native.iml" group="demo/lottie-react-native" />
- <module fileurl="file://$PROJECT_DIR$/../node_modules/react-native-date-picker/android/react-native-date-picker.iml" filepath="$PROJECT_DIR$/../node_modules/react-native-date-picker/android/react-native-date-picker.iml" group="demo/react-native-date-picker" />
- <module fileurl="file://$PROJECT_DIR$/../node_modules/lottie-react-native/src/android/lottie-react-native-src-android-lottie-react-native.iml" filepath="$PROJECT_DIR$/../node_modules/lottie-react-native/src/android/lottie-react-native-src-android-lottie-react-native.iml" group="demo/lottie-react-native" />
- <module fileurl="file://$PROJECT_DIR$/../node_modules/lottie-react-native/src/android/lottie-react-native-src-android-lottie-react-native~1.iml" filepath="$PROJECT_DIR$/../node_modules/lottie-react-native/src/android/lottie-react-native-src-android-lottie-react-native~1.iml" group="demo/lottie-react-native" />
- <module fileurl="file://$PROJECT_DIR$/../node_modules/react-native-image-crop-picker/android/react-native-image-crop-picker.iml" filepath="$PROJECT_DIR$/../node_modules/react-native-image-crop-picker/android/react-native-image-crop-picker.iml" group="demo/react-native-image-crop-picker" />
- <module fileurl="file://$PROJECT_DIR$/../node_modules/react-native-splash-screen/android/react-native-splash-screen.iml" filepath="$PROJECT_DIR$/../node_modules/react-native-splash-screen/android/react-native-splash-screen.iml" group="demo/react-native-splash-screen" />
- </modules>
- </component>
- </project>
更改后:
- <?xml version="1.0" encoding="UTF-8"?>
- <project version="4">
- <component name="ProjectModuleManager">
- <modules>
- <module fileurl="file://$PROJECT_DIR$/../node_modules/lottie-react-native/src/android/lottie-react-native.iml" filepath="$PROJECT_DIR$/../node_modules/lottie-react-native/src/android/lottie-react-native.iml" group="demo/lottie-react-native" />
- <module fileurl="file://$PROJECT_DIR$/../node_modules/react-native-date-picker/android/react-native-date-picker.iml" filepath="$PROJECT_DIR$/../node_modules/react-native-date-picker/android/react-native-date-picker.iml" group="demo/react-native-date-picker" />
- <module fileurl="file://$PROJECT_DIR$/../node_modules/lottie-react-native/src/android/lottie-react-native-src-android-lottie-react-native.iml" filepath="$PROJECT_DIR$/../node_modules/lottie-react-native/src/android/lottie-react-native-src-android-lottie-react-native.iml" group="demo/lottie-react-native" />
- <module fileurl="file://$PROJECT_DIR$/../node_modules/react-native-image-crop-picker/android/react-native-image-crop-picker.iml" filepath="$PROJECT_DIR$/../node_modules/react-native-image-crop-picker/android/react-native-image-crop-picker.iml" group="demo/react-native-image-crop-picker" />
- <module fileurl="file://$PROJECT_DIR$/../node_modules/react-native-splash-screen/android/react-native-splash-screen.iml" filepath="$PROJECT_DIR$/../node_modules/react-native-splash-screen/android/react-native-splash-screen.iml" group="demo/react-native-splash-screen" />
- </modules>
- </component>
- </project>
然后重新build一下项目即可。仅此记录一下,项目的结构终于恢复正常了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。