我试图用我的手机做出反应。但我得到一个奇怪的错误,似乎无法解决它。有人可以帮忙吗?这是堆栈跟踪:
Gallery
我已经包含了必要的堆栈,因此更容易阅读。
答案 0 :(得分:2)
I had to type:
adb kill-server
Wait a moment then run:
adb devices
In my case output is like are as follows
**List of Devices Attached**
*0123456789ABCDEF device*
This will show you the DEVICE_ID (0123456789ABCDEF) of your device running android.
then you will have to run below command and make sure usb is enabled
react-native run-android --deviceId 0123456789ABCDEF
After that my output be like
**D:\React\albums>adb devices
List of devices attached
0123456789ABCDEF device
D:\React\albums>react-native run-android --deviceId 0123456789ABCDEF
Scanning 636 folders for symlinks in D:\React\albums\node_modules (21ms)
JS server already running.
Building the app...
Observed package id 'build-tools;23.0.1' in inconsistent location 'D:\Android\Sd
k\build-tools\build-tools-23.0.1' (Expected 'D:\Android\Sdk\build-tools\23.0.1')
Already observed package id 'build-tools;23.0.1' in 'D:\Android\Sdk\build-tools\
23.0.1'. Skipping duplicate at 'D:\Android\Sdk\build-tools\build-tools-23.0.1'
Observed package id 'extras;google;m2repository' in inconsistent location 'D:\An
droid\Sdk\extras\google\m2repository.backup' (Expected 'D:\Android\Sdk\extras\go
ogle\m2repository')
Already observed package id 'extras;google;m2repository' in 'D:\Android\Sdk\extr
as\google\m2repository'. Skipping duplicate at 'D:\Android\Sdk\extras\google\m2r
epository.backup'
Observed package id 'system-images;android-24;google_apis;x86' in inconsistent l
ocation 'D:\Android\Sdk\system-images\android-24\google_apis\x86.backup' (Expect
ed 'D:\Android\Sdk\system-images\android-24\google_apis\x86')
Already observed package id 'system-images;android-24;google_apis;x86' in 'D:\An
droid\Sdk\system-images\android-24\google_apis\x86'. Skipping duplicate at 'D:\A
ndroid\Sdk\system-images\android-24\google_apis\x86.backup'
Observed package id 'build-tools;23.0.1' in inconsistent location 'D:\Android\Sd
k\build-tools\build-tools-23.0.1' (Expected 'D:\Android\Sdk\build-tools\23.0.1')
Already observed package id 'build-tools;23.0.1' in 'D:\Android\Sdk\build-tools\
23.0.1'. Skipping duplicate at 'D:\Android\Sdk\build-tools\build-tools-23.0.1'
Observed package id 'extras;google;m2repository' in inconsistent location 'D:\An
droid\Sdk\extras\google\m2repository.backup' (Expected 'D:\Android\Sdk\extras\go
ogle\m2repository')
Already observed package id 'extras;google;m2repository' in 'D:\Android\Sdk\extr
as\google\m2repository'. Skipping duplicate at 'D:\Android\Sdk\extras\google\m2r
epository.backup'
Observed package id 'system-images;android-24;google_apis;x86' in inconsistent l
ocation 'D:\Android\Sdk\system-images\android-24\google_apis\x86.backup' (Expect
ed 'D:\Android\Sdk\system-images\android-24\google_apis\x86')
Already observed package id 'system-images;android-24;google_apis;x86' in 'D:\An
droid\Sdk\system-images\android-24\google_apis\x86'. Skipping duplicate at 'D:\A
ndroid\Sdk\system-images\android-24\google_apis\x86.backup'
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:app:prepareComFacebookFbuiTextlayoutbuilderTextlayoutbuilder100Library UP-TO-DA
TE
:app:prepareComFacebookFrescoDrawee101Library UP-TO-DATE
:app:prepareComFacebookFrescoFbcore101Library UP-TO-DATE
:app:prepareComFacebookFrescoFresco101Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipeline101Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipelineBase101Library UP-TO-DATE
:app:prepareComFacebookFrescoImagepipelineOkhttp3101Library UP-TO-DATE
:app:prepareComFacebookReactReactNative0451Library UP-TO-DATE
:app:prepareComFacebookSoloaderSoloader010Library UP-TO-DATE
:app:prepareOrgWebkitAndroidJscR174650Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:bundleDebugJsAndAssets SKIPPED
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:transformClassesWithDexForDebug UP-TO-DATE
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:app:validateSigningDebug
:app:packageDebug UP-TO-DATE
:app:assembleDebug UP-TO-DATE
:app:checkReleaseManifest
:app:prepareReleaseDependencies
:app:compileReleaseAidl UP-TO-DATE
:app:compileReleaseRenderscript UP-TO-DATE
:app:generateReleaseBuildConfig UP-TO-DATE
:app:mergeReleaseShaders UP-TO-DATE
:app:compileReleaseShaders UP-TO-DATE
:app:generateReleaseAssets UP-TO-DATE
:app:mergeReleaseAssets UP-TO-DATE
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources UP-TO-DATE
:app:mergeReleaseResources UP-TO-DATE
:app:bundleReleaseJsAndAssets UP-TO-DATE
:app:processReleaseManifest UP-TO-DATE
:app:processReleaseResources UP-TO-DATE
:app:generateReleaseSources UP-TO-DATE
:app:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
:app:compileReleaseJavaWithJavac UP-TO-DATE
:app:compileReleaseNdk UP-TO-DATE
:app:compileReleaseSources UP-TO-DATE
:app:lintVitalRelease
:app:transformClassesWithDexForRelease UP-TO-DATE
:app:mergeReleaseJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForRelease UP-TO-DATE
:app:processReleaseJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
:app:packageRelease UP-TO-DATE
:app:assembleRelease
:app:assemble
:app:incrementalDebugUnitTestJavaCompilationSafeguard UP-TO-DATE
:app:preDebugUnitTestBuild UP-TO-DATE
:app:prepareDebugUnitTestDependencies
:app:compileDebugUnitTestJavaWithJavac UP-TO-DATE
:app:processDebugUnitTestJavaRes UP-TO-DATE
:app:compileDebugUnitTestSources UP-TO-DATE
:app:mockableAndroidJar UP-TO-DATE
:app:assembleDebugUnitTest UP-TO-DATE
:app:testDebugUnitTest UP-TO-DATE
:app:incrementalReleaseUnitTestJavaCompilationSafeguard UP-TO-DATE
:app:preReleaseUnitTestBuild UP-TO-DATE
:app:prepareReleaseUnitTestDependencies
:app:compileReleaseUnitTestJavaWithJavac UP-TO-DATE
:app:processReleaseUnitTestJavaRes UP-TO-DATE
:app:compileReleaseUnitTestSources UP-TO-DATE
:app:assembleReleaseUnitTest UP-TO-DATE
:app:testReleaseUnitTest UP-TO-DATE
:app:test UP-TO-DATE
:app:check
:app:build
BUILD SUCCESSFUL
Total time: 16.717 secs
Running D:\Android\Sdk/platform-tools/adb -s 0123456789ABCDEF reverse tcp:8081 t
cp:8081
Installing the app on the device (cd android && adb -s 0123456789ABCDEF install
app/build/outputs/apk/app-debug.apk
app/build/outputs/apk/app-debug.apk: 1...ed. 3.2 MB/s (8067631 bytes in 2.442s)
pkg: /data/local/tmp/app-debug.apk
Failure [INSTALL_FAILED_ALREADY_EXISTS]
Starting the app on 0123456789ABCDEF (D:\Android\Sdk/platform-tools/adb -s 01234
56789ABCDEF shell am start -n com.albums/com.albums.MainActivity)...
Starting: Intent { cmp=com.albums/.MainActivity }
**
The important part was the --deviceId XYZ. Without this, the apk would never get uploaded to the phone.
**First Way**
*** If you are using Latest version of React then shake your real device and press reload (In my case react-native cli version is 2.0.1 And react-native version 0.45.1 ) Dont put any machine address and port in dev setting ok ***
**if first method does not works then follow second method**
**Second Way**
Then, the app launched with a red screen... i had to shake it, dev settings, adjust the "debug server host & port for device", putting my computer's IP address and port, like this:
192.168.0.15:8081
Lastly, i had to shake my phone again and select RELOAD...