deployment failed without any error - xamarin

I created this small application. I build the application and can see the icon on the emulator when I clicked the icon, the page opens without showing anything and then it closes again without showing any error. I cancelled the build and then it shows the below message in the output window:
C:\Program Files (x86)\Android\android-sdk\build-tools\23.0.0\zipalign.exe 4 "C:\VisualStudioMobileApplication\App3\App3\App3.Android\bin\Debug\com.companyname.app-Signed-Unaligned.apk" "bin\Debug\\com.companyname.app-Signed.apk"
1>Done building project "App3.Android.csproj" -- FAILED.
1>Build FAILED.
1>
1>Deploy failed on VisualStudio_android-23_arm_phone
1>Process was cancelled
Build has been canceled.
It does not give any error. I also put the break point on "OnCreate" method in MainActivity.cs file.The code does not break on that breakpoint even when I click on App3 icon.Below is my code for MainActivity.cs
using System;
using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace App3.Droid
{
[Activity(Label = "App3", Icon = "#drawable/icon", Theme = "#style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
Xamarin.FormsMaps.Init(this, bundle);
LoadApplication(new App());
}
}
}
The code on MainPage.xaml is below:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App3"
xmlns:maps="clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps"
x:Class="App3.MainPage">
<StackLayout VerticalOptions="StartAndExpand" Padding="30">
<maps:Map WidthRequest="960" HeightRequest="700"
x:Name="MyMap"
IsShowingUser="True"
MapType="Street"
/>
</StackLayout>
</ContentPage>
The code in MainPage.xaml.cs is below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Maps;
namespace App3
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
MyMap.MoveToRegion(
MapSpan.FromCenterAndRadius(
new Position(37, -122), Distance.FromMiles(1)));
}
}
}
I am using Visual studio 2017 enterprise version 15.6. The build of the entire project is always successful.
Below are my androidManifest.xml file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.app" android:installLocation="auto">
<uses-sdk android:targetSdkVersion="27" />
<application android:label="app3.android">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyD1K1njDAN0"/>
</application>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
I really need help to display the map when I click on App3. Any help will be highly appreciated.

On Windows, if you're using Hyper-V for your emulator, you can try this:
Start Hyper V manager
Select your machine under 'Hyper-V Manager'
Under Virtual Machines, right click on the VS emulator you are
trying to run your app on, select Settings.
Expand the 'Processor' node, select Compatibility.
Check the 'Migrate to a physical
computer with a different processor version' box, click OK and try
running your app again.
Hope it helps. Cheers!

Related

minio upgrade issue xml invalid

Task: Trying to upgrade from minio.netcore 1.1.1 client to minio client 3.1.13
Problem: When i try to create a bucket with the new client I get the following excpetion thrown:
MinIO API responded with message=The XML you provided was not well-formed or
did not validate against our published schema
I've tested in isolation from the rest of my code and can't see what the issue is:
using System;
using System.Threading.Tasks;
namespace ConsoleApp3
{
class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("Hello World!");
var client = new Minio.MinioClient("{serverIpAddress}:9000", "myaccesskey", "mysecretkey");
var bucketid = Guid.NewGuid().ToString();
await client.MakeBucketAsync(bucketid,"uk-st-1");
var result = await client.BucketExistsAsync(bucketid);
}
}
}
and my csproj is switching between these 2 nugets:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Minio" Version="3.1.13" />
<!--<PackageReference Include="Minio.NetCore" Version="1.1.1" />-->
</ItemGroup>
</Project>
I've tried catching the traffic and the XML it produces for both nugets is this:
<?xml version="1.0" encoding="utf-8"?>
<q1:CreateBucketConfiguration xmlns:q1="http://s3.amazonaws.com/doc/2006-03-01/">
<q1:LocationConstraint>uk-st-1</q1:LocationConstraint>
</q1:CreateBucketConfiguration>

Does Xamarin support class library project reference nesting, generating an AndroidManifest.xml for components in nested references?

