Is *every* autonomous first-order planar/2D system integrable? Consider a general autonomous first-order planar/2D system:
$$\begin{cases}
\frac{dx}{dt} = A(x,y)\\
\\
\frac{dy}{dt} = B(x,y),
\end{cases}$$
where $A,B$ are two functions. Reading Classical Mechanics by Joseph L. McCauley I found the following statements:

Every two dimensional flow, $$dx/dt = A(x,y), \qquad dy/dt = B(x,y),$$ whether dissipative or conservative, has a conservation law,

and, if we rewrite the system equations as $dt=dx/A=dy/B$,

every differential form $B(x,y)dx-A(x,y)dy=0$ in two variables either is closed or else has an integrating factor $M(x,y)$ that makes it integrable.

So is really every planar system integrable, or have I missed some detail?
 A: A global integrability statement for general autonomous 2D systems does not hold, but a local integrability statement is true. Let us reformulate OP question as follows.

Suppose that we are given an autonomous two-dimensional first-order problem
$$ \dot{x}~=~f(x,y), \qquad   \dot{y}~=~g(x,y), \tag{1}$$
where $f$ and $g$ are two given smooth functions. Is eq. (1) a Hamiltonian system
$$  \dot{x}~=~\{x,H\}, \qquad   \dot{y}~=~\{y,H\}, \tag{2}$$
with a symplectic structure $\{\cdot,\cdot\}$ and Hamiltonian $H(x,y)$?

The answer is, perhaps surprisingly: Yes, always, at least locally.
The Hamiltonian $H$ is the sought-for integral of motion/first integral.

*

*Proof: In two dimensions, a Poisson bracket is completely specified by the fundamental Poisson bracket relations
$$ \{x,y\} ~=~B(x,y)~=~-\{y,x\}, \qquad \{x,x\}~=~0~=~\{y,y\}, \tag{3} $$
where $B$ is some function that doesn't take the value zero. [Exercise: Check that eqs. (3) automatically satisfy the Jacobi identity.] The Hamilton's eqs. (2) become
$$  \dot{x}~=~B\frac{\partial H}{\partial y}, \qquad   \dot{y}~=~-B\frac{\partial H}{\partial x}.\tag{4} $$
Next consider the one-form
$$ \eta ~:=~ f{\rm d}y -g{\rm d}x, \tag{5}$$
which is possibly an inexact differential. However, it is known from the theory of PDE's, that there locally exists an integrating factor $\frac{1}{B}$, so that the one-form
$$ \frac{1}{B}\eta~=~{\rm d}H \tag{6} $$
is locally an exact differential given by some function $H$. It is straightforward to check that one can use $B$ as the Poisson structure (3) and $H$ as the Hamiltonian. $\Box$


*Remark. The existence of a pair of canonical variables $q(x,y)$ and $p(x,y)$, with $\{q,p\}=1$, are, in turn, guaranteed locally by Darboux' Theorem.


*Example: If $f$ and $g$ are homogeneous functions of same order, and if one chooses
$$ B~=~ y f - x g, \tag{7}$$
then one may check that the one-form $\frac{1}{B}\eta$ is closed. A Hamiltonian $H$ can hence be found via contour integration of the one-form (6).


*Example: 1D damped oscillator: Eqs. of motion:
$$ \dot{v}~=~-2bv-\omega^2x, \qquad \dot{x}~=~v. \tag{8}$$
Poisson bracket:
$$ B(x,v) ~=~ v^2 + 2 b v x + \omega^2 x^2. \tag{9}$$
Hamiltonian:
$$\begin{align} H(x,v)~=~&\frac{1}{2}\ln|B(x,v)|\cr
~+~&\left\{\begin{array}{ccr} 
\frac{b}{\sqrt{\omega^2-b^2}}\arctan\frac{\sqrt{\omega^2-b^2} x}{v + b x}&\text{if underdamped}& |b|~<~ \omega,\cr\cr 
\frac{bx}{v + b x}&\text{if critically damped}& |b|~=~ \omega,\cr\cr 
\frac{b}{\sqrt{b^2-\omega^2}}\left\{\begin{array}{c}{\rm artanh}\cr{\rm arcoth}\end{array}\right\}\frac{\sqrt{b^2-\omega^2} x}{v + b x}&\text{if overdamped}& |b|~>~ \omega.\cr 
\end{array}  \right.\tag{10} \end{align}$$


*Example: Math.SE q1577274.


*Counterexample. Solutions to diff. eqs. exist in general only locally. Consider
$$f(q,p)~=~\frac{q}{q^2+p^2}\quad\text{and}\quad g(q,p)~=~\frac{p}{q^2+p^2}\tag{11}$$
in the domain $D=\mathbb{R}^2\backslash\{(0,0)\},$ which is not contractible. It is relatively straightforward to check that
$$\eta~=~f\mathrm{d}p-g\mathrm{d}q ~=~\frac{q\mathrm{d}p-p\mathrm{d}q}{q^2+p^2} \tag{12}$$
is a closed $1$-form, and there doesn't exist a globally defined Hamiltonian $H$ on $D$ such that eqs. (2) are satisfied. The best one can do is to put $H$ equal to a single-valued branch of ${\rm arg}(q+ip)$, which is not globally defined.


*Counterexample: Contractible domain without global solution: Math.SE q2710698.
