Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while creating new Activity

Tags:

java

android

I am trying to create a new Activity, but the following error comes up (bottom of image)

InvalidReferenceException: Error executing FreeMarker template...

If I manually create an Activity by creating a Java Class which extends the Activity Class, then it works.

enter image description here

like image 626
Maroof Avatar asked Mar 22 '17 08:03

Maroof


2 Answers

From the following link : Cannot create empty activity, in Android Studio 2.2.3 , some people had the same kind of problem :

ERROR - llij.ide.plugins.PluginManager - com.android.tools.idea.templates.FreemarkerUtils$TemplateProcessingException: freemarker.core.InvalidReferenceException: The following has evaluated to null or missing: ==> manifestDir [in template "root://activities/common/common_globals.xml.ftl" at line 26, column 39]

The problem was related to a tmp folder created on the C drive

When I first installed Android SDK, I installed it to the C drive and did some exercises inside ud851-Exercises-student there. Then, because I ran out of space on the C drive, I uninstalled it from C and installed it to D. Maybe I accidentally opened one of those projects and that cause the Android Studio to create the tmp folder in C.

Deleting the C:\tmp folder solved the problem

I was having the same issue...deleting tmp folder helped.

Some more information about the root cause :

I realized this issue is because of the "buildDir" path in build.gradle file in Udacity projects. See screen shot.

enter image description here

like image 183
Arnaud Avatar answered Oct 13 '22 01:10

Arnaud


1) Comment out the following code in gradle file (build.gradle)

buildDir = "C:/tmp/${rootProject.name}/${project.name}" ---comment this line

2) Use Sync Now at the top of the page to sync the project 3) Add the new Empty Activity (Child Activity) 4) Uncomment the lines you commented out in the gradle file 5) Sync the project again

like image 33
Akash Gupta Avatar answered Oct 13 '22 01:10

Akash Gupta