Does Xamarin support multiple levels of project reference nesting, where the referenced project includes Android components intended for the AndroidManifest.xml?
For example: AndoidXamarin App > ClassLibrary1 > (which declares a Service) ClassLibrary2 (which also declares a Service):
// ClassLibrary1:
// Referenced by the XamarinApp
// References ClassLibrary2
namespace ClassLibrary1
{
[Service(Exported = true, Name = "com.company.test." + nameof(ClassLib1Service))]
public class ClassLib1Service : Service
{
public override IBinder OnBind(Intent intent) => throw new NotImplementedException();
}
}
// ClassLibrary2
// Referenced only by ClassLibrary1
namespace ClassLibrary2
{
[Service(Exported = true, Name = "com.company.test." + nameof(ClassLib2Service))]
public class ClassLib2Service : Service
{
public override IBinder OnBind(Intent intent) => throw new NotImplementedException();
}
}
// The generated `AndroidManifest.xml` only includes the Service defined in ClassLibrary1.
<application android:allowBackup="true" android:icon="#mipmap/ic_launcher" android:label="#string/app_name" android:roundIcon="#mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="#style/AppTheme" android:name="android.app.Application">
<activity android:label="#string/app_name" android:theme="#style/AppTheme" android:name="crc64a7a6b04b89628087.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:exported="true" android:name="com.company.test.ClassLib1Service" />
<provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="1999999999" android:authorities="com.company.test.mono.MonoRuntimeProvider.__mono_init__" />
</application>

Xamarin.Android: Unable to instantiate activity ComponentInfo

