
842 So.2d 605 (2002)
Ex parte Larry Darnell COLE.
(In re Larry Darnell Cole v. State of Alabama).
1010079.
Supreme Court of Alabama.
March 15, 2002.
*606 Glenn L. Davidson of Collins, Davidson, L.L.C., Mobile, for petitioner.
Bill Pryor, atty. gen., and E. Vincent Carroll, asst. atty. gen., for respondent.
LYONS, Justice.

I.
On November 14, 2000, Larry Darnell Cole was indicted for first-degree robbery and first-degree assault, violations of §§ 13A-8-41(a)(1) and 13A-6-20(a)(1), Ala. Code 1975, respectively. On January 24, 2001, Cole entered a plea of guilty to second-degree robbery and first-degree assault, violations of §§ 13A-8-42 and 13A-6-20(a)(1), Ala.Code 1975, respectively.
At Cole's guilty-plea proceedings, the prosecutor stated that the evidence showed the following:
"On his blind plea the state would expect to show [that] on April 28, 2000, around 12:00 noon, the defendant, Larry Darnell Cole, and another went to 1076 State Street here in Mobile County. At that location the victim, Latrayl Parker, who is sitting here in the courtroom today, and others were playing cards on the front porch. There was an amount of money out there during that card game. The defendant, Mr. Cole, arrived on the front porch, brandished a sawed-off shotgun and demanded the money from the players, from what was on the table as well as what was in their pockets. Right after that the defendant shot the victim, Mr. Parker, in the right leg. After shooting Mr. Parker in the leg, the defendant fled the scene with the money taken from the card game and the individuals."
The trial court accepted Cole's plea of guilty to second-degree robbery and first-degree assault. Because Cole was originally indicted for first-degree robbery, Cole's plea of guilty to the offense of second-degree robbery, in effect, "amended" his indictment to charge second-degree robbery. The court adjudged Cole guilty of second-degree robbery and first-degree assault. He was sentenced to 30 years in prison on each conviction, the sentences to be served concurrently.[1] Cole did not file any postjudgment motions. He appealed his convictions to the Court of Criminal Appeals. On August 24, 2001, the Court of Criminal Appeals affirmed Cole's convictions, in an unpublished memorandum. Cole v. State, (No. CR-00-1103) 837 So.2d 890 (Ala.Crim.App.2001) (table). We granted certiorari review to determine whether the Court of Criminal Appeals erred in holding that Cole had waived his claim that the trial court lacked jurisdiction to accept his plea of guilty to second-degree robbery. Cole did not seek certiorari review of his conviction for first-degree assault.

