‘Xamarin.Android.Support.Design 25.3.1’ is not compatible with ‘Xamarin.Forms 2.3.4.231 constraint: Xamarin.Android.Support.Design (= 23.3.0)’. – How to fix it ?

Why ?

When I was trying to update the NuGet Packages for one of my Xamarin projects, I got an error saying “Unable to resolve dependencies.” and the packages wasn’t updated.

The detailed error message is …

Unable to resolve dependencies. ‘Xamarin.Android.Support.Design 25.3.1’ is not compatible with ‘Xamarin.Forms 2.3.4.231 constraint: Xamarin.Android.Support.Design (= 23.3.0)’.

1 error

Image 1 : Error

The reason for the error was…

The Android project of my Xamarin solution has been configured to Compile using Android 6.0(Marshmallow) API 23.3.0 . But I was trying to update the Android packages for Android 7.1 (Nougat) API 25.3.1.

3 current versions

Image 2 : Current Android application properties(Compile using Android 6.0)

So the target compilation version is not compatible with the updating version of Android packages.

How To Fix the Error ?

To fix the error we have to change the target framework for compile to “Android 7.1(Nougat)”.

Here are Steps to change the target compile framework..

2. go to properties

Image 3 : Right Click on Android Project -> Properties

3 current versions

Image 4 : Current Android application properties(Compile using Android 6.0)

4 select api nouget

Image 5 : Change Compile Android Version to Android 7.1 (Nougat)

When Change the target compilation version of Android , Visual Studio will ask you to restart the project to configure itself…

5 restart project

Image 6 : “Yes” to close and reopen

6 lading

Image 7 : App is loading

7 go to nuget

Image 8 : Again go to NuGet package manager to update Android packages

8 download

Image 9 : Select Android Packages v.25.3.1(or the package showing here)

9 accept

Image 10 : Accept to Agree licence and tearms

9 conform update

Image 11 : You can see changes will be happening (the old packages and new packages). Click OK.

10. installing packages

Image 12 : Then the packages will be downloaded and Install Successfully.

Then Re-Build the project and the app will run successfully…

Thanks !

Xamarin Lesson 2 : Create a Cross-Platform Mobile Project in Visual Studio 2017

Video

This video demonstrates, How to create cross-platform mobile app Including Android/iOS/Windows Phone Native apps and a Portable Class Library(PCL) in Visual Studio 2017

Thanks !

Failed to create directory C:\Program Files(x86)\Android\Android-sdk\temp – How to fix it ?

Objective :

When Trying to install new packages/updates using Android SDK Manager, We can see some errors that “Unable to Install”. So Here are some errors I got when I got when I was trying to Install android API(s) and other package by Right Click and Run the app(Normal way).

Failed to create directory C:\Program Files(x86)\Android\Android-sdk\temp

4 error faild to create directory - Copy

Error 1

URL not found: C:\Program Files (x86)\Android\android-sdk\temp\platform-tools_r25.0.5-windows.zip (Access is denied)

1 error

Error 2

How to Fix it ?

To Fix the error and Install the packages, what we have to do is Run the Android SDK Manager as Administrator..

First, go to C:\Program Files (x86)\Android\android-sdk and select SDK Manager.exe. 

Then Right Click and Run As Administrator.

5 run as administrator

Image 1 : Run as Administrator

6 loading packages

Image 2 : Loading packages

1 install ready

Image 3 : Select Packages to Install/Update

2 click install

Image 4 : Selected Packages

3 select and click install

Image 5 : Accept one by one to Install (Accept radio Button)

3 install sdk s

Image 6 : Accept all selected packages to install using “Accept Licence” radio Button

7 downloading

Image 7 : Downloading

8 finished downloading

Image 8 : Downloaded Successfully

Important

Instead of Running as Administrator by going to Program Files, You can Open Android SDK manager using Visual Studio.

It will run the Android SDK Manager as Administrator itself.

Click the …  Tools -> Android -> Android SDK Manager

9. open in vs

Image 9 : Run SDK Manager using VS as Administrator

Thanks !

Xamarin Lesson 1 – Install Xamarin with VS 2017

Video

This Video show you how to download and install Visual Studio for the development of Cross-platform mobile apps.

Please Follow the video.. To Download and Install Visual Studio 2017…

SQL Server blocked access to procedure ‘sys.xp_cmdshell’ of component ‘xp_cmdshell’ because this component is turned off as part of the security configuration for this server – How To Fix It ?

Objective

When I was trying to execute an  .exe file in my PC using xp_cmdshell command, I got an error which says the sys.xp_cmdshell component is turned off.

Ans Here is the error message…

