使用真机开发,执行adb devices命令,提示版本不匹配,该怎么解决?



  • 我正在学习 React Native,在用真机进行开发时,执行 adb devices 命令,显示:

    D:\wamp\www\miaov\React Native\AwesomeProject>adb devices
    List of devices attached
    adb server version (39) doesn't match this client (40); killing...
    * daemon started successfully
    FFK0217802003240        device
    

    网上查到一些使用模拟器的解决办法,请问我该怎么调整呢?



  • 已经正确识别了啊,还有什么问题



  • @晴明 我运行应用时提示:

    D:\wamp\www\miaov\React Native\AwesomeProject>react-native run-android
    info Starting JS server...
    info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...
    Starting a Gradle Daemon (subsequent builds will be faster)
    
    > Task :app:installDebug
    01:31:55 V/ddms: execute: running am get-config
    01:31:56 V/ddms: execute 'am get-config' on 'FFK0217802003240' : EOF hit. Read: -1
    01:31:56 V/ddms: execute: returning
    Installing APK 'app-debug.apk' on 'DUK-AL20 - 7.0' for app:debug
    01:31:56 D/app-debug.apk: Uploading app-debug.apk onto device 'FFK0217802003240'
    01:31:56 D/Device: Uploading file onto device 'FFK0217802003240'
    01:31:56 D/ddms: Reading file permision of D:\wamp\www\miaov\React Native\AwesomeProject\android\app\build\outputs\apk\debug\app-debug.apk as: rwx------
    01:31:57 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-debug.apk"
    01:31:58 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-debug.apk"' on 'FFK0217802003240' : EOF hit. Read: -1
    01:31:58 V/ddms: execute: returning
    Unable to install D:\wamp\www\miaov\React Native\AwesomeProject\android\app\build\outputs\apk\debug\app-debug.apk
    com.android.ddmlib.InstallException: INSTALL_CANCELED_BY_USER
            at com.android.ddmlib.Device.installRemotePackage(Device.java:1022)
            at com.android.ddmlib.Device.installPackage(Device.java:903)
            at com.android.ddmlib.Device.installPackage(Device.java:881)
            at com.android.ddmlib.Device.installPackage(Device.java:870)
            at com.android.builder.testing.ConnectedDevice.installPackage(ConnectedDevice.java:126)
            at com.android.build.gradle.internal.tasks.InstallVariantTask.install(InstallVariantTask.java:179)
            at com.android.build.gradle.internal.tasks.InstallVariantTask.install(InstallVariantTask.java:110)
            at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
            at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
            at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
            at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
            at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:801)
            at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:768)
            at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:131)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
            at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
            at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120)
            at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99)
            at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77)
            at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
            at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
            at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
            at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
            at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
            at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
            at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
            at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
            at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
            at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
            at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
            at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
            at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
            at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
            at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
            at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46)
            at org.gradle.execution.taskgraph.LocalTaskInfoExecutor.execute(LocalTaskInfoExecutor.java:42)
            at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:277)
            at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:262)
            at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:135)
            at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130)
            at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200)
            at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191)
            at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.run(DefaultTaskPlanExecutor.java:130)
            at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
            at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
            at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    
    > Task :app:installDebug FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app:installDebug'.
    > com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: INSTALL_CANCELED_BY_USER
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 21s
    26 actionable tasks: 1 executed, 25 up-to-date
    error Could not install the app on the device, read the error above for details.
    Make sure you have an Android emulator running or a device connected and have
    set up your Android development environment:
    https://facebook.github.io/react-native/docs/getting-started.html
    error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.
    

    我一直以为是设备连接到 ADB 的问题。请问这是什么问题?



  • com.android.ddmlib.InstallException: INSTALL_CANCELED_BY_USER
    提示安装被用户取消,具体是怎么导致的不清楚
    实在不知道怎么解决就自己想办法把apk拷到手机上装一样的



  • @晴明 我把 app-debug.apk 拷贝到手机上,已经安装了
    0_1556865201817_87c14a36-7eb4-49c3-99eb-c64b84237f9c-image.png
    运行应用时还是报同样的错误……



  • 装上了就不需要run-android了啊,直接react-native start啊



  • 经过一系列查询,终于能在真机上看到效果了,谢谢!