Xamarin cloud apk错误

时间:2016-06-09 08:46:35

标签: c# android unit-testing xamarin

我为测试云编写测试。

当我在电脑上运行它时传递​​良好。

测试代码:

   using System;
using System.IO;
using System.Linq;
using NUnit.Framework;
using Xamarin.UITest;
using Xamarin.UITest.Android;
using Xamarin.UITest.Queries;

namespace MurakamiKiev.UITests
{
    [TestFixture]
    public class Tests
    {
        AndroidApp app;

        [SetUp]
        public void SetUp ()
        {
            //app = ConfigureApp
            //.Android
            //.ApkFile("com.digitalmakers.murakamikiev-Signed.apk")
            //.PreferIdeSettings()
            //.StartApp();
            app = ConfigureApp.Android.StartApp();
        }


        [Test]
        public void AppLaunch()
        {

           // app.Repl();
           Func<AppQuery, AppQuery> bludodnyabuttonQuery = e => e.Id("bludodnya");

            //app.Flash(e => e.Id("bludodnya"));
            //app.Tap(e => e.Id("bludodnya"));

            app.WaitForElement(bludodnyabuttonQuery, "Timed out waiting for tapping bludo dnya");
            app.Tap(bludodnyabuttonQuery);



        }
    }
}

当我在Xamarin Test Cloud上传时,我测试失败了

我在日志中有这个:

     SetUp Error : MurakamiKiev.UITests.Tests.AppLaunch
   SetUp : System.Exception : Multiple launchable acitivites configured in apk file, none was specified.  Available launchable activities: md5b02f34a74755c1c88b16cc48d7de656d.SplashActivity, com.digitalmakers.murakamikiev.MainActivity
  at Xamarin.UITest.Shared.Android.ApkFile.GetActivityToLaunchOrFail (System.String wantedActivity) <0x5a10808 + 0x0023f> in <filename unknown>:0 
  at Xamarin.UITest.Android.TestCloudAndroidAppInitializer.VerifyConfiguration () <0x5a10240 + 0x00083> in <filename unknown>:0 
  at Xamarin.UITest.Android.AndroidApp..ctor (IAndroidAppConfiguration appConfiguration) <0x58a6518 + 0x002a5> in <filename unknown>:0 
  at Xamarin.UITest.Configuration.AndroidAppConfigurator.StartApp (AppDataMode appDataMode) <0x58a5a58 + 0x00063> in <filename unknown>:0 
  at MurakamiKiev.UITests.Tests.SetUp () <0x58a47c8 + 0x00043> in <filename unknown>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
 at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x7e3070 + 0x00093> in <filename unknown>:0 

我的宣言:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.6" package="com.digitalmakers.murakamikiev" android:installLocation="auto" android:versionCode="43">

<uses-sdk android:targetSdkVersion="23" android:minSdkVersion="15" />
<application android:label="Murakami" android:icon="@drawable/icon3">

 android:largeHeap="true"

    <meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyBlOLY2SjQ6l7-O-wRuMeyD_QzwhIh-9x4" /><meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /></application>
<activity android:label="Murakami" android:screenOrientation="portrait">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

MainActivity代码:

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Content.PM;
using System.Json;
using System.Threading.Tasks;
using System.Net;
using System.IO;
using Android.Graphics;
using Android.Preferences;
using Android.Gms.Analytics;

namespace MurakamiKiev
{

    [Activity(Label = "Murakami",Icon = "@drawable/logo", Theme = "@android:style/Theme.Black.NoTitleBar", ScreenOrientation = ScreenOrientation.Portrait)]
    public class MainActivity : Activity
    {
        // Integrating Google Analitycs - start
        public class GAService
        {
            public string TrackingId = "UA-65673888-2";

            private static GoogleAnalytics GAInstance;
            private static Tracker GATracker;

            #region Instantiation ...
            private static GAService thisRef;
            private GAService()
            {
                // no code req'd
            }

            public static GAService GetGASInstance()
            {
                if (thisRef == null)
                    // it's ok, we can call this constructor
                    thisRef = new GAService();
                return thisRef;
            }
            #endregion

            public void Initialize(Context AppContext)
            {
                GAInstance = GoogleAnalytics.GetInstance(AppContext.ApplicationContext);
                GAInstance.SetLocalDispatchPeriod(10);

                GATracker = GAInstance.NewTracker(TrackingId);
                GATracker.EnableExceptionReporting(true);
                GATracker.EnableAdvertisingIdCollection(true);
                GATracker.EnableAutoActivityTracking(true);
            }
        }
        // end of integrating Analitycs



