我正在使用React Native为Android创建项目,并尝试使用以下命令native-base
安装npm install native-base --save
。之后,当我使用react-native link
链接库时,出现如下错误。
rnpm-install ERR! ERRPACKAGEJSON No package found. Are you sure this is a React Native project?
Cannot read property '_text' of undefined
TypeError: Cannot read property '_text' of undefined
at SAXParser.parser_text [as ontext] (/home/codism-8/NewReactWorkSpace/NamazTiming/node_modules/xmldoc/lib/xmldoc.js:235:39)
at emit (/home/codism-8/NewReactWorkSpace/NamazTiming/node_modules/xmldoc/node_modules/sax/lib/sax.js:639:35)
at closeText (/home/codism-8/NewReactWorkSpace/NamazTiming/node_modules/xmldoc/node_modules/sax/lib/sax.js:649:26)
at emitNode (/home/codism-8/NewReactWorkSpace/NamazTiming/node_modules/xmldoc/node_modules/sax/lib/sax.js:643:26)
at SAXParser.write (/home/codism-8/NewReactWorkSpace/NamazTiming/node_modules/xmldoc/node_modules/sax/lib/sax.js:1195:15)
at new XmlDocument (/home/codism-8/NewReactWorkSpace/NamazTiming/node_modules/xmldoc/lib/xmldoc.js:199:15)
at readManifest (/home/codism-8/NewReactWorkSpace/NamazTiming/node_modules/react-native/local-cli/core/android/readManifest.js:20:10)
at Object.projectConfigAndroid [as projectConfig] (/home/codism-8/NewReactWorkSpace/NamazTiming/node_modules/react-native/local-cli/core/android/index.js:41:20)
at Object.keys.forEach.key (/home/codism-8/NewReactWorkSpace/NamazTiming/node_modules/react-native/local-cli/core/index.js:101:36)
at Array.forEach (<anonymous>)
我遵循了本文档http://docs.nativebase.io/docs/GetStarted.html。我没有得到什么问题。请帮助
Package.json
"dependencies": {
"native-base": "^2.12.0",
"react": "16.6.3",
"react-native": "^0.57.7",
"react-native-flash-message": "^0.1.10",
"react-native-linear-gradient": "^2.5.3",
"react-native-modal-datetime-picker": "^6.0.0",
"react-native-navigation": "^2.8.0",
"react-native-tab-view": "^1.3.2",
"react-native-vector-icons": "^6.2.0",
"react-redux": "^6.0.1",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0"
},
答案 0 :(得分:1)
1-确保已在项目目录中完成npm install native-base --save
2-尝试npm i
来解决依赖项问题,然后命令react-native run-android
确保您的依赖项和“ node_modules”文件夹正常工作,并且项目可以运行。
如果没有“ android”或“ ios”文件夹,则可以使用命令react-native eject
,然后链接软件包。
3-编写命令react-native link native-base
,此命令将基于本机的程序包与本机完全链接。
但是,我建议您主要手动链接软件包。
您还可以尝试使用本机基础的先前版本,例如v 2.10.0
。
答案 1 :(得分:0)
感谢@AmirGorji @parashKorat帮助我。对我来说,这个问题来了,因为我已从清单文件中删除了android:roundIcon="@mipmap/ic_launcher_round"
。当我再次输入react-native link
时。我删除了它,因为添加图标后,它显示出缺少圆形图标的错误,暂时删除了。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.namaztiming">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
我不知道这是否是正确的解决方案,但就我而言,它解决了问题。
答案 2 :(得分:0)
我今天遇到了这个问题,我所做的是运行这些命令来清理项目的gradle。
1-转到项目的根目录。
2-运行cd android
3-运行gradlew clean
4-运行cd..
然后运行link
命令