I am not a developer, so don’t beat me if this is stupid. I solved the problem in this way:
1. Locate this line in your template.php file:
<?php echo $amp_post->get_content(); ?>
This is the code to produce the content, as I assume…
2. Add the following code directly above this line to get an adsense ad directly above the content:
<div class="ad-container">
<amp-ad width="auto" height="250"
type="adsense"
data-ad-client="ca-pub-xxxxxxxxxxxxxxx"
data-ad-slot="xxxxxxxxxxxxxx">
</amp-ad>
</div>
Replace the xxxxxxxxxx with your own ID’s. You will find them if you create a new ad in adsense.
You could add the same code below the content generation line and you can change width and height according to your needs.
Here is an example: https://amazingtemples.com/location/america/mexico/yucatan-getting-around/amp/
Would be interested to hear the opinion of developers about this solution…