Office Hours — Today, January 16

Tuesday, January 14

Jan 16
7:20 PM
Mark M.
has entered the room
7:25 PM
Mark M.
turned on guest access
EGHDK
has entered the room
Mark M.
hello, EGHDK!
how can I help you today?
EGHDK
Hello. I've got a small list ready!
I have two things to follow up on from the last time you gave me advice on how to create a listView from multiple adapters. First, https://github.com/commonsguy/cwac-merge has an error in the readme of the installation section. The first link takes you to: gihub.com/... instead of github.com/... Made me think github was down for a while. hahaha.
Mark M.
OK, I'll take a look at that
in the future, feel free to file an issue on the project
EGHDK
Second, you said "Step #2: Create three views for the headers, however you want those to look". I'm having trouble creating these views. I have done "TextView text = new TextView(this)" text.setText("Header") and then mergeAdapter.addView(text); But it looks weird/unstyled. I know I asked about this before but I was never able to "figure it out". How would I go about creating an textView xml and then using that for the textView? And what is that called?
Mark M.
it is called a layout resource
you put it in res/layout/ or a similar directory
you probably have many of these already
and, you would use a LayoutInflater to create the TextView from the layout resource
7:30 PM
EGHDK
So let's say I wanted to create the textView for this header, what would have to be my root element in xml? a textView?
Mark M.
yes
EGHDK
Okay, so my last item on my list is: I'm interested in enabling proguard for my application. As of right now I'm getting even more familiar android security and the project file tree. Something that surprised me today when trying to enable proguard is that in the root of my project I have myApp.keystore, and my-key.keystore. Is that bad? Does that mean that the keystore is being shipped with my apk?
Mark M.
no, the keystore will not be in your APK
just as other files in the root of your project are not in your APK
the only one that is would be AndroidManifest.xml
7:35 PM
EGHDK
Okay, I guess that's it. Besides me being stuck on proguard.
There's a bunch of tutorials on it online, but they seem outdated.
Mark M.
the ProGuard site itself should be up to date, though not especially Android-specific
EGHDK
Some of the files they reference don't exist. I looked in your book for a proguard "lesson" but I didn't find anything. Did I miss something?
Mark M.
no, I have not covered it yet
the filenames for use in Android will differ from ProGuard norms, perhaps, because we have a different build process
EGHDK
Yeah, I was reading through that today but on the first line it mentions: proguard.cfg but I don't have that.
Mark M.
right
the default name is proguard-project.txt
same role
EGHDK
Okay, and then the properties would be project.properties?
Mark M.
I'm not sure quite what you're referring to there, though there is a project.properties file
however, if proguard-project.txt is your filename, you should not need to change project.properties
7:40 PM
Mark M.
yeah, that page is out of date
le sigh
EGHDK
Okay good. I thought it was me.
Because I tried following "the instructions"
View paste
and even got lost with enable proguard with this proguard.config=proguard.cfg
but if you are in project.properties it tells you to "uncomment" this to enable proguard.
View paste
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
Mark M.
that's the right line there, with the reference to proguard-project.txt
so, leave project.properties alone if that line is there
EGHDK
So I'm unsure of what to go with. I don't know if eclipse generated the wrong things, or if the documentation is old.
Mark M.
and put your ProGuard directives in proguard-project.txt
EGHDK
Yeah, that line is there (originally it was commented out), but I uncommented it, so now it should be "enabled"... right?
Mark M.
correct
for release builds
EGHDK
Because that same file says "#Do not modify this file"
so I got worried.
Mark M.
if it makes you feel better, this will all be a lot simpler in, say, 2017 or so
:-)
EGHDK
Basically this is my project.properties... does it look correct?
View paste
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-18

