我们一直坚持这个错误几周,尝试从Stack Overflow上的相同问题的答案的所有建议之前。
我们已经尝试检查Index.js,MainActivity.js中的应用程序名称匹配以及我们维护的名为app.json的参数文件。
我们面临的问题是'npm start'被卡在加载依赖图,完成...消息,并且react-native运行android生成一个apk,给出'应用SmartMedi未注册'。
代码部分复制如下。
main activity.Java
package com.SmartMedi;
import com.facebook.react.ReactActivity;
import com.calendarevents.CalendarEventsPackage;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "SmartMedi";
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
CalendarEventsPackage.onRequestPermissionsResult(requestCode, permissions, grantResults);
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
app.json
{
"name": "SmartMedi",
"displayName": "SmartMedi"
}
index.js
/** @format */
import {AppRegistry} from 'react-native';
import App from './src/components/Main';
//Registration,Main,SearchScreen
import {name as appName} from './app.json';
// type Props = {};
console.disableYellowBox = true;
AppRegistry.registerComponent(appName, () => App);
的package.json
{
"name": "SmarMedi",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
...
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
...
"native-base": "^2.7.2",
"react": "16.4.1",
....
"react-native": "^0.55.4",
.....
}
你的package.json有"name": "SmarMedi"
。 SmartMedi
缺少T.
当您运行应用程序时会发生这种情况,但您忘记关闭之前项目打开的地铁捆绑包。在模拟器上卸载应用程序,重新启动终端并重新运行项目。