"react-native log-android" 错误 "adb' logcat -c" 失败。 adb' logcat -c 运行良好。 [Ubuntu]

"react-native log-android" Error "adb' logcat -c" failed. adb' logcat -c runs fine. [Ubuntu]

我正在尝试 运行 react-native log-android 来测试在我的 react-native phone 应用程序上上传 google 照片。我收到错误

warn The following packages use deprecated "rnpm" config that will stop working from next release:
  - react-native-fetch-blob: https://github.com/wkh237/react-native-fetch-blob#readme
  - react-native-google-signin: https://github.com/react-native-community/react-native-google-signin
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.



info Starting logkitty
/bin/sh: 1: /home/diamonddoesnt/Library/Android/sdk/platform-tools/adb: not found
error Command failed: '/home/diamonddoesnt/Library/Android/sdk/platform-tools/adb' logcat -c
/bin/sh: 1: /home/diamonddoesnt/Library/Android/sdk/platform-tools/adb: not found
. Run CLI with --verbose flag for more details.
Error: Command failed: '/home/diamonddoesnt/Library/Android/sdk/platform-tools/adb' logcat -c
/bin/sh: 1: /home/diamonddoesnt/Library/Android/sdk/platform-tools/adb: not found





    at spawnLogcatProcess (/home/diamonddoesnt/Desktop/prog/it project/react/project/COMP30022-DiamondDoesnt/family3/node_modules/logkitty/build/android/adb.js:36:11)
    at runAndroidLoggingProcess (/home/diamonddoesnt/Desktop/prog/it project/react/project/COMP30022-DiamondDoesnt/family3/node_modules/logkitty/build/android/adb.js:21:10)
    at logkitty (/home/diamonddoesnt/Desktop/prog/it project/react/project/COMP30022-DiamondDoesnt/family3/node_modules/logkitty/build/api.js:137:85)
    at Object.logAndroid [as func] (/home/diamonddoesnt/Desktop/prog/it project/react/project/COMP30022-DiamondDoesnt/family3/node_modules/@react-native-community/cli-platform-android/build/commands/logAndroid/index.js:37:44)
    at Command.handleAction (/home/diamonddoesnt/Desktop/prog/it project/react/project/COMP30022-DiamondDoesnt/family3/node_modules/react-native/node_modules/@react-native-community/cli/build/cliEntry.js:160:21)
    at Command.listener (/home/diamonddoesnt/Desktop/prog/it project/react/project/COMP30022-DiamondDoesnt/family3/node_modules/commander/index.js:315:8)
    at Command.emit (events.js:189:13)
    at Command.parseArgs (/home/diamonddoesnt/Desktop/prog/it project/react/project/COMP30022-DiamondDoesnt/family3/node_modules/commander/index.js:651:12)
    at Command.parse (/home/diamonddoesnt/Desktop/prog/it project/react/project/COMP30022-DiamondDoesnt/family3/node_modules/commander/index.js:474:21)
    at setupAndRun (/home/diamonddoesnt/Desktop/prog/it project/react/project/COMP30022-DiamondDoesnt/family3/node_modules/react-native/node_modules/@react-native-community/cli/build/cliEntry.js:210:24)

但是当我在控制台中输入 adb logcat -c 或 adb 'logcat -c 时,它工作正常。

diamonddoesnt@diamonddoesnt-ThinkPad-X260:~/Desktop/prog/it project/react/project/COMP30022-DiamondDoesnt/family3$ adb logcat -c
diamonddoesnt@diamonddoesnt-ThinkPad-X260:~/Desktop/prog/it project/react/project/COMP30022-DiamondDoesnt/family3$ adb' logcat -c

而且我想我已经将它包含在路径中,我的 .bashrc 看起来像

## added
export PATH="$PATH:~/.local/lib"
export PATH="$PATH:~/.local/lib/python3.6/site-packages/yTermPlayer"
export PATH="/home/diamonddoesnt/Desktop/prog/it project/flutter/flutter/bin:$PATH"
export PATH="$PATH:~/Downloads/android-studio/bin"
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/platform-tools/adb
export PATH=${PATH}:/Library/Android/sdk/tools:/path/to/android-sdk/platform-tools


所以我不确定为什么会给我这个错误。

脚本正在尝试 运行 /home/diamonddoesnt/Library/Android/sdk/platform-tools/adb,完全合格。你的 adb 在你的 PATH 中,但它不在那里。当您尝试 运行 具有完全限定路径的程序时,如果它在那里找不到它,它不会费心检查您的 PATH 。当你只是 运行 它作为 adb 时,它会检查你的 PATH,解释差异。要修复它,请执行 which adb 找出二进制文件的实际位置,然后重新配置脚本以使用该二进制文件。

我试着用 cd 找到 /home/diamonddoesnt/Library/Android/sdk/platform-tools/adb。它没有用,但是当我 cd /home/diamonddoesnt/Library/Android/ 时,它确实起作用了。这看起来很愚蠢,但问题是在我的 /Android 文件夹中,sdk 文件夹被命名为 Sdk。所以我修改了 .bashrc 行

export ANDROID_HOME=$HOME/Library/Android/sdk

为了反映这一点,它奏效了。