android.library.reference.1=actionbarsherlock
Mark M.
assuming that your first comment word-wrapped, and assuming that actionbarsherlock is a subdirectory under the project root, yes, that looks fine
7:45 PM
EGHDK
2017... hahah Why do you say that this will be simpler? Are they working on something?
Mark M.
over the past couple of updates to my book, I have been adding chapters about the new Gradle-based build system
which, all things considered, is probably not something that you specifically should need to worry about in the near term
Google is changing the way we build our projects, in conjunction with building out the new Android Studio IDE
however, the Android toolchain steers like an aircraft carrier
and so, it takes a *long* time to pivot on stuff like this
and it takes a *long* time for knowledge to percolate through the ecosystem
EGHDK
gotcha.
Mark M.
for me, these next few years are gonna suck, from the standpoint of support questions
but, in the end, we will wind up with a more sensible solution
EGHDK
Also, just to triple check. You said assuming my first comment is word wrapped. My first comment is:
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
Should the words directly after "uncomment this" be uncommented?
(Available properties:sdk.dir, user.home):
Mark M.
that is all one line in your file, right?
EGHDK
yeah
Mark M.
then it is correct as it stands
EGHDK
great.
You also mentioned "and put your ProGuard directives in proguard-project.txt"
7:50 PM
Mark M.
correct
EGHDK
So basically after I enable proguard in project.properties, all the other changes will be made in proguard-project.txt?
Mark M.
correct
EGHDK
Btw that merge adapter was super simple. So easy to use.
Mark M.
it doesn't do much, so it tries to do it simply
sometimes, I come up with a good API my first try
other times, not so much
EGHDK
Which brings me to another question. I never "know" if I'm importing libraries/jars the right way. So for the merge adapter to work, I had to download two seperate jars. I then dragged them from my downloads into the libs folder in my app, I then right clicked on my project, went to "Java build path" and under libraries I clicked "add jars", browsed for them in my project libs and then, when to the "order and export" tab and checked both of the jars. Is that the right way to do it?
Mark M.
you were fine up through the "into the libs folder of my app"
the rest was unnecessary and might cause problems
putting the JARs in libs/ is sufficient for Eclipse and Ant
7:55 PM
EGHDK
Oh really?
Mark M.
you may wish to double-check one item in your build path for your project: http://stackoverflow.com/questions/16596969/lib...
EGHDK
Interesting. Should I just remove them then? in libraries and order and export?
Mark M.
I'd say yes
generally speaking, outside of double-checking the one thing in that SO answer I linked to above, you don't mess with the Java build path in Eclipse for Android development
OTOH, so long as what you have is working, you could just leave it alone for the time being
it's your call
EGHDK
OTOH?
Mark M.
"on the other hand"
EGHDK
Gotcha. So if I order and export android private libraries, that will go into my libs folder and make sure everything is working?
Mark M.
yes
EGHDK
working or imported? whatever you want to call it.
oh! So thats what that means.
heh
Okay, well I've messed up a lot of jars then. I've done this same process tens of times now.
Mark M.
again, if your app is running, you can leave them alone
but, you don't need to do it
8:00 PM
Mark M.
the real problem comes in if you *don't* put them in libs/, and just try attaching them to your project via the manually-adjusted build path
then, they will be available for the compile step, but will not be packaged into the APK
and you get a lot of ClassNotFoundExceptions at runtime
EGHDK
Gotcha.
Makes sense.
When it comes to libraries that are folders (like ABS), I just import them as a project in eclipse, and then add it manually by project properties -> android -> add library. That sounds correct... right?
Mark M.
ues
er, yes
EGHDK
Is there anyway to keep my eclipse package explorer clean? I use a whole bunch of libraries and they are all over the place. I never know if it's a library or what, because most libraries are called "library" and never "ActionBarSherlock" or "SwitchBackport".
Mark M.
well, you can rename them in Eclipse to be whatever you want
Shift+Alt+R, or right-click over the project and choose Refactor > Rename
8:05 PM
EGHDK
Alright, I never knew if that messed anything up. So I never attempted. Cool, I look forward to naming all of the with an "A" to make sure they show up at the top of my package explorer. heh. Thanks
8:10 PM
EGHDK
I think that about sums it up for all the questions I had in 48 hours worth of coding since Tuesday. hahah. Thanks again Mark
Mark M.
you are very welcome
8:15 PM
Emmanuel
has entered the room
8:20 PM
Mark M.
hello, Emmanuel!
Emmanuel
Hello all
Mark M.
Emmanuel: do you have a question?
Emmanuel
no, I wanted to personally thank you for your long and detailed answer today
Mark M.
ah, you're the Emmanuel who used the new SO bump service?
Emmanuel
I thought it was 7.30pm CST...lol
yes
really nice idea
Mark M.
it's something I had been meaning to add to the site for quite a while
finally got around to it
Emmanuel
I actually had the chance to talk to you in person in AnDevCon Boston last year
(I was the guy asking about Context)
maybe you had multiple guys asking about Context
Mark M.
it's more that it was, like, eight months ago
I'm happy if I remember what I had for breakfast, some days
:-)
mfcplus
has entered the room
Mark M.
hello, mfcplus!
Emmanuel
LOL
Mark M.
mfcplus: the chat will be ending soon -- do you have a question?
mfcplus
any idea when will the code be updated using android studio instead of eclipse?
Mark M.
at their current pace?
mid-2014, I'm hoping
mfcplus
ok, thanks
Mark M.
even then, I won't be converting all of them
mfcplus
and what you think about html5 vs native
Mark M.
um, could you be more specific?
8:25 PM
mfcplus
like writing a native android app using java vs using html5 javascript on the device
Mark M.
mfcplus
cool thanks
Mark M.
while that blog post is more about PhoneGap than plain HTML5, it covers my opinion
generally speaking: HTML5 (with or without PhoneGap) is fine for many use cases, though not all
if anyone has a question, chime in
Emmanuel
You are not coming any time soon to St. Louis, MO, right?
Mark M.
I have no current plans to go to St. Louis
if I think of it, I might propose a talk for Strange Loop, which IIRC is held in St. Louis
Emmanuel
I was going to tell you about that right now
you beat me to it
that would be great!
Mark M.
I have heard good things about that event
8:30 PM
Emmanuel
yeah
and it is more affordable than AnDevCon
Mark M.
it seems like it's more of a language event, though
Emmanuel
yeah, that is true
Mark M.
anyway, I filed myself a to-do for it
and that's a wrap for today's chat
Emmanuel
cool, thank you, good night
EGHDK
Thanks mark goodnight!
Mark M.
the transcript will be posted to http://commonsware.com/office-hours/ shortly
next one is 10am US Eastern on Tuesday
have a pleasant day!
Emmanuel
see you then
EGHDK
has left the room
Emmanuel
has left the room
mfcplus
has left the room
Mark M.
turned off guest access

Tuesday, January 14

 

Office Hours

People in this transcript

  • EGHDK
  • Emmanuel
  • Mark Murphy
  • mfcplus