II.
Cole argues that the trial court did not have jurisdiction to accept his plea of *607 guilty to second-degree robbery because Cole had been indicted for first-degree robbery and the indictment, he argues, was improperly "amended" to charge second-degree robbery. According to Cole, second-degree robbery requires proof of an element not required for first-degree robberyi.e., the defendant must have been aided by another person actually present. See § 13A-8-42, Ala.Code 1975. The factual account of the robbery as provided by the prosecutor clearly indicated that Cole was accompanied by another person when the robbery occurred, but according to Cole, the trial judge made no determination whether the other person who was present actually aided or assisted in the robbery. Because the trial court failed to determine whether Cole was actually aided by another person during the commission of the robbery, Cole argues that the court was without jurisdiction to accept his plea of guilty to second-degree robbery. The Court of Criminal Appeals concluded that although Cole couched his argument in jurisdictional terms, he was actually challenging the factual basis underlying his guilty plea. Relying upon Teasley v. State, 704 So.2d 104 (Ala.Crim. App.1997), and Moore v. State, 668 So.2d 100 (Ala.Crim.App.1995), the Court of Criminal Appeals held that, because Cole did not challenge the factual basis for the guilty plea at the trial-court level, he had not preserved the issue for appellate review.
A guilty plea waives nonjurisdictional constitutional rights; however, a guilty plea does not waive a jurisdictional challenge. See Gordon v. Nagle, 647 So.2d 91, 94 (Ala.1994). See also Boykin v. Alabama, 395 U.S. 238, 89 S.Ct. 1709, 23 L.Ed.2d 274 (1969). A nonjurisdictional defect in the entry of a plea of guilty may be waived if the defendant failed to preserve the issue for appellate review. See Gordon v. Nagle, 647 So.2d at 93-94. Our recent opinions confirm that a defendant can waive irregularities or mere formalities in a court's obtaining jurisdiction over him. See Ex parte Lewis, 811 So.2d 485 (Ala.2001), and Ex parte Looney, 797 So.2d 427 (Ala.2001). "However, `"a formal accusation by indictment, or information, or complaint,"' made in the manner prescribed by law and `"supported by oath"' is a prerequisite to the trial court's jurisdiction `"and cannot be waived."'" Ex parte Looney, 797 So.2d at 429, quoting Ross v. State, 529 So.2d 1074, 1078 (Ala. Crim.App.1988) (quoting in turn Sherrod v. State, 14 Ala.App. 57, 59-60, 71 So. 76, 78, rev'd on other grounds, 197 Ala. 286, 72 So. 540 (1916)) (emphasis added).
A valid indictment or complaint, giving the accused notice of the criminal charge against him, is the source of the subject-matter jurisdiction to try a contested criminal case. Ash v. State, 843 So.2d 213 (Ala.2002); see also Ex parte Looney, 797 So.2d at 429; Batey v. State, 755 So.2d 593, 595 (Ala.Crim.App.1999). Absent a valid indictment or complaint, a trial court would lack subject-matter jurisdiction to try, to convict, or to sentence a defendant in a contested criminal case. See Ash v. State, supra; see also Batey v. State, supra. Rule 13.5(a), Ala. R.Crim. P., prohibits any amendment to an indictment that changes the offense or charges a new offense not contemplated in the original indictment. See also Rule 13.2(c), Ala. R.Crim. P. (specifying an offense in the indictment provides notice to the accused that he has been charged with all lesser offenses necessarily included in the charged offense). Rule 13.5(a), in conjunction with Rule 13.2(c), allows an indictment to be amended to charge a lesser offense included within the offense charged in the indictment because the accused is placed on sufficient notice of the charge against *608 which he must defend, and the accused is not being tried for an offense different from the charge intended by the grand jury. See Ash v. State, supra; Ex parte Washington, 571 So.2d 1062, 1063 (Ala. 1990); Woods v. State, 675 So.2d 47, 50 (Ala.Crim.App.1995); Gayden v. State, 38 Ala.App. 39, 42, 80 So.2d 495, 498 (1954).
Although there is no indication that the prosecutor actually moved the trial court to amend Cole's original indictment, cases dealing with entry of a guilty plea to an offense other than the offense charged in the indictment sometimes describe the process as "amending" the indictment. For example, in Fleming v. State, 814 So.2d 310 (Ala.Crim.App.2001), and Wingard v. State, 821 So.2d 240 (Ala.Crim. App.2001), reference to the amendment appears within quotation marks, indicating that no formal amendment has occurred but that the process is equivalent to amending the indictment. Regardless of whether by formal amendment or by implicit amendment, the entry of a plea to an offense different than the one charged in the indictment must not violate Rules 13.5(a) and 13.2(c), which, as previously noted, combine to permit only those amendments that charge a lesser-included offense. Furthermore, the defendant cannot consent to an amendment that effectively charges an offense not contemplated by the indictment. See Hugh Maddox, Alabama Rules of Criminal Procedure § 13.5 (3d ed.1999); see also Wingard v. State, supra; Murray v. State, 814 So.2d 1006 (Ala.Crim.App.2001); Green v. State, 619 So.2d 952, 953 (Ala.Crim.App.1993); Ross v. State, 529 So.2d 1074, 1077 (Ala. Crim.App.1988).
In this case, the trial court, after acknowledging that the indictment charged robbery in the first degree and assault in the first degree, stated, "It is my understanding that Mr. Cole will be entering a plea to robbery in the second degree and assault in the first degree." Later, the trial court addressed Cole as follows:
"THE COURT: You understand that the indictment in this case charges you with the crime of robbery in the first degree, which includes, I guess, robbery in the second degree and assault in the first degree. Has Mr. Yazdi [defense counsel] explained to you what the State of Alabama would have to prove in order to find you guilty of those charges?"
(Emphasis added.) Cole responded in the affirmative.
If at these guilty-plea proceedings, the indictment was "amended," the State was required to comply with Rules 13.5(a) and 13.2(c) and to confine its "amendment" to lesser offenses necessarily included within the offense of first-degree robbery. In this respect, a defendant charged with first-degree robbery by an indictment that describes the defendant's conduct as occurring in the presence of another aiding him could plead guilty to second-degree robbery as a lesser-included offense, because robbery in the second degree requires the use of force or the threatened use of force while the defendant is "aided by another person actually present." § 13A-8-42, Ala.Code 1975. Under those circumstances, where the original indictment charging first-degree robbery alleged the facts essential to the lesser-included offense of second-degree robbery, any insufficiency in the factual basis of a guilty plea to the lesser-included offense could not be subsequently attacked for lack of subject-matter jurisdiction.
The indictment by which Cole was charged alleged only facts describing a first-degree robbery in which he acted alone. The indictment read as follows:
"Larry Darnell Cole ... did in the course of committing a theft of property *609 to-wit: $200.00 in lawful United States Currency, the property of Latrayl Parker, use or threaten the imminent use of force against the person of Latrayl Parker, with intent to compel acquiescence to the taking of or escaping with the property, while the said Larry Cole was armed with a deadly weapon or dangerous instrument, to-wit: a sawed off shotgun, in violation of § 13A-8-41(a)(1) of the Code of Alabama."
When, as here, an indictment for first-degree robbery fails to set forth facts from which one might conclude that the defendant was aided in the robbery by another participantan essential element of the offense of second-degree robberythe insufficiency of the factual basis for a guilty plea to second-degree robbery may be subsequently attacked on the basis that the trial court lacked subject-matter jurisdiction to accept the plea. Had the trial court obtained Cole's consent to amend the indictment charging first-degree robbery by adding the fact that another participant was present, no new offense would have been charged because first-degree robbery is broad enough to include such an element. An indictment so amended, permitting a defendant to plead guilty to second-degree robbery, would not run afoul of Rule 13.5(a). That, however, did not occur here. To treat the proceedings in this case as if the original indictment included that additional fact just because Cole pleaded guilty would disregard the settled principle that one cannot consent to an improper amendment to an indictment. See Murray v. State, supra; Wingard v. State, supra; Green v. State, supra; and Ross v. State, supra.
Based upon the foregoing, we must reverse the judgment of the Court of Criminal Appeals as to Cole's conviction for second-degree robbery. Cole's conviction for first-degree assault, however, is unchallenged and therefore remains valid. Because the indictment charging him with first-degree robbery was improperly amended to charge second-degree robbery, Cole's original indictment charging first-degree robbery remains valid. The State may try Cole on this charge, or if the factual circumstances would support a conviction for another degree of robbery, the State may reindict Cole for the proper offense. See Williams v. State, 823 So.2d 1285 (Ala.Crim.App.2001); Pless v. State, 805 So.2d 778 (Ala.Crim.App.2001); Marks v. State, 791 So.2d 1062, 1064 (Ala.Crim. App.2000). A reindictment after a conviction that has been held to be void does not constitute double jeopardy because, if a court is without jurisdiction, there can be no valid conviction; hence there is no jeopardy. Dutton v. State, 807 So.2d 596 (Ala. Crim.App.2001), citing Cox v. State, 585 So.2d 182, 192 (Ala.Crim.App.1991). See also Cox v. State, 462 So.2d 1047, 1051 (Ala.Crim.App.1985). We remand the case to the Court of Criminal Appeals for the entry of an order or proceedings consistent with this opinion.
REVERSED AND REMANDED.
MOORE, C.J., and HOUSTON, SEE, JOHNSTONE, HARWOOD, WOODALL, and STUART, JJ., concur.
NOTES
[1]  Cole was sentenced as an habitual offender pursuant to the Habitual Felony Offender Act, § 13A-6-9, based upon two prior felony convictions.
