How to change packagename and install with appium

I write an appium test to check an integration between app A that opens app B as an SDK app.

meaning app B has a whitelist of apps’ package names that can trigger it to open a specific activity.

app A can be one of 3 apps with different package names.

So i created 3 apks with different package names.

Here is app A manifest

I wanted change the package in the manifest, but it fails the apk build.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.eliran.myapplication" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

so i read this post in SOF and changed the applicaitonId instead (gradle.build)

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.partner1"
        minSdkVersion 15
        targetSdkVersion 22

I created an apk

but now appium fails to install that apk

with this desired capabilities:

saying:

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Error occured while starting App. Original error: Activity used to start app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 21.63 seconds

Put 2 capabilities

  1. appWaitActivity for rest two activity