SQL Server blocked access to procedure ‘sys.xp_cmdshell’ of component ‘xp_cmdshell’ because this component is turned off as part of the security configuration for this server.
A system administrator can enable the use of ‘xp_cmdshell’ by using sp_configure.

1 error

1 : Error messgge

Reason

By Default, xp_cmdshell is Disabled in SQL Server. So We have to enable it to use the feature.

What is xp_cmdshell  ?

Spawns a Windows command shell and passes in a string for execution. Any output is returned as rows of text.

In another way xp_cmdshell is a alternative of DOS prompt for SQL Server.

To Learn more use below link…

Reference : docs.microsoft.com

How to Fix the issue ?

Then what I did is Enable the xp_cmdshell  using SQL Server configure option.

Here are Steps to do it…

2 show advanced options

2 : Step 1 – Run  SP_Configure ‘Show advanced options’

3 re configure

3. Step 2 – Run RECONFIGURE

4 enable cmd shell

4. Step 3 – Run CONFIGURE ‘xp_cmdshell’ to Enable

In here you have top add “1” if you want to Enable the Feature. If you want to Disable the feature, then add “0”.

4 re configure again

5. Step 4 – Again Run RECONFIGURE

5 OK

6. Step 5 : Then Run the quarry you want to execute

Then the quarry will run properly.


-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1;
GO
-- To update the currently configured value for advanced options.
RECONFIGURE;
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1;
GO
-- To update the currently configured value for this feature.
RECONFIGURE;
GO

Thanks !

References :

https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/xp-cmdshell-transact-sql

https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/xp-cmdshell-server-configuration-option

How to Check the App is running for the First time – in Xamarin Forms (Android/iOS/Windows)

Objective

In one of my Xamarin Forms apps, I wanted to check is the app running for the first time after the installation or the app is already installed and according to that Load different pages in the app

 How to Install Xamarin in Visual Studio 2017…

Furthermore,

  1. If the App is running for the first time, I wanted to a Quick Start Guide to the user.
  2. If all has already installed, app will show the Login Form.

pags

Then I looked for a solution and James Montemagno‘s  SettingsPlugin gave me the solution…

If you want to learn more, Click above links to go to GitHub and  MotzCod.es.

How I did it ?

First I went through the Instruction of the above references and I installed the plugin using NuGet..

Here I’ll explain how I did it.. and Here is my project at the beginning.

1-project

1. First Install the Settings Plugin using NuGet packages.. Search  “Xam.Plugins.Settings”

2-download-settings

2. Apply The package to all projects or selected projects.. (But I’m managing the settings from the PCL project) and Install the package..

3-select-all-projects

3. Then Conform the installation..

4-conform-installa-tion

4. When the packages has installed, It will generate a folder which is “Helpers” and a class onside it “Settings.cs” to manage settings.

It will added to all selected projects.

5-helpers-settings

The default Settings class includes below C# code to manage settings..


using Plugin.Settings;
using Plugin.Settings.Abstractions;

namespace FirstTimeUse.Droid.Helpers
{
///
<summary>
/// This is the Settings static class that can be used in your Core solution or in any
/// of your client applications. All settings are laid out the same exact way with getters
/// and setters.
/// </summary>

public static class Settings
{
private static ISettings AppSettings
{
get
{
return CrossSettings.Current;
}
}

#region Setting Constants

private const string SettingsKey = "settings_key";
private static readonly string SettingsDefault = string.Empty;

#endregion
public static string GeneralSettings
{
get
{
return AppSettings.GetValueOrDefault<string>(SettingsKey, SettingsDefault);
}
set
{
AppSettings.AddOrUpdateValue<string>(SettingsKey, value);
}
}

}
}

To read the more about the Settings class go to:  https://github.com/jamesmontemagno/SettingsPlugin

I’m going to store my value in the SettingsKey property. So I’ll change the default value of the SettingsKey property to “yes”. Which means the app is running for the first time.

6-change-settings-key


private static readonly string SettingsDefault = "yes";

5. Now I’m going to use the Settings in the application..

I’m checking the app status in the App.xaml.cs class. Because the app navigating to the Main page happens in the constructor in App.xaml.cs class.

The default code of the App class is… And there are not properties in this class…


public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new MainPage();
}

protected override void OnStart()
{
// Handle when your app starts
}

protected override void OnSleep()
{
// Handle when your app sleeps
}

protected override void OnResume()
{
// Handle when your app resumes
}
}

Now I’ll add a Property to App class to Manage App Settings. The property name is “IsFirstTime” and type is String.

7-add-isfirsttime


///
<summary>
/// Get and Set value to General settings
/// </summary>

public string IsFirstTime
{
get { return Settings.GeneralSettings; }
set
{
if (Settings.GeneralSettings == value)
return;
Settings.GeneralSettings = value;
OnPropertyChanged();
}
}

