예제 #1
0
        public XamarinAndroidApplicationProject()
        {
            SetProperty("AndroidApplication", "True");

            SetProperty("AndroidResgenClass", "Resource");
            SetProperty("AndroidResgenFile", () => "Resources\\Resource.designer" + Language.DefaultExtension);
            SetProperty("AndroidManifest", "Properties\\AndroidManifest.xml");
            SetProperty(DebugProperties, "AndroidLinkMode", "None");
            SetProperty(ReleaseProperties, "AndroidLinkMode", "SdkOnly");

            AndroidManifest = default_android_manifest;
            LayoutMain      = default_layout_main;
            StringsXml      = default_strings_xml;
            PackageName     = PackageName ?? string.Format("{0}.{0}", ProjectName);

            OtherBuildItems.Add(new BuildItem.NoActionResource("Properties\\AndroidManifest.xml")
            {
                TextContent = () =>
                              AndroidManifest.Replace("${PROJECT_NAME}", ProjectName).
                              Replace("${PACKAGENAME}", PackageName)
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\layout\\Main.axml")
            {
                TextContent = () => LayoutMain
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\values\\Strings.xml")
            {
                TextContent = () => StringsXml.Replace("${PROJECT_NAME}", ProjectName)
            });

            Sources.Add(new BuildItem.Source(() => "MainActivity" + Language.DefaultExtension)
            {
                TextContent = () => ProcessSourceTemplate(MainActivity ?? DefaultMainActivity)
            });
        }
        public XamarinAndroidApplicationProject(string debugConfigurationName = "Debug", string releaseConfigurationName = "Release", [CallerMemberName] string packageName = "")
            : base(debugConfigurationName, releaseConfigurationName)
        {
            if (Builder.UseDotNet)
            {
                SetProperty(KnownProperties.OutputType, "Exe");
                SetProperty("XamarinAndroidSupportSkipVerifyVersions", "True");
                SetProperty("_FastDeploymentDiagnosticLogging", "True");

                // Workaround for AndroidX, see: https://github.com/xamarin/AndroidSupportComponents/pull/239
                Imports.Add(new Import(() => "Directory.Build.targets")
                {
                    TextContent = () =>
                                  @"<Project>
							<PropertyGroup>
								<VectorDrawableCheckBuildToolsVersionTaskBeforeTargets />
							</PropertyGroup>
						</Project>"
                });
            }
            else
            {
                SetProperty("_FastDeploymentDiagnosticLogging", "True");
                SetProperty("AndroidApplication", "True");
                SetProperty("AndroidResgenClass", "Resource");
                SetProperty("AndroidResgenFile", () => "Resources\\Resource.designer" + Language.DefaultDesignerExtension);
                SetProperty("AndroidManifest", "Properties\\AndroidManifest.xml");
                SetProperty(DebugProperties, "AndroidLinkMode", "None");
                SetProperty(ReleaseProperties, "AndroidLinkMode", "SdkOnly");
                SetProperty(DebugProperties, KnownProperties.EmbedAssembliesIntoApk, "False", "'$(EmbedAssembliesIntoApk)' == ''");
                SetProperty(ReleaseProperties, KnownProperties.EmbedAssembliesIntoApk, "True", "'$(EmbedAssembliesIntoApk)' == ''");
            }

            AndroidManifest  = default_android_manifest;
            TargetSdkVersion = AndroidSdkResolver.GetMaxInstalledPlatform().ToString();
            LayoutMain       = default_layout_main;
            StringsXml       = default_strings_xml;
            PackageName      = $"com.xamarin.{(packageName ?? ProjectName).ToLower ()}";
            JavaPackageName  = JavaPackageName ?? PackageName.ToLowerInvariant();

            OtherBuildItems.Add(new BuildItem.NoActionResource("Properties\\AndroidManifest.xml")
            {
                TextContent = ProcessManifestTemplate,
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\layout\\Main.axml")
            {
                TextContent = () => LayoutMain
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\values\\Strings.xml")
            {
                TextContent = () => StringsXml.Replace("${PROJECT_NAME}", ProjectName)
            });

            Sources.Add(new BuildItem.Source(() => "MainActivity" + Language.DefaultExtension)
            {
                TextContent = () => ProcessSourceTemplate(MainActivity ?? DefaultMainActivity)
            });
        }
        public XamarinFormsAndroidApplicationProject(string debugConfigurationName = "Debug", string releaseConfigurationName = "Release")
            : base(debugConfigurationName, releaseConfigurationName)
        {
            var forms = KnownPackages.XamarinForms_3_1_0_697729;

            Packages.Add(forms);
            Packages.Add(KnownPackages.Android_Arch_Core_Common_26_1_0);
            Packages.Add(KnownPackages.Android_Arch_Lifecycle_Common_26_1_0);
            Packages.Add(KnownPackages.Android_Arch_Lifecycle_Runtime_26_1_0);
            Packages.Add(KnownPackages.AndroidSupportV4_27_0_2_1);
            Packages.Add(KnownPackages.SupportCompat_27_0_2_1);
            Packages.Add(KnownPackages.SupportCoreUI_27_0_2_1);
            Packages.Add(KnownPackages.SupportCoreUtils_27_0_2_1);
            Packages.Add(KnownPackages.SupportDesign_27_0_2_1);
            Packages.Add(KnownPackages.SupportFragment_27_0_2_1);
            Packages.Add(KnownPackages.SupportMediaCompat_27_0_2_1);
            Packages.Add(KnownPackages.SupportV7AppCompat_27_0_2_1);
            Packages.Add(KnownPackages.SupportV7CardView_27_0_2_1);
            Packages.Add(KnownPackages.SupportV7MediaRouter_27_0_2_1);
            Packages.Add(KnownPackages.SupportV7RecyclerView_27_0_2_1);
            Packages.Add(KnownPackages.VectorDrawable_27_0_2_1);

            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\values\\colors.xml")
            {
                TextContent = () => colors_xml,
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\values\\styles.xml")
            {
                TextContent = () => styles_xml,
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\layout\\Tabbar.axml")
            {
                TextContent = () => Tabbar_axml,
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\layout\\Toolbar.axml")
            {
                TextContent = () => Toolbar_axml,
            });
            OtherBuildItems.Add(new BuildItem("EmbeddedResource", "MainPage.xaml")
            {
                TextContent = () => ProcessSourceTemplate(MainPage_xaml),
            });
            Sources.Add(new BuildItem.Source("MainPage.xaml.cs")
            {
                TextContent = () => ProcessSourceTemplate(MainPage_xaml_cs),
            });
            OtherBuildItems.Add(new BuildItem("EmbeddedResource", "App.xaml")
            {
                TextContent = () => ProcessSourceTemplate(App_xaml),
            });
            Sources.Add(new BuildItem.Source("App.xaml.cs")
            {
                TextContent = () => ProcessSourceTemplate(App_xaml_cs),
            });
            Imports.Add(new Import($@"..\packages\{forms.Id}.{forms.Version}\build\netstandard2.0\Xamarin.Forms.targets"));

            MainActivity = default_main_activity_cs;
        }
        public XamarinFormsAndroidApplicationProject(string debugConfigurationName = "Debug", string releaseConfigurationName = "Release", [CallerMemberName] string packageName = "")
            : base(debugConfigurationName, releaseConfigurationName, packageName)
        {
            if (Builder.UseDotNet)
            {
                PackageReferences.Add(KnownPackages.XamarinForms_4_7_0_1142);
                this.AddDotNetCompatPackages();
            }
            else
            {
                PackageReferences.Add(KnownPackages.XamarinForms_4_0_0_425677);
            }

            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\values\\colors.xml")
            {
                TextContent = () => colors_xml,
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\values\\styles.xml")
            {
                TextContent = () => styles_xml,
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\layout\\Tabbar.axml")
            {
                TextContent = () => Tabbar_axml,
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\layout\\Toolbar.axml")
            {
                TextContent = () => Toolbar_axml,
            });
            OtherBuildItems.Add(new BuildItem("EmbeddedResource", "MainPage.xaml")
            {
                TextContent = MainPageXaml,
            });
            Sources.Add(new BuildItem.Source("MainPage.xaml.cs")
            {
                TextContent = () => ProcessSourceTemplate(MainPage_xaml_cs),
            });
            OtherBuildItems.Add(new BuildItem("EmbeddedResource", "App.xaml")
            {
                TextContent = () => ProcessSourceTemplate(App_xaml),
            });
            Sources.Add(new BuildItem.Source("App.xaml.cs")
            {
                TextContent = () => ProcessSourceTemplate(App_xaml_cs),
            });

            MainActivity = default_main_activity_cs;
        }
예제 #5
0
        public XamarinFormsAndroidApplicationProject(string debugConfigurationName = "Debug", string releaseConfigurationName = "Release")
            : base(debugConfigurationName, releaseConfigurationName)
        {
            //NOTE: we can get all the other dependencies transitively, yay!
            PackageReferences.Add(KnownPackages.XamarinForms_3_6_0_220655);

            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\values\\colors.xml")
            {
                TextContent = () => colors_xml,
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\values\\styles.xml")
            {
                TextContent = () => styles_xml,
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\layout\\Tabbar.axml")
            {
                TextContent = () => Tabbar_axml,
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\layout\\Toolbar.axml")
            {
                TextContent = () => Toolbar_axml,
            });
            OtherBuildItems.Add(new BuildItem("EmbeddedResource", "MainPage.xaml")
            {
                TextContent = () => ProcessSourceTemplate(MainPage_xaml),
            });
            Sources.Add(new BuildItem.Source("MainPage.xaml.cs")
            {
                TextContent = () => ProcessSourceTemplate(MainPage_xaml_cs),
            });
            OtherBuildItems.Add(new BuildItem("EmbeddedResource", "App.xaml")
            {
                TextContent = () => ProcessSourceTemplate(App_xaml),
            });
            Sources.Add(new BuildItem.Source("App.xaml.cs")
            {
                TextContent = () => ProcessSourceTemplate(App_xaml_cs),
            });

            MainActivity = default_main_activity_cs;
        }
        public XamarinAndroidApplicationProject(string debugConfigurationName = "Debug", string releaseConfigurationName = "Release")
            : base(debugConfigurationName, releaseConfigurationName)
        {
            SetProperty("AndroidApplication", "True");

            SetProperty("AndroidResgenClass", "Resource");
            SetProperty("AndroidResgenFile", () => "Resources\\Resource.designer" + Language.DefaultDesignerExtension);
            SetProperty("AndroidManifest", "Properties\\AndroidManifest.xml");
            SetProperty(DebugProperties, "AndroidLinkMode", "None");
            SetProperty(ReleaseProperties, "AndroidLinkMode", "SdkOnly");
            SetProperty(DebugProperties, KnownProperties.EmbedAssembliesIntoApk, "False", "'$(EmbedAssembliesIntoApk)' == ''");
            SetProperty(ReleaseProperties, KnownProperties.EmbedAssembliesIntoApk, "True", "'$(EmbedAssembliesIntoApk)' == ''");

            AndroidManifest = default_android_manifest;
            LayoutMain      = default_layout_main;
            StringsXml      = default_strings_xml;
            PackageName     = PackageName ?? string.Format("{0}.{0}", ProjectName);
            JavaPackageName = JavaPackageName ?? PackageName.ToLowerInvariant();

            OtherBuildItems.Add(new BuildItem.NoActionResource("Properties\\AndroidManifest.xml")
            {
                TextContent = () =>
                              AndroidManifest.Replace("${PROJECT_NAME}", ProjectName).
                              Replace("${PACKAGENAME}", PackageName)
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\layout\\Main.axml")
            {
                TextContent = () => LayoutMain
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\values\\Strings.xml")
            {
                TextContent = () => StringsXml.Replace("${PROJECT_NAME}", ProjectName)
            });

            Sources.Add(new BuildItem.Source(() => "MainActivity" + Language.DefaultExtension)
            {
                TextContent = () => ProcessSourceTemplate(MainActivity ?? DefaultMainActivity)
            });
        }
예제 #7
0
        public XamarinFormsMapsApplicationProject([CallerMemberName] string packageName = "")
            : base(packageName: packageName)
        {
            if (Builder.UseDotNet)
            {
                PackageReferences.Add(KnownPackages.XamarinFormsMaps_4_7_0_1142);
                PackageReferences.Add(KnownPackages.Xamarin_GooglePlayServices_Base);
                PackageReferences.Add(KnownPackages.Xamarin_GooglePlayServices_Basement);
                PackageReferences.Add(KnownPackages.Xamarin_GooglePlayServices_Maps);
                PackageReferences.Add(KnownPackages.Xamarin_GooglePlayServices_Tasks);

                //TODO: temporary fix for <Import/> ordering breakage and workloads
                SetProperty("AndroidApplication", "True");
            }
            else
            {
                PackageReferences.Add(KnownPackages.XamarinFormsMaps_4_0_0_425677);
            }
            MainActivity = MainActivity.Replace("//${AFTER_FORMS_INIT}", "Xamarin.FormsMaps.Init (this, savedInstanceState);");
            //NOTE: API_KEY metadata just has to *exist*
            AndroidManifest = AndroidManifest.Replace("</application>", "<meta-data android:name=\"com.google.android.maps.v2.API_KEY\" android:value=\"\" /></application>");
            // From https://github.com/xamarin/GooglePlayServicesComponents/blob/fc057c754e04d3e719d8c111d03d60eb2467b9ce/source/com.google.android.gms/play-services-basement/buildtasks.tests/google-services.json
            OtherBuildItems.Add(new BuildItem("GoogleServicesJson", "google-services.json")
            {
                Encoding    = new System.Text.UTF8Encoding(encoderShouldEmitUTF8Identifier: false),
                TextContent = () =>
                              @"{
  ""project_info"": {
    ""project_number"": ""1041063143217"",
    ""firebase_url"": ""https://white-cedar-97320.firebaseio.com"",
    ""project_id"": ""white-cedar-97320"",
    ""storage_bucket"": ""white-cedar-97320.appspot.com""
  },
  ""client"": [
    {
      ""client_info"": {
        ""mobilesdk_app_id"": ""1:1041063143217:android:ffbe6976403db935"",
        ""android_client_info"": {
          ""package_name"": ""com.xamarin.sample""
        }
      },
      ""oauth_client"": [
        {
          ""client_id"": ""1041063143217-rve97omgqivvs3qcne1ljso137k3t6po.apps.googleusercontent.com"",
          ""client_type"": 1,
          ""android_info"": {
            ""package_name"": ""com.xamarin.sample"",
            ""certificate_hash"": ""84949BBD3F34C8290A55AC9B66AD0A701EBA67AC""
          }
        },
        {
          ""client_id"": ""1041063143217-hu5u4dnv8dkj19i4tpi6piv97kd2k9i0.apps.googleusercontent.com"",
          ""client_type"": 3
        },
        {
          ""client_id"": ""1041063143217-n82odtjjgs9g2qnh1t470mdhj086id9f.apps.googleusercontent.com"",
          ""client_type"": 3
        }
      ],
      ""api_key"": [
        {
          ""current_key"": ""NOT_A_REAL_KEY""
        }
      ],
      ""services"": {
        ""analytics_service"": {
          ""status"": 2,
          ""analytics_property"": {
            ""tracking_id"": ""UA-6465612-26""
          }
        },
        ""appinvite_service"": {
          ""status"": 2,
          ""other_platform_oauth_client"": [
            {
              ""client_id"": ""1041063143217-hu5u4dnv8dkj19i4tpi6piv97kd2k9i0.apps.googleusercontent.com"",
              ""client_type"": 3
            },
            {
              ""client_id"": ""1041063143217-rdc97s7jssl1k29c83b6oci04sihqkdi.apps.googleusercontent.com"",
              ""client_type"": 2,
              ""ios_info"": {
                ""bundle_id"": ""com.xamarin.googleios.collectallthestars""
              }
            }
          ]
        },
        ""ads_service"": {
          ""status"": 2
        }
      }
    }
  ],
  ""configuration_version"": ""1""
}"
            });
        }