A new session could not be created

Hi,

I’m using Appium with Android ( 4.4 ) and I’m facing to an issue when I try to start an Appium Inspector directly through Appium or even by code when I try to create new AndroidDriver instance.

1/ When I try to click on Appium Inspector I get this error:

In my Appium console:

error: Failed to start an Appium session, err was: Error: packageAndLaunchActivityFromManifest failed. Error: Command failed: /bin/sh -c “/Users/me/Documents/Android SDK/sdk/build-tools/android-4.4W/aapt” dump badging /Users/me/Projects/myProject/app/build/outputs/apk/app-app-debug.apk
W/ResourceType( 8096): Failure getting entry for 0x7f060020 (t=5 e=32) in package 0 (error -84)
ERROR getting ‘android:label’ attribute: attribute is not a string value

2/ By code I get this error:

A new session could not be created. (Original error: packageAndLaunchActivityFromManifest failed. Error: Command failed: /bin/sh -c “/Users/me/Documents/Android SDK/sdk/build-tools/android-4.4W/aapt” dump badging /Users/me/Projects/myProject/app/build/outputs/apk/app-app-debug.apk
W/ResourceType( 6918): Failure getting entry for 0x7f060020 (t=5 e=32) in package 0 (error -84)
ERROR getting ‘android:label’ attribute: attribute is not a string value
) (WARNING: The server did not provide any stacktrace information)

So here in my Manifest file, I tried to change my android:label=@string/name to android:label=“Name” and also clean my project. But I still get this error.

My code to create Appium Driver:

protected static String directory = "/Users/me/Projects/myProject/app/build/outputs/apk";
protected static String apk = "app-app-debug.apk";
protected static AndroidDriver driver;
protected static void appiumDriver() throws MalformedURLException {
    File appDir = new File(directory);
    File app = new File(appDir, apk);
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("appium-version", "1.4");
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability("platformVersion", "4.4");
    capabilities.setCapability("deviceName", "192.168.57.101:5555");
    capabilities.setCapability("appPackage", "com.my.package");
    capabilities.setCapability("app", app.getAbsolutePath());
    //capabilities.setCapability("appWaitActivity", "10000");
    driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);// Error triggered at this line
    driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}

Finally my settings in Appium:

I used Appium few months ago with this configuration and it was working good so I don’t really see here my mistake.

Thanks for any help.

Under Setting also u need to select option “Pre Launch Application” then it will work …

Thanks for your answer. I just dont see “Pre Launch Application” maybe I’ve just missed it… but thanks to your comment I tried to add a “Launch Activity” and then now it works good. But to be honest when I used Appium in the past I didnt remember that, I think I have not specified any Activity to launch… Anyway it’s working now.

Hi,
I am using appium app inspector 1.6.5 but it is not possible to launch the inspector it is throwing error as session couldn’t be created . how to resolve this?