I keep getting an IllegalStateException error in the event log while creating new activity
in android studio:
11:27:15 InvalidReferenceException: Error executing FreeMarker template: The following has evaluated to null or missing:
==> srcDir [in template "root://activities/common/common_globals.xml.ftl" at line 41, column 34]
Tip: If the failing expression is known to be legally null/missing, either specify a default value with myOptionalVar!myDefault, or use when-presentwhen-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)??
I have been faced that, after I setup my android environment.I already set up and configured everything, but this still occur.After searching a few mins, I found the problem in Logcat,
Then, I know project is missing Build Tool version. You have to give which build tool version you will use to run for project. Go to >> Project Structure , ( Cmd + ; ) in mac. Choose
Compile Sdk Version
andBuild Tools Version
, After the gradle build, creating new activity from menu error has been fixed. I hope this will help for you.Notes : Some of the projects from Github or bitbucket also missing Build Tools version when you cloned and run the project. These are the same errors and this approach can help to solve for them.
I've encountered the same problem and trying the following steps were working for me:
I have the same exact problem when trying to create a new activity. IDE Fatal Errors
I was running Android Studio 3.2.1 on Windows 7 Professional. I did not have this problem until I started to switch loading project from different drives - I used to run my projects from F: drive and when I downloaded sample code to C: drive, creating new activities started to give this IDE fatal error.
Got a clue from online sources of a potential issue caused by
buildDir
path inbuild.gradle(Project:)
shown below;Since my project working directory is in F: drive, I changed the above C: drive to F:
With this simple change, I can now create new Activity.
If nothing else works for you I suggest you try this solution.
removing the build folder redirect code in the gradle file is a workaround.
Found it here https://github.com/udacity/ud851-Exercises/issues/67
I had the same issue. Visit this Link. https://code.google.com/p/android/issues/detail?id=232076
this happens if you have your project in a different drive other then C: android studio will automatically create a copy of your project (i hope they are cache files) in the C: drive's tmp folder. this folder is the cause for this issue.
try File-> Invalidate Caches/Restart. or just deleted the tmp folder in the c: drive and restart everything and it will work fine.
Comment the code in build.gradle which creates folders in tmp directory and then create the Activity.
After successful creation of activity ,revert back the commented code in build.gradle (Co)
}