        protected override void OnCreate (Bundle bundle)
        {


            base.OnCreate (bundle);



            SetContentView (Resource.Layout.Main);

            GAService.GetGASInstance().Initialize(this);

            // Sets images for the slider icons and their size



            Button sushi = FindViewById<Button> (Resource.Id.sushi);
            Button sets = FindViewById<Button> (Resource.Id.seti);
            //Button holodni = FindViewById<Button> (Resource.Id.holodni);
            Button deserts = FindViewById<Button> (Resource.Id.deserts);
            Button salads = FindViewById<Button> (Resource.Id.salads);
            Button souces = FindViewById<Button> (Resource.Id.souces);
            Button soupes = FindViewById<Button> (Resource.Id.soupes);
            //Button goryachie = FindViewById<Button> (Resource.Id.goryachie);
            Button lokshina = FindViewById<Button> (Resource.Id.lokshina);
            Button lanchi = FindViewById<Button> (Resource.Id.lanchi);

            Button tepan = FindViewById<Button> (Resource.Id.tepan);
            Button zakuski = FindViewById<Button> (Resource.Id.zakuski);
            Button napoi = FindViewById<Button> (Resource.Id.napoi);
            Button osnovni = FindViewById<Button> (Resource.Id.osnovni);
            Button sashimi = FindViewById<Button> (Resource.Id.sashimi);


            Button rolli = FindViewById<Button> (Resource.Id.rolli);
            ImageButton menu = FindViewById<ImageButton> (Resource.Id.menuButton);
            ImageButton cart = FindViewById<ImageButton> (Resource.Id.cartButton);

            //Otslezivaem click po knopke 'next' i perehodim dalshe
            souces.Click += delegate {
                Vibrator vib2 = (Vibrator)this.GetSystemService (Context.VibratorService);
                vib2.Vibrate (30);
                var intent = new Intent (this, typeof(Souces));
                StartActivity (intent);
            };
            lanchi.Click += delegate {
                Vibrator vib2 = (Vibrator)this.GetSystemService (Context.VibratorService);
                vib2.Vibrate (30);
                var intent = new Intent (this, typeof(Lanchi));
                StartActivity (intent);
            };
            zakuski.Click += delegate {
                Vibrator vib2 = (Vibrator)this.GetSystemService (Context.VibratorService);
                vib2.Vibrate (30);
                var intent = new Intent (this, typeof(ZakuskiActivity));
                StartActivity (intent);
            };
            sashimi.Click += delegate {
                Vibrator vib2 = (Vibrator)this.GetSystemService (Context.VibratorService);
                vib2.Vibrate (30);
                var intent = new Intent (this, typeof(SashimiActivity));
                StartActivity (intent);
            };
            osnovni.Click += delegate {
                Vibrator vib2 = (Vibrator)this.GetSystemService (Context.VibratorService);
                vib2.Vibrate (30);
                var intent = new Intent (this, typeof(OsnovniBludaActivity));
                StartActivity (intent);
            };
            napoi.Click += delegate {
                Vibrator vib2 = (Vibrator)this.GetSystemService (Context.VibratorService);
                vib2.Vibrate (30);
                var intent = new Intent (this, typeof(NapitkiActivity));
                StartActivity (intent);
            };

            lokshina.Click += delegate {
                Vibrator vib2 = (Vibrator)this.GetSystemService (Context.VibratorService);
                vib2.Vibrate (30);
                var intent = new Intent (this, typeof(LapshaActivity));
                StartActivity (intent);
            };
            /*goryachie.Click += delegate {
                Vibrator vib2 = (Vibrator)this.GetSystemService (Context.VibratorService);
                vib2.Vibrate (30);
                var intent = new Intent (this, typeof(GoryachieZakuskiActivity));
                StartActivity (intent);
            };*/
            soupes.Click += delegate {
                Vibrator vib2 = (Vibrator)this.GetSystemService (Context.VibratorService);
                vib2.Vibrate (30);
                var intent = new Intent (this, typeof(SoupesActivity));
                StartActivity (intent);
            };
            salads.Click += delegate {
                Vibrator vib2 = (Vibrator)this.GetSystemService (Context.VibratorService);
                vib2.Vibrate (30);
                var intent = new Intent (this, typeof(SaladsActivity));
                StartActivity (intent);
            };
            deserts.Click += delegate {
                Vibrator vib = (Vibrator)this.GetSystemService (Context.VibratorService);
                vib.Vibrate (30);
                var intent140 = new Intent (this, typeof(DesertsActivity));
                StartActivity (intent140);
            };
            rolli.Click += delegate {
                Vibrator vib3 = (Vibrator)this.GetSystemService (Context.VibratorService);
                vib3.Vibrate (30);
                var intent139 = new Intent (this, typeof(RolliKategorii));
                StartActivity (intent139);

            };
            sets.Click += delegate {
                Vibrator vib3 = (Vibrator)this.GetSystemService (Context.VibratorService);
                vib3.Vibrate (30);
                var intent121 = new Intent (this, typeof(SetsActivity));
                StartActivity (intent121);

            };
            sushi.Click += delegate {

                Vibrator vib4 = (Vibrator)this.GetSystemService (Context.VibratorService);
                vib4.Vibrate (30);
                var intent24 = new Intent (this, typeof(SushiActivity));
                StartActivity (intent24);

            };
            tepan.Click += delegate {

                Vibrator vib4 = (Vibrator)this.GetSystemService (Context.VibratorService);
                vib4.Vibrate (30);
                var intent24 = new Intent (this, typeof(Tepan));
                StartActivity (intent24);

            };

            //Otlezivaem click po knopke 'Korzina' i perehodim v nee
            cart.Click += delegate {
                var intent2 = new Intent (this, typeof(CartActivity));
                StartActivity (intent2);
            };
            menu.Click += delegate {
                var intent39 = new Intent (this, typeof(MenuTopActivity));
                ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this);
                ISharedPreferencesEditor editor = prefs.Edit();
                editor.Clear();
                editor.Commit();
                StartActivity (intent39);

            };



            }
        }






        }

但我只在SplashActivity中有MainLauncher=true

我如何解决此错误?

请帮帮我:(

0 个答案:

没有答案