I am receiving this error when trying to launch a Xamarin forms application on Android from a text message URL. I have been following the steps noted in THIS article.
Here the application node in my AppManifest.xml
<application android:label="Label A">
<activity android:icon="#drawable/Icon" android:label="LabelB" android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="superduperapp" />
</intent-filter>
</activity>
</application>
According to the article I need to do something with intent objects to get the OnCreate override to fire but I think I am not matching something up right with my manifest and the naming convention for a class I created below.
[Activity(Label = "urlentryclass")]
public class OpenFromURI : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
Intent outsideIntent = Intent;
var x = Intent.Data.EncodedAuthority;
}
}
So, with the above code added to my xamarin solution I also have a webpage with the code below..
and when i click the link above from my mobile browser it touches the mobile app because I get the error below
MyApp.Mobile.Droid.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "MyApp.Mobile.Droid.MainActivity" on path: DexPathList[[zip file "/data/app/MyApp.Mobile.Droid-1/base.apk"],nativeLibraryDirectories=[/data/app/MyApp.Mobile.Droid-1/lib/arm64, /data/app/MyApp.Mobile.Droid-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]] occurred
MyApp.Mobile.Droid.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "MyApp.Mobile.Droid.MainActivity"
Xamarin.Android, by default, generates the Java wrappers using MD5-based class names to avoid Java class name clashing, such as:
md579731053346ff64fcf21847b09163ce1.MainActivity
You have hard-coded a android:name=".MainActivity" in your manifest but the generated class will be MD5-based by default.
Open up your MainActivity and within the ActivityAttribute on your MainActvity class, add a fully qualified name within a Name parameter of that attribute, this will force the Xamarin.Android build process to use a Java-class name of your choosing vs. the MD5-based one and thus it will match your manifest entry.
Example:
[Activity(Name = "MyApp.Mobile.Droid.MainActivity", Label = "MySuperDuperApp", MainLauncher = true, Icon = "#mipmap/icon")]
public class MainActivity : Activity
{
~~~

MEF Import Exception w/ Visual Studio 2015 Extension

Hoping someone can provide me with some guidance on an issue I'm facing using MEF with my VS2015 extension. I'm attempting to extend the IntelliSense capabilities of VS and followed this tutorial as a basis: https://msdn.microsoft.com/en-us/library/ee372314.aspx
Here is my ICompletionSourceProvider:
[Export(typeof(ICompletionSourceProvider))]
[Name("Test Statement Completion Provider")]
[Order(Before = "default")]
[ContentType("text")]
internal class MyCompletionSourceProvider : ICompletionSourceProvider
{
[Import]
internal ITextStructureNavigatorSelectorService NavigatorService { get; set; }
[Import]
internal IServiceProvider ServiceProvider { get; set; }
public ICompletionSource TryCreateCompletionSource(ITextBuffer textBuffer)
{
return new MyCompletionSource(this, textBuffer);
}
}
The strange thing here is that this works fine on my machine (where this code was initially developed on), but fails to work on every other machine I've tried (both in Debug and Release). Breakpoints placed within TryCreateCompletionSource are never hit. I suspected this MEF component was never being exported, so I downloaded the mefx tool as recommend on MSDN and executed it on my generated DLL and received the following:
[Primary Rejection]
[Export] MyVSIX.Source.MyCompletionSourceProvider (ContractName="Microsoft.VisualStudio.Language.Intellisense.ICompletionSourceProvider")
[Import] MyVSIX.Source.MyCompletionSourceProvider.NavigatorService (ContractName="Microsoft.VisualStudio.Text.Operations.ITextStructureNavigatorSelectorService")
[Exception] System.ComponentModel.Composition.ImportCardinalityMismatchException: No exports were found that match the constraint:
ContractName Microsoft.VisualStudio.Text.Operations.ITextStructureNavigatorSelectorService
RequiredTypeIdentity Microsoft.VisualStudio.Text.Operations.ITextStructureNavigatorSelectorService
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
at Microsoft.ComponentModel.Composition.Diagnostics.CompositionInfo.AnalyzeImportDefinition(ExportProvider host, IEnumerable`1 availableParts, ImportDefinition id)
[Import] MyVSIX.Source.MyCompletionSourceProvider.ServiceProvider (ContractName="System.IServiceProvider")
[Exception] System.ComponentModel.Composition.ImportCardinalityMismatchException: No exports were found that match the constraint:
ContractName System.IServiceProvider
RequiredTypeIdentity System.IServiceProvider
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
at Microsoft.ComponentModel.Composition.Diagnostics.CompositionInfo.AnalyzeImportDefinition(ExportProvider host, IEnumerable`1 availableParts, ImportDefinition id)
If I remove the [Import] statements these are all resolved and things begin working again. From the tutorial though, this seems as though it should just work. This also doesn't explain why it works 100% of the time on my machine and never works on any other machines.
This is my .vsixmanifest file:
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="MyVSIX.Company.39048217-955a-4402-84e9-8a24f0730e72" Version="1.0" Language="en-US" Publisher="MyVSIX" />
<DisplayName>MyVSIX</DisplayName>
<Description xml:space="preserve"></Description>
<Icon>Resources\MyVSIX.ico</Icon>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[14.0]" />
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
<Dependency Id="Microsoft.VisualStudio.MPF.14.0" DisplayName="Visual Studio MPF 14.0" d:Source="Installed" Version="[14.0]" />
</Dependencies>
<Assets>
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%|" />
<Asset Type="Microsoft.VisualStudio.ItemTemplate" Path="Output\ItemTemplates" />
<Asset Type="Microsoft.VisualStudio.ProjectTemplate" Path="Output\ProjectTemplates" />
</Assets>
</PackageManifest>
Figured out why it wasn't working on other machines, but I still cannot understand why it was ever working on my machine. I changed this:
[Import]
internal IServiceProvider ServiceProvider { get; set; }
to this:
[Import(typeof(SVsServiceProvider)]
internal IServiceProvider ServiceProvider { get; set; }
Hope this helps someone in the future - I spent 2 days figuring this out!

android-beacon-library can not detect iBeacon advertiser

Due to the problem mentioned here, I configure the mornitoring example code as follows, however my app can not detect the iBeacon advertiser deployed.
new a mornitoring Activity named MainActivity, except the onCreate method, all other code are the same as the sample code.
public class MainActivity extends Activity implements BeaconConsumer {
protected static final String TAG = "MornitoringActivity";
public static final String UUID = "UUID: D57092AC-DFAA-446C-8EF3-C81AA22815B5";
private BeaconManager beaconManager = BeaconManager.getInstanceForApplication(this);
TextView mInfoView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mInfoView = (TextView) findViewById(R.id.show_info_lable);
beaconManager.setDebug(true);
beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
beaconManager.bind(this);
Log.i(TAG, "on create complete!");
}
#Override
protected void onDestroy() {
super.onDestroy();
beaconManager.unbind(this);
Log.i(TAG, "on destroy complete!");
}
#Override
public void onBeaconServiceConnect() {
beaconManager.setMonitorNotifier(new MonitorNotifier() {
#Override
public void didEnterRegion(Region region) {
Log.i(TAG, "I just saw an beacon for the first time!");
mInfoView.setText("I just saw an beacon for the first time!");
}
#Override
public void didExitRegion(Region region) {
Log.i(TAG, "I no longer see an beacon");
mInfoView.setText("I no longer see an beacon");
}
#Override
public void didDetermineStateForRegion(int state, Region region) {
Log.i(TAG, "I have just switched from seeing/not seeing beacons: "+state);
mInfoView.setText("I have just switched from seeing/not seeing beacons: "+state); }
});
try {
beaconManager.startMonitoringBeaconsInRegion(new Region("myMonitoringUniqueId", Identifier.parse(UUID), null, null));
} catch (RemoteException e) { }
}
}
copy class.jar in android-beacon-library/libs/ into myProject/libs/, and add it to build path
manually edit the AndroidManifest.xml, here is my xml file,
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mymornitoring"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:allowBackup="true"
android:icon="#drawable/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>
<service
android:enabled="true"
android:exported="true"
android:isolatedProcess="false"
android:label="beacon"
android:name="org.altbeacon.beacon.service.BeaconService">
</service>
<service
android:enabled="true"
android:name="org.altbeacon.beacon.BeaconIntentProcessor">
</service>
<receiver android:name="org.altbeacon.beacon.startup.StartupBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.ACTION_POWER_CONNECTED"/>
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED"/>
</intent-filter>
</receiver>
</application>
Use Macbook running the BeaconOSX app to perform as an iBeacon advertiser.(And I've use the AirLocate app on iPhone 4s to confirm the iBeacon advertiser works, however fail to be detected by the iBeacon Locate android app developed by Radius Networks)
Then I ran myProject on Nexus 5, the logcat messages are as below
11-06 10:49:08.838: I/BeaconService(5023): beaconService version 2.0 is starting up
11-06 10:49:08.878: D/BeaconService(5023): No org.altbeacon.beacon.SimulatedScanData class exists.
11-06 10:49:08.878: I/BeaconService(5023): binding
11-06 10:49:08.908: I/BeaconService(5023): start monitoring received
11-06 10:49:08.908: D/BeaconService(5023): startMonitoring called
11-06 10:49:08.908: D/BeaconService(5023): Currently monitoring 1 regions.
11-06 10:49:08.928: D/BeaconService(5023): Waiting to stop scan for another 1100 milliseconds
11-06 10:49:08.928: D/BeaconService(5023): Scan started
11-06 10:49:09.938: D/BeaconService(5023): Waiting to stop scan for another 99 milliseconds
11-06 10:49:10.038: D/BeaconService(5023): Done with scan cycle
11-06 10:49:10.048: D/BeaconService(5023): Restarting scan. Unique beacons seen last cycle: 0 Total beacon advertisement packets seen: 0
This idicate the BeaconService works well.
11-06 10:48:41.238: D/BtGatt.GattService(1483): registerClient() - UUID=6eaaf541-90fb-4e88-a0d5-1f267769128b
11-06 10:48:41.248: D/BtGatt.GattService(1483): onClientRegistered() - UUID=6eaaf541-90fb-4e88-a0d5-1f267769128b, clientIf=5
11-06 10:48:41.248: D/BtGatt.GattService(1483): startScan() - queue=0
11-06 10:48:41.248: D/BtGatt.GattService(1483): startScan() - adding client=5
11-06 10:48:51.258: D/BtGatt.GattService(1483): stopScan() - queue=1
11-06 10:48:51.258: D/BtGatt.GattService(1483): stopScan() - queue empty; stopping scan
11-06 10:48:51.258: D/BtGatt.GattService(1483): unregisterClient() - clientIf=5
11-06 10:48:41.238: D/BluetoothAdapter(1365): startLeScan(): null
11-06 10:48:41.248: D/BluetoothAdapter(1365): onClientRegistered() - status=0 clientIf=5
11-06 10:48:51.258: D/BluetoothAdapter(1365): stopLeScan()
11-06 10:49:08.918: D/BluetoothAdapter(5023): startLeScan(): null
11-06 10:49:08.928: D/BluetoothAdapter(5023): onClientRegistered() - status=0 clientIf=5
11-06 10:49:10.038: D/BluetoothAdapter(5023): stopLeScan()
11-06 10:49:10.048: D/BluetoothAdapter(5023): startLeScan(): null
I notice that there are two apps on my Nexus 5, who print the same BluetoothAdapter log msgs. Does this matter? And the didEnterRegion/didExitRegion has never been called. What could the problem be?

Resources