The teenager also denied abducting and raping the six-year-old, who had been holidaying on the Isle of Bute.
The boy, who cannot be named because he is under 18, told the High Court trial: "I have never met Alesha MacPhail."
The body of the schoolgirl, who died from significant pressure being applied to her face and neck, was discovered in a wooded area on 2 July last year.
Alesha, from Airdrie, North Lanarkshire, was only days into a summer break in Rothesay when she was killed.
At the High Court in Glasgow, the teenager has lodged a special defence claiming the crime was committed by 18-year-old Toni McLachlan, the girlfriend of the victim's father.
'Friends with benefits'
The accused claimed he had sex with Ms McLachlan, who then planted his DNA - from a used condom - at the scene.
In previous evidence, Ms McLachlan insisted she did not have sex with the accused and had nothing to do with Alesha's death.
The boy was called as the first witness for the defence after the prosecution closed its case.
The teenager said he had been having sex with Ms McLachlan "fairly frequently". He said that from October 2017 they were "friends with benefits" and were "meeting up, having sex, smoking joints".
This arrangement lasted most of the winter and stopped when he got back together with a former girlfriend, the court heard.
He said that early on 2 July, he and Ms McLachlan were messaging on Instagram, and he had asked her for cannabis. She said she had none, but asked if he wanted to meet for a cigarette.
The accused said they met in a shelter outside the home where she was staying with Mr MacPhail, Alesha and her grandparents, then went to a garage and had sex, before going their separate ways.
'Just speculating'
The teenager said that out of concern for Ms McLachlan, he had lied to his mother and the police about having had sex.
Defence QC Brian McConnachie asked the accused about a video he posted on social media that day which showed the top half of his body with the written message "found who done it".
He replied: "It was a video of my feet walking to the bathroom and the camera points up to the mirror and I pretend to get a fright and it says 'found who done it'."
Asked why he did that, he said: "People were talking about who might have done it and one of my friends said my name and I didn't want to take it to heart so I just thought I would build on it."
Mr McConnachie said: "You were making people know you were responsible."
The accused replied: "No, we didn't even know it was a murder at that time, we were just speculating."
Special defence
Questioned about messages he exchanged with a friend where he says he might "kill one day for the lifetime experience", he said these were "not serious".
The teenager has lodged a special defence of incrimination, blaming Ms McLachlan.
In her evidence at the trial, Ms McLachlan denied being responsible for Alesha's death, saying she "loved" Alesha.
She also denied suggestions by the defence that she had sex with the accused on 2 July, then planted his semen on Alesha, before "attacking and brutalising her" and murdering her.
The trial, before judge Lord Matthews, continues.
What the trial has heard so far
- DNA found on Alesha 'matched accused'
- Alesha trial told of DNA Google search
- Alesha accused had 'fantasy' killing chat
- Alesha, six, had 'catastrophic' injuries
- Woman denies killing six-year-old Alesha
- Alesha's father 'sold cannabis to accused'
- Boy accused of Alesha murder blames woman
Why is the BBC not naming the accused?
It is illegal in Scotland to publish the name, address, school or any other information which could identify anyone under the age of 18 who is the accused, victim or witness in a criminal case
This law applies to social media as well as to websites, newspapers and TV and radio programmes.
However, the name of victims who have died can be published - so the BBC and other outlets are able to identify Alesha MacPhail.
How can an accused blame someone else for the crime?
Ahead of their trial, the accused can lodge a special defence such as self-defence (they were defending themselves from attack), alibi (they were somewhere else when the crime was committed) and mental disorder (the accused is not responsible for their actions because they were suffering from a psychiatric condition).
In this case, the accused has lodged a special defence of incrimination, which means he has claimed that someone else (Toni McLachlan) was responsible.
However, the Crown must still prove the guilt of the accused beyond reasonable doubt. There is no onus on the accused to prove their special defence is true, and he or she can still be acquitted even if the jury does not believe their special defence.