I have faced two errors while Build my project on Android Studio:
License for package Android SDK Platform 28 not accepted. (while Build my project in Android Studio 4.1)
exception in thread main java.lang.noclassdeffounderror javax/xml/bind/annotation/xmlschema (while running SDK manager to accept license)
For me, it was a java version problem. I have installed JDK instead of java. TO SOLVE THE ISSUE, I did the following steps.
For Windows:
Step1: Download and install the latest JAVA version from https://www.java.com/en/download/
Step2: Search for "View advanced system settings" in the start menu button (windows icon)
Step3: Click on "Environment Variables"
Step4: under "System variables" click on "New", now set "Variable name: JAVA_HOME
" and "Variable value: C:\Program Files\Java\jre1.8.0_271
" (add latest installed java path here). Then "OK", "OK", and "OK".
Step5: open cmd as an administrator and type the following commands:
cd C:\Users\kevin\AppData\Local\Android\Sdk\tools\bin
(*change username here)
sdkmanager --licenses
Press "y" for all questions.
Step6: Restart your Android Studio again.
DONE.
Let me know if anyone having a problem while following the above steps.