Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot create new activity in android studio

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)??
like image 325
brain pinky Avatar asked Nov 19 '16 09:11

brain pinky


People also ask

What are Android studio activities?

An activity provides the window in which the app draws its UI. This window typically fills the screen, but may be smaller than the screen and float on top of other windows. Generally, one activity implements one screen in an app.

How can I run a particular activity in Android Studio?

Go to "Edit Configurations..." in the "Run" menu. In the left pane, select your application. In the right pane, in the "General" tab, in the "Launch Options" section, there is a "Launch:" dropdown. Select "Specified Activity", and enter the name of your activity as it appears in your Manifest.


2 Answers

Method 1:Just Remove the following code from your app level build.gradle

debug {
            storeFile file('/Users/Razz/Documents/keys/keystore.jks')
            storePassword 'ABC@123'
            keyAlias 'key0'
            keyPassword 'ABC@123'
      }



Method 2: In case, if there are two packages together (kotlin and java)

I was facing the same problem as whenever I create new activity form the activity templates provided by the android studio. Nothing was happening even after Gradle sync completes successfull.

After a long item, I figure out that, java directory name inside my project changed into kotlin somehow. And I supposed Android Studio looking for the java package to create new Activity.

Then, to solve this issue, I follow the below steps:

  1. Closed Android Studio
  2. Went to the project location up to java directory as ../ProjectName/app/src/main/
  3. In this main directory, I had the kotlin directory instead of java.
    So, I just renamed it to java.
  4. Then opened the project with Android Studio, and that's all.
  5. I created new activity it easily created one as it works before.
like image 56
Razz Avatar answered Oct 05 '22 02:10

Razz


I experienced to same issue 2 day ago and i solve it by update the below text. Check to gradle.build app and module to newer versions.

classpath 'com.google.gms:google-services:4.3.4'
like image 35
Yakup şeker Avatar answered Oct 05 '22 01:10

Yakup şeker