6. Now I’ll add another page to use for log in to system if the app has already installed.

Page name is “LoginPage.xaml”.

8-added-2-pages

7. Now Lets Write code in App.xaml.cs to check the app status…

The page is initialize in the constructor of the App class. So I’m going to check the status of the app inside of the constructor.

And Here is the code. In the Settings class, I have set the default value as “yes“. So the app runs for the first time, the value should be “yes“. Then  the MainPage page will open. And when the app ran for the first time, it  sets the “IsFirstTime value to “no“.

Then when the user run the app after the first time, it will load the second page which is Logging Page.

9-check-first-time


public App()
{
InitializeComponent();

// Check is the app running for the first time
if (IsFirstTime == "yes")
{
// if this is the first time, set it to "No" and load the
// Main Page ,which will show at the first time use
IsFirstTime = "no";
MainPage = new FirstTimeUse.MainPage();
}
else
{
// If this is not the first time,
// Go to the login page
MainPage = new FirstTimeUse.LoginPage();
}
}

8. The Build and run the app using emulator. I’m using my Samsung Galaxy J7 as the emulator. And the App was run  successfully.

screenshot_20170219-173522

First time it will open the Main Page

screenshot_20170219-173745

And When I run the app after the first time, It loads the Login page..

 

References…

https://github.com/jamesmontemagno/SettingsPlugin

https://components.xamarin.com/gettingstarted/settingsplugin

 

Thanks !

How to Fix Error “C:\Program Files (Access is Denied)” When Proguard has Enabled while Build a Android app

Why ?

When I was trying to build one of my android apps in “Release” mode to deploy, I got and Error that  “C:\Program Files (Access is Denied)” and the File was “PROGUARD”.

2-errror

Then I looked for a solution to avoid the error.

What is Proguard ?

The Reason For The Error

In the Android project, I have set the Proguard Enabled before I build the app.

The reason for the error is there is a space in the path to the PROGUARD. Proguard is in the Android folder in Program Files (x86) and there is a spaces between “Program Files (x86)”.

C:\Program Files (x86)\Android\android-sdk\tools\proguard

0-program-file-spaces

So PROGUARD may unable to find the path..

So How to Fix This ?

What we have to do is Place the android-sdk folder to a path without spaces..

To do that I created a symbolic Link(sym-link) ..

Here are steps to create a symbolic link..

1 .First we have to download and Install the  Link Shell Extension.

To Download the Link Shell Extension , Click Here .. 

2. After Installed the Extension then we are ready to create the sym-link.

How To Create a Symbolic Link, Click Here…

Here are steps How I created according to my Folder structure..

First I create a Folder in C: drive outside of Program Files x86 which is “AndroidSysLink”. So we have to Link the Android-SDK path to this folder.

First Go to Program Files x86 and Right Click on Android Folder and we can see a new context menu “Pick Link Source”. Then Click it..

1-pick

Then Go back and Select “AndroidSysLink” Folder -> Right Click . Then We can see a new context menu “Drop As” . When we click on it and we will see few options in another context menu. Then Select “Junction”. And then The link will be created.

2-drop-symbolic-link

3. Then We have to change the Android SDK path in Visual Studio.

So go to Tools -> Options -> Xamarin and Click the “change” button inside of the Android SDK location…

Then we can see a dialogue to select the sdk path..

3-existing-sdk-path

4. Go to the Linked folder and copy the path in it..

4-select-new-path

5. Paste the Path in the sdk-path selection dialogue box.

5-new-sdk-path

Then Click OK…

6. Now The Path has changed an Click OK to conform the new SDK path..

6-new-sdk-path

7. Now we are ready to release the app. But before Build the app recheck the configuration in properties.

First Verify Target Android versions..

0-selectandroid-versions

Make Sure the Confutation has set to “Release” and Proguard is Enabled..

1-enable-proguard

8. Then Build The app in Release Mode..

The app will build successfully..

3-build-success

9. Now we are ready to Archive the Android App.

Right Click on the Android project and click “Archive“…

4-archieve

We can see Archiving Progress…

5-archieving

We can see a Settings I con with a Green icon when the app has archived successfully and in the bottom of the dialogue we can see build information.

6-archieved-successfully

Click the “Open” folder and the created .apk file will see in that folder.

7-open-the-path

References…

https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/publishing_an_application/part_1_-_preparing_an_application_for_release/

https://developer.xamarin.com/guides/android/application_fundamentals/cpu_architectures/

https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/proguard/

https://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/

http://schinagl.priv.at/nt/hardlinkshellext/linkshellextension.html

https://forums.xamarin.com/discussion/45210/enable-proguard-error-c-program-files-access-is-denied

Thanks !