react-social-login

The easiest way to integrate Social Login in your React Apps ...Checkout NPM
Showing posts with label Troubleshooting. Show all posts
Showing posts with label Troubleshooting. Show all posts

Thursday, September 26, 2019

How to upgrade React Native to 0.60.5

Sunday, September 16, 2018

Fixing npm run android issues



fix NPM RUN ANDROID

This command could either delight you with your first react native app launching nicely on an emulator OR frustrate you. This article provides a fix for most common issues encountered while running this.

Remember: React-Native as on SEP 2018 needs JDK8 (It doesn't work on 9+)
This is a source for most of the issues.

Let's tackle all common issues one-by-one.

Error: JAVA_HOME isn't set

Common Issues

1. JAVA SDK not installed

Fix:
Install Java SDK if this is the case.

Q. How do I find if JAVA is installed or not?
= Open command prompt and run java -version
If you see JAVA isn't recognized OR JAVA jre 9.0 (or above), fix this first.

You may also have multiple JAVA versions installed.
If you're on windows, navigate to program files/Java folder and look for jdk 1.8.x (JAVA8) folder. If doesn't exist, download and install from here. (If you have JAVA 9, the folder would be jdk-9)

2. JAVA SDK is installed but JAVA_HOME variable not set

Fix:
open command prompt and execute SET JAVA_HOME = path_to_your_java8_bin_folder (see 1. above)

3. JAVA_HOME is set but includes /bin

You may have JAVA_HOME set. However, when you create a new project using creat-react-native-app it attempts to add bin to the current path. So, if you JAVA_HOME already has bin, it becomes bin/bin. Instead of correcting JAVA_HOME (as you don't know, what this would break), navigate to your project folder/android and open gradlew.bat in a notepad.
Find JAVA_HOME and remove bin from set JAVA_EXE=%JAVA_HOME%/bin/java.exe


Error: Could not find com.android.tools.build:gradle:3.0.x

Fix:
Open build.gradle add google() as a repository

Error: Error:Could not initialize class com.android.sdklib.repositoryv2.AndroidSdkHandler

Common Cause
Your JAVA is pointing to JAVA 9 or above.  Ideally, if you've been following this article, you'd have fixed this already. But incase you jumped here, Open Command Prompt and run JAVA - version to ensure thGo to properties of PC and select Environmental Variables options. Fix the path to point to JDK 8 instead of 9. Following screenshot shows it to be 9.. Fix the path to point to your Java8.
Close and Open Command Prompt again and continue npm run android



Warning: 'adb' is not recognized as an internal or external command

Open the command prompt and run adb. If you see command unrecognized error, you don't have adb. You might have it, but not in path. For this, add platform-tools folder to your environmental variables.
Q. Where is this folder?
Try to look into C:\Users\\AppData\Local\Android\Sdk. If it isn't there, install it from Android Studio ->Tools->SDK Manager-> SDK Tools TAB ->Check "Android SDK platform-tools" and install.



Wednesday, March 25, 2015

CryptographicException - Key not valid for use in specified state

Recently, I was caught with frustrating exception
"CryptographicException “Key not valid for use in specified state.” while attempting to generate pass using passbook generator using C#. The fix for me was to install the certificate NOT by installing the certificate by opening the cert installer but instead installing it from the MMC console.


Steps:
1. Open MMC
2. If you don't see certificates, in Files selectAdd remove snap In
2a. Select Certificate options and add it to right followed by your certificates needs
3. Once you have the certificate snap-in and opt for Import from context menu, locate your pfx or pk12 and complete wizard.

Ensure to select "Mark this key as exportable" in wizard step where you punch in password


Saturday, July 19, 2014

Setting Deployd and Nodejs for Apress professional angularjs

If you're reading Professional Angular Apress book (One of the best books I've read), for practical exercises you'd need to make some installations. Unfortunately, the book text is a little outdated as far as installation is considered. I'm just summarizing steps (that worked for me on Windows box).

1. Install NodeJS
This is simple. Download and install NodeJS from http://nodejs.org/

If you just want to test if Node is properly installed:
a. open command prompt
b. type node and enter
c. Type  following and enter
    function testNode() {return "Node is working"}; testNode();

If "Node is working" dispays, its working fine.

2. Using Nodejs as web server
Here you would run a little out of luck by following steps as are defined in book.
2.1. Install Connect NodeJs plugin
This is same as in book.
a. Open command prompt and navigate to folder where NodeJs is installed (in my case C:\Program Files\nodejs)
b. type npm install connect and enter

2.2 Install ServeStatic NodeJs plugin
Within the same folder as above in a , type npm install serve-static and enter

2.3 Server.js file
Instead of text in book, use following:

var connect = require('connect'),
    serveStatic = require('serve-static');
var app = connect();
app.use(serveStatic("../angularjs"));
app.listen(5000);

Note: If you want to specify a specific path, ensure to escape slashes. for example:
app.use(serveStatic("D:/\MyBooks/\Frontend/\angular/\angularJs"));


2.4 Validating
a. open command prompt and run node server.js
b. open browser and type http://localhost:5000/test.html

The above code assumes that you've created a folder "angularjs" at the same level as Nodejs (not inside NodeJs folder). If you've created it inside you'd need to remove ../ otherwise NodeJs will give error
Cannot Get /test.html. Also it assumes that there is a test.html file.

3. Installing Deployd
If you go to deployd.com and try to download installer (which is in Google Drive), you'd see following message:
Sorry, this file is infected with a virus
Only the owner is allowed to download infected files.

The file is actually not infected. To get deployd, you've 2 options:
a. Download the sourcecode of book from http://www.apress.com/9781430264484 which contains a copy of installer
b. Other way is to fool Google Drive by:
- From file menu, choose Move to Folder  and move it to your own G drive
- It will still show the owner as Jeffery Cross in your drive. Right Click the file name and select Make a copy  from context menu.
Now the file will be copied into your drive with your name in owner. You can download it then.

4. Creating Sportsstore
I'm not sure if MongoDb is a pre-requisite or deployd installer has all what's needed. But I was getting some error upon trying to run sportsstore for which :
a. I downloaded and installed MongoDb from www.mongodb.com
b. Give full access to yourself (everyone is even better) to the folder that will have sportsstore (if you're following book, thie would be the deployd folder created by yourself). I was getting
{error 'EACESS', syscall:listen} otherwise.

Finally, to launch create and launch your sportsstore
a. open command prompt and navigate to folder you created in 4.
b. run dpd create sportsstore
c. run cd sportsstore
d. run dpd

voila! Your page will open in browser.
You'are all set to try practical chapters.


Wednesday, April 9, 2014

Error 1061: The Service cannot accept control messages at this time

Recently, while debugging a windows service (written in C#), I left the code in debug mode for long in a catch block. Likely it caused some thread issue and my service got stuck in a suspended state. I opened services MMC (WinKey+R, type service.msc and enter) and tried to stop, restart the service. But in every attempt I got 1061 error.

Error 1061: The Service cannot accept control messages at this time.
I applied the master key to all fix - a Restart, but surprisingly that didn't fix the issue and I continued to get the error. Eventually, I did following and it resolved the issue. I was able re-install it again using installutil.exe.
P.S. I'm not sure of the impact of this fix, but it worked like a charm for me and something I'll always try to fix 1061.

Al Fix:
All I did was
1. Opened Registry Editor (Press Win+R, type regedit and press enter)
2. Open Find Window while selecting top node (Ctrl+F)
3. Check all checkboxed and search for the string matching your service name that appears in Services MMC
4. You'll likely find 2 search results - One contains service description while other represents service node
5. I deleted both the folders from the tree and restarted my machine
Voila! Service didn't appear in services anymore (Services.msc)

Since, I couldn't find this fix on NET, I thought to post it here to help a frustrated dev (like I was while fixing this problem)

Happy Coding!

Wednesday, August 14, 2013

SVC handlers missing in IIS on Windows8

A quick tip. I recently upgraded OS to windows 8 and installed both VS2010 and VS2012. Post that, my svc files stopped working in IIS and threw a 404 not found error. After a little struggle I found that .svc mappings were missing in IIS and the easy way to restore them is:
1. Open Control Panel
2. Select "Turn windows features on or off"
3. Expand.NET framework and check HttpActivation for WCF
and you're done!


Friday, June 7, 2013

Pending AJAX terminating on window.location.href issue

Consider following 2 lines executed together:
$.ajax('url',options)
window.location.href= 'some url';

Many browsers (Chrome for example) terminate Ajax request when they encounter redirect call.

Q. Why would I need ajax and redirect together?
A. There can be many reasons. Most important being tracking scripts which does analytic on page visits.

Q. Can't I solve that by making async as false for Ajax?
A. Definitely Yes!

$.ajax('url',{async:false}) 
would resolve the problem. But what if AJAX call is wrapped deep inside some third party plugin you're using where you've no control over ajax attributes? In this case you won't have the flexibility to apply async:false. To resolve this, you can make use of $.active property in JQuery. This property (damn useful) gives a count of number of open xmlHttpRequests on a page.

So, coming back to our problem, you can do following to ensure plugin's ajax executes before redirect:
SomPluginCalledHavingAjaxRequest()
var timer = SetInterval(function(){
    if($.active==0){
       clearInterval(timer);
       window.location.href= 'Some Url';
}
},1000);

Here, every 1000ms we're checking if there is any open ajax request. The moment ajax from third party plugin is through, $.active will get 0 and control will fall under condition where we stop the interval and do the redirect.

Monday, April 1, 2013

JQuery unrecognized expression in parsing MVC Partial

This is a quick tip sharing. Recently, I was stuck in a problem where I was making an AJAX call to get MVC partial as HTML in response.

Within this response, I made an attempt to find an element using $.find as following:


  
$.ajax({
   url: theURL,
   type: "POST",
   success: function (data) {
                 var controls = $(data).find('#someTextBox'); }
});
.find threw an exception:
Uncaught Error: Syntax error, unrecognized expression: <HTML response>
Issue was with enter keys and spaces in the response. Trimming data before calling find, resolved the issue.

var controls = $(data.trim()).find('#someTextBox');

Friday, January 4, 2013

svn issue cannot display: file marked as binary type

It is possible that you may face following issue while comparing different versions of a file - specially with .css and .js file as following:

CAUSE: It happens when SVN is not able to identify the mime-type for a file and sets it as application/octetstream


Monday, December 24, 2012

Fixing ASP.NET application for IE10 compatibility

We've a stable MVC web application. However, recently there was a sprung in issues (mostly JavaScript) breaking many of the existing features.
Recently, QA started to test application in IE10 browser after the analytic showing an increased traffic from it (Thanks to a lot of new Windows 8 devices). Where QA was quick enough to log defects one-after-the-another, we as a developer, were a bit panicked.

This post is all about fixing your application for IE 10. I'm in progress of fixing my application and will keep posting any new gimmick. (I appreciate if you could share your experiences too)

1st Fix (Master Stroke)

Issue: Application working in cookieless mode. I.e. Adding session to URL. For example:
upon login (Forms Authentication), http://mysite.com/welcome.aspx, it shows http://mysite.com/welcome.aspx(A(ikRoEoqwOieH_FyADedeEbit-_uDNadHNudahUar-HaUsU99DiasIadsjKAsjJiaojdJaJadijAQBR0))/Welcome.aspx


The first fix I did, was with minutest change but fixed more than 80% issues in one go. If you're using FormsAuthentication, you may find application running in CookieLess mode. I.e., when a user authenticates, there is a long dirty string that gets appended to brwoser for each request (as happened in our case)

FIX: You need to check for 2 things in web.config to ensure that your application doesn't switch to cookieless mode:

1. Add cookieless="UseCookies"  in your FormsAuthentication tag


 


2. Add cookieless="false" in Session Tag


2nd Fix: Forced to make application run in IE9 mode

There is a major issue (still unresolved) which forced me to apply a fix that forces IE10 to run in IE9 mode for my application.

ISSUE: JQuery $.Ajax POST request doesn't posts data which causes action methods to fail due to null arguments.


Searched a lot and found this issue raised by developers of different technologies - PHP, .NET etc. as it is a JQuery issue (http://bugs.jquery.com/ticket/12790)
Until this issue is resolved, I'm applying following hack:

    @if (HttpContext.Current.Request.UserAgent!=null && HttpContext.Current.Request.UserAgent.ToLower().Contains("msie 10"))
    {
    
    }
    else
    {
    
    }
   
This resolved all IE10 issues because it is now working IE9 mode when it is a IE10 browser.

Tuesday, November 13, 2012

Error while enabling windows feature NetFx3

Recently, I tried to install SQL 2012 express edition on a Windows 8 OS running inside VMware. Installation wizard is very much the same as SQL 2008, so I thought it's going to be pretty smooth. With several Next clicks, my installation process started. BUT :( it got aborted with following error:

The following error has occurred:
Error while enabling windows feature : NetFx3, Error Code : -2146498298.

Reason:
=========================================================
Installation process requires .NET framework 3.5, which is generally not installed along with windows. However, it is available in Turn Windows Features On/Off option. Most likely this will be unchecked if you are getting NetFx3 installation error.


You'd be tempted to quickly check and try install this component. It shows 2 options - Install from a disc or install from internet. If you try later option, it will fail (I don't know reason but you'd see a generic error message). Check following resolution for an alternative workaround (which worked for me like a charm)

Resolution:
=========================================================
Open Command Prompt in elevated permission mode and execute 
dism /online /enable-feature /featurename:NetFx3 /source:d:\sources\sxs

Following is a Step-by-Step Guide:


Saturday, October 13, 2012

Conditionally render MVC layout section

Error:

The following sections have been defined but have not been rendered for the layout page "~/_SiteLayout.cshtml"


Reason:
Let's say there is a Layout as following:

<html>
<head>
</head>
<body>
 @RenderBody() 
 @RenderSection("footer")
</body>
</html>

And a view as following:
<H1>Hello World</H1>
@section footer{ Copyright 2012 }
When rendered,
<h1>Hello World</h1> will be rendered by RenderBody() while Copyright 2012 will be rendered by RenderSection(). But, what if for some reason you want to display footer conditionally on Layout? So for that, if you do something like following, you will encounter an error:

<body>
 @RenderBody() 
 if(condition){
 @RenderSection("footer")
 }
</body>

Reason is that MVC needs to flush out section declared in your view. Else it displays error as on top of article. To resolve this, there is a quick trick:
<body>
 @RenderBody() 
 if(condition){
 @RenderSection("footer") //display
 }
 else
 {
 @RenderSection("footer").ToString().Remove(0) //hide
 }
</body>

Wednesday, January 18, 2012

Keyset does not exist issue in creating VS STS project


Error:
Keyset does not exist

When:
While creating Visual Studio ASP.NET STS Website (a project type for WIF)

Impacts:

Causes FederationMetadata.xml to be empty

Reaon(s):

STSTestCert certificate might be corrupt/lost or not accessible.

Resolution:

1. Click Start, type mmc in the Search programs and files box, and then press ENTER. 
2. On the File menu, click Add/Remove Snap-in. 
3. Under Available snap-ins, double-click Certificates. 
4. Select Computer account, and then click Next. 
5. Click Local computer, and then click Finish. Click OK. 
6. Under Console Root, Certificates (Local Computer), in the Personal store, click Certificates. 
7. Select STSTestCert certificate and right click
8. From context menu select All task > Manage Private Keys
9. Most likely, you would see "Object Not found" error. If so, delete this certificate and close console.

Note:

1. If you can not see STSTestCert, this post might not be useful to you OR alternatively, you can try steps 7-9 for all other certificates.
2. If you do not face error in Step 9., then ensure that certificate is accessible to user using Visual Studio

Monday, July 11, 2011

The following module was built either with optimizations enabled or without debug information Visual Studio

If you are facing this issue for long you must be on verge of banging your head or throw away your PC. There are many cause for this error. You might have tried options and may have missed a few. Following is a summary of different things that have helped me in resolving this issue (Hope it helps you out too):

1. In your Visual Studio, Go to Tools>Options>Debugging>General and check "Enable just my code as shown below"
2. If your application is configured to run using a IIS URL instead of dynamic localhost port, just ensure that IIS directory is pointing to your directory. Often while testing we make different copies of application and keep pointing application in IIS to one or the other. This actually resolved my issue.


3. Clean your solution, close VS, open again, rebuild application and try

4.Open properties of your project and ensure configuration as below:

5. Continuing from above, press advance button in Build settings below which opens a popup. Ensure, Debug Info is full as shown below



6. Delete old assemblies from GAC if you have added one to it.

Tuesday, May 24, 2011

Connect with 32bit DSN from 64bit .NET

Recently I ran into a trouble. I was using a specific database which supported only 32bit ODBC connections. However my machine was 64bit Win7. If I connected to my 32bit DSN from Excel, I could get the data but from Visual Studio I received error :" There is an architectural mismatch". The reason was that by default my .NET communicated with 64bit driver. To force it to use, I changed my project Platform target from "ANY CPU" to "x86".. and it worked!! :)

Friday, September 3, 2010

Accesssing TextBox value in Init Event

As per ASP.net Page Lifecycle, Events that actually wire up Server Controls and load their viewstate, take place, quite after Init. However, one thing to remember is that even in Init Request object is available.

Hence, if you are aware of textbox control then you can access it using Request["textBoxName"].

Ideally you would use HTMLcontrol instead of ASP.net server control Like:

<input type="text" id="myTextbox" value="<%=SomeValueFromServerSide%>">

This textbox then can easily be accessed in Init using
var textBoxValue = Request["myTextBox"]

Monday, April 26, 2010

Dropdown value when EnableViewstate = false

If EnableViewstate of a dropdown is set to false, you would need to bind the data at every post. Nothing new in this! But, you might face issues in retrieving value selected in dropdown before postback. It will always be ""

To get the value, pre-populate dropdown in Page_Init instead of Page_Load (if you are doing so). This will give the right selected value.