How to calculate the integral $$ \iint_{\mathbb{T}} K \, dA,$$ where $\mathbb{T}$ is the torus with $R$ being the distance from the center of the torus to the center of the tube and $r$ is the radius of the tube. $K$ is the Gaussian curvature of the torus, i.e. $$K=\frac{\cos \theta}{r(R+r \cos \theta)}.$$ I have used the same parametrization as on Wikipedia.
I got to the conclusion that $$dA=\sqrt{R^2+r^2+2rR \cos \theta}\, r \, d \theta \, d \phi$$ but then I get a very difficult integral which I can't solve.
How to do this in a better way?
Think of it as a $r$-$\theta$ region in $R^2$ equipped with a new metric, which gives it a curvature. In fact, you have already calculated the area element in this new metric, which is you $dA$. Oh! We are thinking of the polar coordinates $(r,\theta)$ as a local coordinate on the torus, which covers whole of it. Thus, integrating $K$, a function, over your manifold in this coordinate, is done by pulling back (or pushing forward?!) everything to the local coordinate and then calculating there. So,
$$\iint_{\mathbb{T}} K \, dA, = \iint_{r\theta \ region \ that \ gives \ torus} \frac{\cos \theta}{r(R+r \cos \theta)} \sqrt{R^2+r^2+2rR \cos \theta}\, r \, d \theta \, dr.$$
In fact, you want to show that this is zero.
If finding the region is hopeless, try $\theta$-$\phi$ coordinates, which wraps the square of sides $2\pi$ onto the torus. But then you need to find $dA$ anew. And also $K$ in this coordinate. But all of these are doable.
Warning: No relation between $r$, $\theta$, and $\phi$. They do not come from spherical coordinates in $R^3$.