问题
D:\rnworkspace\Hello>react-native run-android
JS server already running. @H_301_4@ Building and installing the app on the device (cd android && gradlew.bat install @H_301_4@ Debug)... @H_301_4@ :app:preBuild UP-TO-DATE @H_301_4@ :app:preDebugBuild UP-TO-DATE @H_301_4@ :app:checkDebugManifest @H_301_4@ :app:preReleaseBuild UP-TO-DATE @H_301_4@ :app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE @H_301_4@ :app:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE @H_301_4@ :app:prepareComAndroidSupportSupportV42321Library UP-TO-DATE @H_301_4@ :app:prepareComFacebookFrescoDrawee0110Library UP-TO-DATE @H_301_4@ :app:prepareComFacebookFrescoFbcore0110Library UP-TO-DATE @H_301_4@ :app:prepareComFacebookFrescoFresco0110Library UP-TO-DATE @H_301_4@ :app:prepareComFacebookFrescoImagepipeline0110Library UP-TO-DATE @H_301_4@ :app:prepareComFacebookFrescoImagepipelineBase0110Library UP-TO-DATE @H_301_4@ :app:prepareComFacebookFrescoImagepipelineOkhttp30110Library UP-TO-DATE @H_301_4@ :app:prepareComFacebookReactReactNative0392Library UP-TO-DATE @H_301_4@ :app:prepareComFacebookSoloaderSoloader010Library UP-TO-DATE @H_301_4@ :app:prepareOrgWebkitAndroidJscR174650Library UP-TO-DATE @H_301_4@ :app:prepareDebugDependencies @H_301_4@ :app:compileDebugAidl UP-TO-DATE @H_301_4@ :app:compileDebugRenderscript UP-TO-DATE @H_301_4@ :app:generateDebugBuildConfig UP-TO-DATE @H_301_4@ :app:generateDebugAssets UP-TO-DATE @H_301_4@ :app:mergeDebugAssets UP-TO-DATE @H_301_4@ :app:generateDebugResValues UP-TO-DATE @H_301_4@ :app:generateDebugResources UP-TO-DATE @H_301_4@ :app:mergeDebugResources UP-TO-DATE @H_301_4@ :app:bundleDebugJsAndAssets SKIPPED @H_301_4@ :app:processDebugManifest UP-TO-DATE @H_301_4@ :app:processDebugResources UP-TO-DATE @H_301_4@ :app:generateDebugSources UP-TO-DATE @H_301_4@ :app:processDebugJavaRes UP-TO-DATE @H_301_4@ :app:compileDebugJavaWithJavac UP-TO-DATE @H_301_4@ :app:compileDebugNdk UP-TO-DATE @H_301_4@ :app:compileDebugSources UP-TO-DATE @H_301_4@ :app:preDexDebug UP-TO-DATE @H_301_4@ :app:dexDebug @H_301_4@ :app:validateDebugSigning @H_301_4@ :app:packageDebug @H_301_4@ :app:zipalignDebug @H_301_4@ :app:assembleDebug @H_301_4@ :app:installDebug Failed @H_301_4@ @H_301_4@ @H_301_4@ FAILURE: Build Failed with an exception. @H_301_4@ @H_301_4@ @H_301_4@ * What went wrong: @H_301_4@ Execution Failed for task ':app:installDebug'. @H_301_4@ > com.android.builder.testing.api.DeviceException: No connected devices! @H_301_4@ @H_301_4@ @H_301_4@ * Try: @H_301_4@ Run with --stacktrace option to get the stack trace. Run with --info or --debug @H_301_4@ option to get more log output. @H_301_4@ @H_301_4@ @H_301_4@ BUILD Failed @H_301_4@ @H_301_4@ @H_301_4@ Total time: 23.398 secs @H_301_4@ Could not install the app on the device,read the error above for details.@H_301_4@ Make sure you have an Android emulator running or a device connected and have@H_301_4@ set up your Android development environment:@H_301_4@ https://facebook.github.io/react-native/docs/android-setup.html @H_301_4@ @H_301_4@ @H_301_4@ (node:6824) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejec @H_301_4@tion id: 2): TypeError: Cannot read property 'message' of undefined
@H_301_4@
问题分析
1.用
gradlew compileDebug --stacktrace 编译调试命令进行调试,显示如下:
D:\rnworkspace\Hello\android>gradlew compileDebug --stacktrace@H_301_4@ @H_301_4@ @H_301_4@ FAILURE: Build Failed with an exception.@H_301_4@ @H_301_4@ @H_301_4@ * What went wrong:@H_301_4@ Task 'compileDebug' is ambiguous in root project 'Hello'. Candidates are: 'compi@H_301_4@ leDebugAidl','compileDebugAndroidTestAidl','compileDebugAndroidTestJavaWithJav@H_301_4@ ac','compileDebugAndroidTestNdk','compileDebugAndroidTestRenderscript','compi@H_301_4@ leDebugAndroidTestSources','compileDebugJavaWithJavac','compileDebugNdk','com@H_301_4@ pileDebugRenderscript','compileDebugSources','compileDebugUnitTestJavaWithJava@H_301_4@ c','compileDebugUnitTestSources'.@H_301_4@ @H_301_4@ @H_301_4@ * Try:@H_301_4@ Run gradlew tasks to get a list of available tasks. Run with --info or --debug o@H_301_4@ ption to get more log output.@H_301_4@ @H_301_4@ @H_301_4@ * Exception is:@H_301_4@ org.gradle.execution.TaskSelectionException: Task 'compileDebug' is ambiguous in@H_301_4@ root project 'Hello'. Candidates are: 'compileDebugAidl','compileDebugAndroidT@H_301_4@ estAidl','compileDebugAndroidTestJavaWithJavac',@H_301_4@ 'compileDebugAndroidTestRenderscript','compileDebugAndroidTestSources','compil@H_301_4@ eDebugJavaWithJavac','compileDebugRenderscript','compileDeb@H_301_4@ ugSources','compileDebugUnitTestJavaWithJavac','compileDebugUnitTestSources'.@H_301_4@ at org.gradle.execution.TaskSelector.getSelection(TaskSelector.java:100)@H_301_4@
解决
1.启动AVD