问题
Got this error when I tested an Android build "internal" flavor, I believe the problem is a mismatch in package and process name of our Android application build which could have to happen when the package name changed due to the "internal" flavor. I'm still looking into how to fix this and I can find any relevant cases here and while searching on the web. I'll keep looking and trying fixes but if anyone has an idea or solution pls. let me know.
回答1:
Findings: Turns out that Android creates a new package name for every different "flavor" build, see https://developer.android.com/studio/build/build-variants but retain the processName. In our case, it added "internal" on package name ex. com.xxxx.android.internal while processName remains com.xxxx.android.
Issue: The root of the issue is when you switch to webview context, Appium pass certain capabilities to ChromeDriver including packageName but when it tried to issue an adb command to find the process it can't find it because of a mismatch.
Solution: Use chromeOptions capability to pass the processName, see code below in java.
Map<String, Object> chromeOptions = new HashMap<String, Object>();
chromeOptions.put("androidProcess", "com.xxxx.android");
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
来源:https://stackoverflow.com/questions/52429593/appium-getting-error-failed-to-start-chromedriver-session-original-error-unk