Office Hours — Today, June 15

Yesterday, June 14

Mark M.
has entered the room
Mark M.
turned on guest access
Jun 15
4:00 PM
Jonathan
has entered the room
Jonathan
Hi
Mark M.
hello, Jonathan!
Jonathan
I have enjoyed reading your book.
Mark M.
how can I help you today?
thanks!
Jonathan
I'm trying to compile audio recording software.
In android studio.
Newest version.
Not sure how to configure.
Got errors.
Mark M.
not sure how to configure... what?
Jonathan
Android studio? Gradle? Not sure.
Mark M.
compile errors? or are you crashing when you run the app?
Jonathan
Mostly before. But sometimes it runs and immediately crashes.
4:05 PM
Mark M.
um, OK
when it runs and crashes, what does the Java stack trace in LogCat say?
Jonathan
I can go check.
It is installed on this computer, so I need to switch windows.
I went to omnibus, media, audiorecording.
Gradle is running.
Mark M.
are you referring to this project? https://github.com/commonsguy/cw-omnibus/tree/m...
Jonathan
Exactly. From the book.
Asks me to update gradle from 2.3.3. to 3.3 should I?
Mark M.
either way should be fine
4:10 PM
Jonathan
I accepted the update.
Gradle is still building
Mark M.
your development machine needs a faster CPU, more RAM, an SSD, or perhaps all three
this is a *very* small project
Jonathan
Maybe.
Indexing.
I'm now running the application on my Nexus 5 2 GB 23 M.
Gradle build running.
Emulator starting up.
Mark M.
emulator?
I would not expect this sample to work on an emulator
4:15 PM
Jonathan
Oh.
Why?
Mark M.
as far as I know, an emulator does not emulate a microphone
now, I just ran the sample on an Android 6.0 emulator
Jonathan
I plugged in my Nexus 5 (physical device to USB). It is running marshmellow.
Mark M.
it did not crash
but I would not expect to get any output, as at least on my machine, the "enable microphone" option is disabled in the emulator controls
Jonathan
It didn't crash on mine this time.
Yet, I *can* run audio recording on the emulator.
Mark M.
earlier in this chat, you indicated that you were getting compile errors sometimes, and runtime crashes sometimes
I cannot help you without the details
Jonathan
How do I get this code to run on my phone? (I'll get back to the compile errors after.)
4:20 PM
Mark M.
just two statements ago, you said "It didn't crash on mine this time"
in context, "mine" is your phone, from what I can tell
Jonathan
No, speaking about the emulator.
Mark M.
then try running it on the phone, and provide me with the details of what is going wrong
I cannot help you without a Java stack trace or specific compile errors
Jonathan
It just does an on-off with a click flashing the screen (on the emulator).
Mark M.
that is all the UI is supposed to do -- it's a ToggleButton
Jonathan
Please remind me how I get it to run on the phone that is attached.
Mark M.
the same way that you get it to run on an emulator: click the green triangle "run" button in the Android Studio toolbar
if your device is set up for USB debugging, Android Studio should give you the option of running on it
Jonathan
I had to stop the application first.
Mark M.
if Android Studio does not pop up a dialog asking where you want to run the app, then there is an issue in the run configuration for this project, which we can fix
Jonathan
View paste
Unexpected error while executing: am start -n "com.commonsware.android.audiorecord/com.commonsware.android.audiorecord.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while Launching activity
Mark M.
OK, Android Studio and your phone are not getting along for some reason
Jonathan
Yup.
Mark M.
when you ran the project, did Android Studio display a dialog, asking where you wanted to run the app?
(with a list of emulators, plus your device)
Jonathan
Yes
Mark M.
and your device was in the list, and you chose it?
Jonathan
Yes
Mark M.
if you look on the device, in the home screen launcher, is the app there?
4:25 PM
Mark M.
it is called "Audio Recording" and has the CommonsWare "molecule" icon
Jonathan
yes
Mark M.
try running it from the launcher
Jonathan
It just started up on a my phone.
The UX was translated into the language of my phone. A good thing.
What is it supposed to do?
The AudioRecorder application?
Mark M.
um, that is covered in the book chapter
if you tap the ToggleButton, it will begin recording
Jonathan
I thought it was supposed to record audio and play it back.
Mark M.
if you tap it a second time, it will stop recording
no, it does not play it back
it just records it
Jonathan
And puts it where?
Mark M.
the recording is saved on external storage, in the Download/ directory, as recording.3gp
though I do not have the MediaScannerConnection code in there to have it be indexed
so it will only show up using something like adb shell
Jonathan
I'll check.
Yup. It works. Nice.
So, next question. I'm trying to compile code -- not only yours and it doesn't work. I'll find an example.
4:30 PM
Jonathan
View paste
For an open source project called android record: "6/15/17
16:31	EOFException: Failed to maintain projects LRU cache for dir /Users/singingtorah-shtiebel_org/Library/Caches/AndroidStudio2.3/resource_folder_cache"
What does that mean?
Mark M.
I do not know
try that (Select "File"->"Invalidate Caches/Restart...")
Jonathan
For Android-AudioRecorder. It says "Change configuration settings?" Edit Continue anyway.
Configuration is still incorrect.
Do you want to edit it again?
Mark M.
sorry, but I do not know what you are referring to
4:35 PM
Mark M.
I just ran File > Invalidate Caches/Restart on Android Studio 2.3
Jonathan
I downloaded another audio recorder from github. Name of project is "Android-AudioRecorder" https://github.com/Uncodin/Android-AudioRecorder. Wondering how do I correct the configuration?
What am I expected to do when I "edit configuration?"
Mark M.
usually, in Android Studio, "configuration" refers to the "run configurations"
you can edit them via Run > Edit Configurations
but since I do not know what is wrong with your run configuration, I cannot tell you what to change
Jonathan
I see general. Module. Deploy. Launch. Target.
Don't think it is wrong. Just don't know how to fill in the form.
It looks like it was a pre-android studio application, so it doesn't know the gradle parameters.
Mark M.
I have not imported an old Eclipse project in a while, so I do not know what it sets up by default
Jonathan
Pre-eclipse.
Mark M.
I recommend you compare and contrast two projects, this one and one created directly in Android Studio
um, unless it is from 2007 or something, there was no "pre-Eclipse" era in Android development, that I recall
Jonathan
I'll try to find a compile error that I had earlier on another project.
4:40 PM
Jonathan
Ok. I opened sayit. Another open source project.
View paste

16:41	EOFException: Failed to maintain projects LRU cache for dir /Users/singingtorah-shtiebel_org/Library/Caches/AndroidStudio2.3/resource_folder_cache

16:41	Gradle sync failed: /Users/spoken-android/Say_it/keystore.properties (No such file or directory)
			Consult IDE log for more details (Help | Show Log)
Mark M.
that project is set up to refer to a keystore.properties file from its Gradle build scripts
and that file is missing
Jonathan
View paste
Error:(11, 0) /Users/spoken-android/Say_it/keystore.properties (No such file or directory)
<a href="openFile:/Users/spoken-android/Say_it/app/build.gradle">Open File</a>
Mark M.
you would have to ask the project maintainers what to do
Jonathan
They appear to be cryptographic keys. I think.
Mark M.
it might configure those keys
Jonathan
I'm looking for the file.
View paste (5 more lines)
android {
    signingConfigs {
        config {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    defaultConfig {
        applicationId 'com.cesarsk.say_it'
        minSdkVersion 21
        targetSdkVersion 23
...
4:45 PM
Jonathan
View paste
apply plugin: 'com.android.application'

// Create a variable called keystorePropertiesFile, and initialize it to your
// keystore.properties file, in the rootProject folder.
def keystorePropertiesFile = rootProject.file("keystore.properties")

// Initialize a new Properties() object called keystoreProperties.
def keystoreProperties = new Properties()

// Load your keystore.properties file into the keystoreProperties object.
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
Mark M.
there is supposed to be a keystore.properties file in the project root
Jonathan
It seems to be creating the file, so why is it a problem?
Mark M.
no, it is not creating the file
it is creating the Groovy equivalent of a java.io.File object
and trying to read from the file using a FileInputStream
I demonstrate this sort of properties-reading code in one of the chapters on Gradle
Jonathan
I can check there.
Mark M.
so, when it tries to open the file, and the file is not there, you get the Gradle sync error
Jonathan
So, if I read that chapter. Does that tell me how to create this file?
Mark M.
no
as I wrote, you would need to contact the project maintainers and ask them what is supposed to be in it
Jonathan
Got it.
Mark M.
the file itself is just a properties file, with key-value pairs
but I have no way of knowing what keys and values are required
Jonathan
That's what I thought.
Mark M.
you might be able to reverse-engineer it from the Gradle script
but, that's well outside the scope of what I can help with in these chats
Jonathan
I'm moving on to trying other code I had difficulty with. Here is an error message from "longman-to-anki" project.
Failed to maintain projects LRU cache for dir /Users/singingtorah-shtiebel_org/Library/Caches/AndroidStudio2.3/resource_folder_cache
What is that?
4:50 PM
Mark M.
we discussed that previously
Jonathan
Trying it.
Restarting. I have a macbook air. 11" 1.3 Ghz. 8GB Ram 1600. 128 GB SSD. intel core 5. MacBook Air (11-inch, Mid 2013). What configuration do I need?
Mark M.
1.3GHz is a bit slow
8GB RAM should be fine, but that depends on what else you have open, of course
4:55 PM
Jonathan
More general question. I also seem to have asked before, but I didn't understand the answer. What chapter of your book covers how to set up the configuration, particularly for pre-android studio found open-source code?
Mark M.
I do not cover that
I talk about run configurations in a few spots, specifically around testing
Jonathan
Thank you for helping me today. I feel that I learned from it. Have a wonderful evening.
:-)
Mark M.
note that the transcript will be published on https://commonsware.com/office-hours/ shortly after the chat ends
5:00 PM
Mark M.
that is a wrap for today's chat
the next chat is Tuesday at 4pm US Eastern
have a pleasant day!
Jonathan
has left the room
Mark M.
turned off guest access

Yesterday, June 14

 

Office Hours

People in this transcript

  • Jonathan
  • Mark Murphy