A curated list of commonly faced issues and error messages and how to solve them. The list is specifically designed for Android Basics Course on Udacity as a part of Google Challenge India Scholarship, though most errors are general in nature and can occur while developing for any application.
Sometimes Android Studio is unable to generate R.java
file correctly. R.java
is a dynamically generated class, created during build process to dynamically identify all assets (from strings to android widgets to layouts), for usage in our java classes.
The most optimum solution is to Clean Build the Project and Sync again. Build > Clean Project would normally resolove this issue. Also check for the import statements and see if the package name is correct. If there is some modifications in directories and files you would do File > Invalidate Caches / Restart > Invalidate and Restart .
.kt
is for Kotlin file extension. This is not an error but if you are following the Android Basics Course code, it will generate errors. The Course follows Java programming language, instead of Kotlin. This appears when you check Include Kotlin
option in the begining of your Project Creation.
It is recommended that to close this project and create a new one. Refractoring MainActivity.kt
to MainActivity.java
might do the trick, but you need to change every Java file thereafter. Since Kotlin is 100% interoperable with Java, you can incorporate it seamlessly into your existing app. So if you are following this course, create a new project.
Gradle can be bit confusing for a new Android developer. Sometimes people make it synonymous to error.
tl;dr : Gradle is a system to build Android Applications.
Read on:- Gradle is a build system and is improvised form of other build systems. It is based on JVM. You must have seen build.gradle file(s) in your project. That is where you can write scripts to automate your tasks. The code you saw in these files is Groovy code. If you write System.out.println("Hello Gradle!"); then it will print on your console. Gradle doesn't correspond to errors. Read more at https://stackoverflow.com/questions/16754643/what-is-gradle-in-android-studio
4. Error:CreateProcess error=216, This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher
Install JDK 1.8. Then in Android Studio navigate to File-> Project Structure-> SDK Location, select your directory where the JDK is located.Click OK and you are good to go.