Closed Visandi closed 1 year ago
So, from what you're describing I can deduce you are using Windows with PHP and composer already installed.
What's still unclear to me is if (or how) you have the android platform tools installed properly. You mentioned you've tried to put/rename an adb folder. Nothing like that is actually required for the program to run. BUT the adb
(adb.exe
is the full filename on Windows) executeble is part of the android platform tools and has to be available as a command (like composer
or npm
for example).
Please make sure the installation location of the android platform tools is added to the PATH
environment variable. You can refer to this stackoverflow answer for a short description on how to do that.
For now, I'd recommend using it from cmd only, until this is fixed (more details further down below).
I didn't test the script under powershell, I suspect it won't work out of the box. To explain that a little bit further:
To achive cross platform compatibility when checking for the availability of the adb
(Android Debug Bridge) executable, the CopyTabsCommand::isShellCommandAvailable()
behavior differs based on the detected OS. If it's Windows, the where
command (cmd context) is used, else (e.g. for Mac and Linux) the command
command is used to check whether there is an executable path found for adb
.
I haven't encountered the INFO ...
message myself until now, but from what I've found online, it seems to be related to powershell, where the where
means something totally different than in cmd context. They are two different things after all, which is something I wasn't aware of up until now.
I'll definitely look into this to make sure the code works on Windows in powershell and cmd context alike.
Right, I have installed PHP and Composer in my computer.
Sorry to make you misunderstood about the platform tools folder, The folder I renamed was the script folder. To avoid further confusion, the steps I took was: installing PHP + Composer, download your script from github page then extract it, so the output is directory like D:\android-chrome-tab-transfer
also there is src/Command
directory inside it. Finally, after encountering an error I digging into copy-tabs.php script and found some code at lines 26 to 29 which I suppose call required files in specific folder in order to run CopyTabsCommand.php. The code is
require __DIR__.'/vendor/autoload.php';
use App\Command\CopyTabsCommand;
use Symfony\Component\Console\Application;
Based on that I rename src/Command into App/Command.
I didn't add platform tools installation location to the PATH environment variable because I don't ever know what is it (until I read here honestly) and after seeing the stackoverflow answer I only learn that the environment variable add adb command to the cmd path, so you can call adb
on cmd everytime, previously if I want to use it I must go through the platfom-tools folder, holding shift + right click to use open command window here context.
I'll look into that and let you know later if I have spare time
This software, rather "tool", works without any modifications, given the environment (the other software required for it to work) is set up correctly (i.e. availability on the system %PATH%
, as mentioned in the prerequisites.
The steps you took were correct, to the point, that you tried to change the directory structure.
The use
statements you've posted above do not refer to the directory structure, as it would be the case in a strict psr-4 structure, they refer to the namespace of some classes used. In PHP, namespaces can differ from the directory structure, depending on the autoloader used.
I will not explain the details of how managing dependencies using composer and how autoloading works.
Please make sure all files/folders are in their original state (and structure), otherwise any troubleshooting done here is nonsense.
The original error message you've posted above was caused by using the powershell instead of cmd to run the command. Additionally, I suspect, you didn't have the adb
executable available on the system path
environment variable, as explained above.
Please make sure your system environment is properly set up for the program.
I'm planning to introduce a bundled version of the tool as a .phar
(php archive) file for easier execution. See #4.
To make this very clear, currently (2022/05/31) powershell is not supported, so please use the normal cmd promt. To do so, enter cmd
in powershell to launch a new cmd session. You'll be left in the same directory as before and can exit back to the powershell using exit
.
EDIT: The issue will be fixed in #8.
Closing, as the bug has been fixed.
Since I am noob to php and coding, I started with steps that you provided in readme file. I run the command first through cmd but it doesn't work, tried it with PowerShell the code only works partially. "cd android-chrome-tab-transfer" and "composer install" command worked, but "php ./copy-tabs.php" gives me error. The error message is:
I try figuring out what caused this error by checking inside the script what does directory copy-tabs.php and CopyTabsCommand.php needed, then renaming the folder based on that, even try to put adb folder inside script folder but still any of my attempts gives unsucessfull result. So can you give me a clear instruction to follows?