Sitelet https://github.com/SharpAdb/AdvancedSharpAdbClient/issues/90
Skip to content

deviceClient.StartApp("com.android.app"); doesn't work #90

Description

@evolution1987

Describe the bug

HI! I have updated package from 2.5.8 to 3.0.9 buy found that deviceClient.StartApp("com.android.app"); doesn't open apk on smartphone There are no errors in log. I use NET Framework 4.8

Steps to reproduce the bug

  1. Install facebook apk
  2. deviceClient.StartApp("com.facebook.katana");

Expected behavior

No response

Screenshots

No response

NuGet package version

3.0.9

.NET Platform

.NET Framework 4.8.x

Platform type

Windows

System version

windows 10 pro

IDE

Visual Studio 2022

Additional context

No response

Activity

  1. wherewhere commented on Feb 8, 2024

    @wherewhere
    Member

    It works on my device...

    screen-20240208-115733.3.mp4
  2. evolution1987 commented on Feb 8, 2024

    @evolution1987
    Author

    On my visual studio Start app works on 2.5.8 version but not in 3.0.9

  3. wherewhere commented on Feb 8, 2024

    @wherewhere
    Member

    .net4.8 also works.
    Try using client.StartApp(device, "com.bilibili.app.in")

    Screenshot_20240208-195941_Termux.png

  4. evolution1987 commented on Feb 8, 2024

    @evolution1987
    Author

    Here is my code. App installed but can't run. The problem is on all android smartphones package version 3.0.9, in 2.5.8 there is no problem but problem is with getting elements on adroid 9

    logger.Info($"Thread {Thread.CurrentThread.ManagedThreadId} Start work");
    string adb = textBox1.Text;
    if (!AdbServer.Instance.GetStatus().IsRunning)
    {
        AdbServer server = new AdbServer();
        StartServerResult result = server.StartServer($"{adb}", false);
        if (result != StartServerResult.Started)
        {
            Console.WriteLine("Can't start adb server");
        }
    }
    
              
    
    var client = new AdbClient();
    var serial = client.GetDevices().FirstOrDefault().Serial;
    client.Connect(serial);
    var deviceData = client.GetDevices().FirstOrDefault();
    string fbApp = textBox2.Text;
    var deviceClient = new DeviceClient(client, deviceData);
    //install APK
    PackageManager manager = new PackageManager(client, deviceData);
    try
    {
        manager.InstallPackage($"{fbApp}", callback: null);
        logger.Info($"Thread {Thread.CurrentThread.ManagedThreadId} installed apk");
    }
    catch (Exception ex)
    {
        logger.Error($"Can't send keyevent:{ex.Message}");
    }
    //start Facebook
    logger.Info($"Thread {Thread.CurrentThread.ManagedThreadId} start Facebook");
    try
    {
        deviceClient.StartApp("com.facebook.katana");
    
    
    } catch (Exception ex)
    {
        logger.Error($"Thread {Thread.CurrentThread.ManagedThreadId} {ex.Message}");
    }
  5. wherewhere commented on Feb 8, 2024

    @wherewhere
    Member

    So what's your old code?

  6. evolution1987 commented on Feb 8, 2024

    @evolution1987
    Author

    This code with 3.0.9 version and StartApp doesn't work

  7. wherewhere commented on Feb 8, 2024

    @wherewhere
    Member

    But it works on my device. I need to know the difference to figure out what happened...
    And why you connect a connected device?

  8. wherewhere commented on Feb 8, 2024

    @wherewhere
    Member
    var serial = client.GetDevices().FirstOrDefault().Serial; // You get the first connected device's serial.
    client.Connect(serial); // Then you connect it again.
    var deviceData = client.GetDevices().FirstOrDefault(); // Now I don't know which device you would get...

    And StartApp is sending monkey -p xxx 1 to the Android shell. You can try to using adb shell monkey -p xxx 1 on adb command line.

  9. evolution1987 commented on Feb 8, 2024

    @evolution1987
    Author

    You are right but in any case I can't start apk after installing, comman doesn't run application, nothing happens. But all works on 2.5.8 So I think there is some promler in latest version of Advanced Sharp Adb I try to found whre is problem Can you show actual examples on real smartphone or maybe you need test on facebook apk?

  10. wherewhere commented on Feb 8, 2024

    @wherewhere
    Member
    var client = new AdbClient();
    AdbServer.Instance.StartServer("adb/to/your/path", false);
    client.Connect("ip:port")
    var device = new DeviceClient(client, client.GetDevices().First());
    device.StartApp("packagename");
  11. evolution1987 commented on Feb 8, 2024

    @evolution1987
    Author

    Tell me please, in method client.Connect("ip:port") can I use name of device as ip:port?

  12. wherewhere commented on Feb 8, 2024

    @wherewhere
    Member

    No, you can only use ip and port like 192.168.1.19:37146.
    If you connected with USB, you can ignore it.

  13. evolution1987 commented on Feb 8, 2024

    @evolution1987
    Author

    So, if I connect my smartphone via USB I can ignore the line client.Connect("ip:port")?

  14. wherewhere commented on Feb 8, 2024

    @wherewhere
    Member

    Yes.

  15. evolution1987 commented on Feb 8, 2024

    @evolution1987
    Author

    Thank you very much, I will try to discover my problem again

  16. evolution1987 commented on Feb 9, 2024

    @evolution1987
    Author

    Hello! I can run app using shell as you said me, but comand StartApp from documentaion doesn't work for me. In any case, you can help me, thanks

  17. wherewhere commented on Feb 22, 2024

    @wherewhere
    Member

    I don't know what happened...

  18. wherewhere commented on Feb 22, 2024

    @wherewhere
    Member

    I have no idea...

  19. liditingziya commented on Jan 14, 2025

    @liditingziya

    I encountered the same problem.
    image
    This code works in v2.5.8, but it has no effect in versions above it.

  20. added theissue type on Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions