examples/cordova1/plugins/branch-cordova-sdk/src/scripts/android/updateAndroidManifest.js
function getManifest(context) {
    let pathToManifest;
    let manifest;

    try {
      // cordova platform add android@6.0.0
      pathToManifest = path.join(
        context.opts.projectRoot,
        "platforms",
        "android",
        "AndroidManifest.xml"
      );
      manifest = xmlHelper.readXmlAsJson(pathToManifest);
    } catch (e) {
      try {
        // cordova platform add android@7.0.0
        pathToManifest = path.join(
          context.opts.projectRoot,
          "platforms",
          "android",
          "app",
          "src",
          "main",
          "AndroidManifest.xml"
        );
        manifest = xmlHelper.readXmlAsJson(pathToManifest);
      } catch (e) {
        throw new Error(`BRANCH SDK: Cannot read AndroidManfiest.xml ${e}`);
      }
    }
    const mainActivityIndex = getMainLaunchActivityIndex(
      manifest.manifest.application[0].activity
    );
    const targetSdk =
      manifest.manifest["uses-sdk"][0].$["android:targetSdkVersion"];

    return {
      file: manifest,
      path: pathToManifest,
      mainActivityIndex: mainActivityIndex,
      targetSdk: targetSdk
    };
  }
function getManifest(context) {
    let pathToManifest;
    let manifest;

    try {
      // cordova platform add android@6.0.0
      pathToManifest = path.join(
        context.opts.projectRoot,
        "platforms",
        "android",
        "AndroidManifest.xml"
      );
      manifest = xmlHelper.readXmlAsJson(pathToManifest);
    } catch (e) {
      try {
        // cordova platform add android@7.0.0
        pathToManifest = path.join(
          context.opts.projectRoot,
          "platforms",
          "android",
          "app",
          "src",
          "main",
          "AndroidManifest.xml"
        );
        manifest = xmlHelper.readXmlAsJson(pathToManifest);
      } catch (e) {
        throw new Error(`BRANCH SDK: Cannot read AndroidManfiest.xml ${e}`);
      }
    }
    const mainActivityIndex = getMainLaunchActivityIndex(
      manifest.manifest.application[0].activity
    );
    const targetSdk =
      manifest.manifest["uses-sdk"][0].$["android:targetSdkVersion"];

    return {
      file: manifest,
      path: pathToManifest,
      mainActivityIndex: mainActivityIndex,
      targetSdk: targetSdk
    };
  }
function getManifest ( context ) { let pathToManifest ; let manifest ; try { // cordova platform add android@6.0.0 pathToManifest = path . join ( context . opts . projectRoot , "platforms" , "android" , "AndroidManifest.xml" ) ; manifest = xmlHelper . readXmlAsJson ( pathToManifest ) ; } catch ( e ) { try { // cordova platform add android@7.0.0 pathToManifest = path . join ( context . opts . projectRoot , "platforms" , "android" , "app" , "src" , "main" , "AndroidManifest.xml" ) ; manifest = xmlHelper . readXmlAsJson ( pathToManifest ) ; } catch ( e ) { throw new Error ( ` ${ e } ` ) ; } } const mainActivityIndex = getMainLaunchActivityIndex ( manifest . manifest . application [ 0 ] . activity ) ; const targetSdk = manifest . manifest [ "uses-sdk" ] [ 0 ] . $ [ "android:targetSdkVersion" ] ; return { file : manifest , path : pathToManifest , mainActivityIndex : mainActivityIndex , targetSdk : targetSdk } ; }
get AndroidManifest.xml information
get AndroidManifest . xml information