Editing GRAndWalkthrough

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 6: Line 6:
  
 
* Open Android Studio
 
* Open Android Studio
** File > New> New Project
+
** File > New> New Project
 
** Give it a name and a company domain
 
** Give it a name and a company domain
 
** Select the type -- probably Phone and Tablet
 
** Select the type -- probably Phone and Tablet
Line 37: Line 37:
  
 
* Create a new '''jni''' directory.
 
* Create a new '''jni''' directory.
** app > src >main > Right Click> New > Directory> 'jni'
+
** app > src >main > Right Click> New > Directory> 'jni'
 
** This makes a folder app/src/main/jni
 
** This makes a folder app/src/main/jni
 
* Add the Android makefiles we provide
 
* Add the Android makefiles we provide
Line 62: Line 62:
  
 
* We've created the '''jni''' directory where our flowgraph lives.
 
* We've created the '''jni''' directory where our flowgraph lives.
* Add a new file to this directory: Right-Click -> New > New C/C++ Source File
+
* Add a new file to this directory: Right-Click -> New > New C/C++ Source File
 
** name this file fg.cpp and see the [https://github.com/trondeau/GrTemplate/blob/master/app/src/main/jni/fg.cpp flowgraph file] in the GrTemplate repo.
 
** name this file fg.cpp and see the [https://github.com/trondeau/GrTemplate/blob/master/app/src/main/jni/fg.cpp flowgraph file] in the GrTemplate repo.
  
Line 134: Line 134:
 
}</syntaxhighlight>
 
}</syntaxhighlight>
 
* This flowgraph is very simple and just creates the following flowgraph:
 
* This flowgraph is very simple and just creates the following flowgraph:
** <code>null_source -> throttle -> null_sink</code>
+
** <code>null_source -&gt; throttle -&gt; null_sink</code>
 
* There are four JNI functions declared here that we can use from our Java app:
 
* There are four JNI functions declared here that we can use from our Java app:
 
** FgInit: Where we ceate the blocks and construct the flowgraph.
 
** FgInit: Where we ceate the blocks and construct the flowgraph.
Line 208: Line 208:
  
 
* Tell Android Studio about the NDK:
 
* Tell Android Studio about the NDK:
** Under Gradle Scripts > local.properties
+
** Under Gradle Scripts &gt; local.properties
 
** Add a line fo the NDK:
 
** Add a line fo the NDK:
 
** ndk.dir=/opt/ndk
 
** ndk.dir=/opt/ndk
 
** Or wherever you installed the NDK on your system.
 
** Or wherever you installed the NDK on your system.
  
* Next, we have to modify Gradle Scripts > "build.gradle (Module: app)" (Can also find this under the '''app''' directory).
+
* Next, we have to modify Gradle Scripts &gt; "build.gradle (Module: app)" (Can also find this under the '''app''' directory).
  
 
* Here we will tell Android Studio not to try and do its own thing with the NDK but to run the command 'ndk-build' from the path directly. This makes sure that the build system uses our Android.mk file, which is important because we have a lot of libraries to install ourselves and there isn't a better way to do this in Android Studio.
 
* Here we will tell Android Studio not to try and do its own thing with the NDK but to run the command 'ndk-build' from the path directly. This makes sure that the build system uses our Android.mk file, which is important because we have a lot of libraries to install ourselves and there isn't a better way to do this in Android Studio.
Line 231: Line 231:
  
 
     tasks.withType(JavaCompile) {
 
     tasks.withType(JavaCompile) {
         compileTask -> compileTask.dependsOn ndkBuild
+
         compileTask -&gt; compileTask.dependsOn ndkBuild
 
     }</syntaxhighlight>
 
     }</syntaxhighlight>
  
Line 241: Line 241:
  
 
<pre>$ android update project -p . -s -t android-21</pre>
 
<pre>$ android update project -p . -s -t android-21</pre>
'''''' I am sure there is a way to do this within Android Studio itself, but I've yet to figure out how. (Note: Tools>Android>'Sync Project with Gradle Files')
+
'''''' I am sure there is a way to do this within Android Studio itself, but I've yet to figure out how. (Note: Tools&gt;Android&gt;'Sync Project with Gradle Files')
  
* Build the program: Build -> Make Project (or Ctrl + F9)
+
* Build the program: Build -&gt; Make Project (or Ctrl + F9)
 
* At this point, if everything was done correctly above, the build should end with "BUILD SUCCESSFUL" in the Messages tab at the bottom of the Android Studio interface.
 
* At this point, if everything was done correctly above, the build should end with "BUILD SUCCESSFUL" in the Messages tab at the bottom of the Android Studio interface.
 
* Build the project with the fg.cpp we wrote. It will take a few seconds for the ndk-build to run, and you'll likely see a handful of warnings about the Android LOG levels, which you can ignore (or help us fix them!). You should not get any errors.
 
* Build the project with the fg.cpp we wrote. It will take a few seconds for the ndk-build to run, and you'll likely see a handful of warnings about the Android LOG levels, which you can ignore (or help us fix them!). You should not get any errors.

Please note that all contributions to GNU Radio are considered to be released under the Creative Commons Attribution-ShareAlike (see GNU Radio:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)