React Native 是facebook 开源的一套用于开发移动端跨平台App的技术框架,下面为大家讲解一下React Native安装和使用。
公主岭网站建设公司创新互联建站,公主岭网站设计制作,有大型网站制作公司丰富经验。已为公主岭上千多家提供企业网站建设服务。企业网站搭建\成都外贸网站建设要多少钱,请找那个售后服务好的公主岭做网站的公司定做!
react-native init JustNoCode
执行之后,一直卡在Installing react-native package from npm…,但是, 我等了两天,终于成功了:
@feng github react-native init JustNoCodeprompt: Directory JustNoCode already exist. Continue?: (no) yThis will walk you through creating a new React Native project in /Users/fengjian/Code/github/JustNoCodeInstalling react-native package from npm...Setting up new React Native app in /Users/fengjian/Code/github/JustNoCodecreate .gitignorecreate .watchmanconfigcreate index.ios.jscreate index.Android.jscreate ios/main.jsbundlecreate ios/JustNoCode/AppDelegate.hcreate ios/JustNoCode/AppDelegate.mcreate ios/JustNoCode/Base.lproj/LaunchScreen.xibcreate ios/JustNoCode/Images.xcassets/AppIcon.appiconset/Contents.jsoncreate ios/JustNoCode/Info.plistcreate ios/JustNoCode/main.mcreate ios/JustNoCodeTests/JustNoCodeTests.mcreate ios/JustNoCodeTests/Info.plistcreate ios/JustNoCode.xcodeproj/project.pbxprojcreate ios/JustNoCode.xcodeproj/xcshareddata/xcschemes/JustNoCode.xcschemecreate android/app/build.gradlecreate android/app/proguard-rules.procreate android/app/src/main/AndroidManifest.xmlcreate android/app/src/main/res/values/strings.xmlcreate android/app/src/main/res/values/styles.xmlcreate android/build.gradlecreate android/gradle.propertiescreate android/settings.gradlecreate android/app/src/main/res/mipmap-hdpi/ic_launcher.pngcreate android/app/src/main/res/mipmap-mdpi/ic_launcher.pngcreate android/app/src/main/res/mipmap-xhdpi/ic_launcher.pngcreate android/app/src/main/res/mipmap-xxhdpi/ic_launcher.pngcreate android/gradle/wrapper/gradle-wrapper.jarcreate android/gradle/wrapper/gradle-wrapper.propertiescreate android/gradlewcreate android/gradlew.batcreate android/app/src/main/Java/com/justnocode/MainActivity.javaTo run your app on iOS:Open /Users/fengjian/Code/github/JustNoCode/ios/JustNoCode.xcodeproj in XcodeHit Run buttonTo run your app on Android:Have an Android emulator running, or a device connectedcd /Users/fengjian/Code/github/JustNoCodereact-native run-android
显示详细信息
react-native run-android
结果报错,如下:
@feng JustNoCode (master) react-native run-androidStarting JS server...Building and installing the app on the device (cd android && ./gradlew installDebug)...Download https://jcenter.bintray.com/com/android/tools/build/gradle/1.3.1/gradle-1.3.1.pomDownload https://jcenter.bintray.com/com/android/tools/build/gradle-core/1.3.1/gradle-core-1.3.1.pom... ...Download https://jcenter.bintray.com/com/android/tools/lint/lint-api/24.3.1/lint-api-24.3.1.jarFailed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence.java.lang.RuntimeException: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable. at com.android.build.gradle.internal.SdkHandler.getAndCheckSdkFolder(SdkHandler.java:102) ... ... at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMainin.java:61)FAILURE: Build failed with an exception.* Where:Build file '/Users/fengjian/Code/github/JustNoCode/android/app/build.gradle' line: 20* What went wrong:A problem occurred evaluating project ':app'.> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.* Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.BUILD FAILEDTotal time: 52.605 secsCould not install the app on the device, see the error above.
显示详细信息
在.zshrc中配置一下ANDROID_HOME:
export ANDROID_HOME=~/Tools/android-sdk
再运行一次,
@feng JustNoCode (master) react-native run-androidJS server already running.Building and installing the app on the device (cd android && ./gradlew installDebug)...:app:preBuild UP-TO-DATE... ...:app:installDebugInstalling APK 'app-debug.apk' on 'Google Nexus S - 4.1.1 - API 16 - 480x800 - 4.1.1'Installed on 1 device.BUILD SUCCESSFULTotal time: 10.294 secsThis build could be faster, please consider using the Gradle Daemon: http://gradle.org/docs/2.4/userguide/gradle_daemon.htmlStarting the app (/Users/fengjian/Tools/android-sdk/platform-tools/adb shell am start -n com.justnocode/.MainActivity)...Starting: Intent { cmp=com.justnocode/.MainActivity }
显示详细信息
成功了,显示了MainActivity,一个简单的说明页面,
分享题目:快速上手ReactNative
当前网址:http://www.shufengxianlan.com/qtweb/news0/550850.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联