Calculating coefficient of friction 
Consider a body attached to a horizontal spring and resting on a surface, inclined at an angle $\theta$ from the ground.
The spring constant is $k$. Initially the spring was kept in its natural length while the body was held still by some external agent. When the external agent was removed, the body slid $x$ units down the inclined plane to achieve equilibrium.The coeffecient of (kinetic) frictional force acting on the body  is $\mu$

To solve this problem, I can use two methods:
1.Work-Energy Theorem: This yields 
$$0=mg(x\sin\theta)-\frac12kx^2-\mu (mgx\cos\theta)$$
2.Equating forces at equilibrium: This yields 
$$kx+\mu mg\cos\theta-mg\sin\theta=0$$(along the inclined plane)
On solving the equations the two methods give different answers, while they should give the same. Is there anything I am missing out here? Please help me solve this problem.
 A: @soumyadeep is on the right track, but wrong.
The object starts at rest. When the "external force" is removed, it starts to slide down the slope, picking up speed. When it reaches the point where the force of friction plus the force of the spring equal the force of gravity, it doesn't just stop - it stops accelerating.
Thus, to get equality you need to consider the net amount of energy that was available before the block reaches the extension $x$ - you will find that it's exactly the $\frac12 kx^2$ that you were missing. This is kinetic energy in the system at the time that the forces are in equilibrium.
Alternatively - if you wanted to make the block move very, very slowly, you would have to hold it back (compensate for the lack of force that the spring initially has) with a force that will change with displacement $x$ - the sum of this force and the force of the spring being always constant. If other words,
$$F_{ext} = k(L-x)$$
where $L$ is the full length where equilibrium occurs.
You can immediately see that the amount of work done by the block against this external force will be equal to the amount of energy stored in the spring at full extension ($x=L$)  by integrating:
$$\begin{align}U &= \int_0^L k(L-x)dx\\
&= kL^2 - \frac12 kL^2\\
&= \frac12 kL^2\\
\end{align}$$
so once again you find your missing factor $\frac12 k L^2$ in the energy equation.
