Difference between revisions of "CISC181 S2019 NewPlainJavaInAndroidStudio"

From class_wiki
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
This is necessary for JUnit testing to work smoothly  
+
This is necessary for the JUnit unit testing framework to work smoothly.  Basically, don't make a java module as the other instructions say.  The [http://nameless.cis.udel.edu/class_wiki/index.php/CISC181_S2019_NewAndroidStudioProject first few steps for making a new project] are unchanged.
  
 
# Open your Android project in Android Studio. If you do not have one, create one.
 
# Open your Android project in Android Studio. If you do not have one, create one.
Line 18: Line 18:
  
 
Now if you click '''Run''' (or use Shift+F10 keyboard shortcut), this should compile and run your app module.  If it does not happen quickly (the first time may be quite slow), there is a progress bar at the bottom of the window.  If you get an error the first time, try again.
 
Now if you click '''Run''' (or use Shift+F10 keyboard shortcut), this should compile and run your app module.  If it does not happen quickly (the first time may be quite slow), there is a progress bar at the bottom of the window.  If you get an error the first time, try again.
 +
 +
See [https://developer.android.com/training/testing/unit-testing/local-unit-tests here] for directions on running your unit tests
  
 
You can tweak your editor's look and feel at '''File > Settings > Editor'''
 
You can tweak your editor's look and feel at '''File > Settings > Editor'''

Latest revision as of 10:01, 17 April 2019

This is necessary for the JUnit unit testing framework to work smoothly. Basically, don't make a java module as the other instructions say. The first few steps for making a new project are unchanged.

  1. Open your Android project in Android Studio. If you do not have one, create one.
  2. On the far left there should be a "project view" pane. If not, click sideways (vertical) tab that says "1: Project" or type "Alt+1" (hold down Alt key and press 1)
  3. Open the "app/java" module folder. There should be 3 subdirectories starting with your package name ("cisc181.mylabN" or similar). The second and third should have "(androidTest)" and "(test)" after the package name.
  4. Right-click the first directory and choose New > Java Class. Fill in the name of your top level class if you have a main(), or whatever utility class you are developing (such as "Fraction"), and click "OK".
  5. In the project pane, double-click on the package subdirectory and then "MyClass" (or whatever your class name is) and start coding! For example, paste this into MyClass (between the curly braces) and save with Control-S:
 public static void main(String[] args) 
 {
   System.out.println("Hello World!"); 
 }
  1. Before you forget, make sure to ADD YOUR NAME to the code as a comment.
  2. Click on the drop down menu to the left of the Run button (the green triangle next to the bug icon). Click Edit Configurations...
  3. In the new window, click on the green plus sign at the top left of the window and select Application
  4. A new application configuration should appear. Enter in the details such as name ("MyJavaProgram"), your full main class ("cisc181.mylab_n.MyClass"), and classpath of your module ("app"), and click OK. Pop-up menus should help with faster completion here.

Now if you click Run (or use Shift+F10 keyboard shortcut), this should compile and run your app module. If it does not happen quickly (the first time may be quite slow), there is a progress bar at the bottom of the window. If you get an error the first time, try again.

See here for directions on running your unit tests

You can tweak your editor's look and feel at File > Settings > Editor