Office Hours — Today, July 9

Friday, July 5

Jul 9
8:50 AM
Mark M.
has entered the room
8:55 AM
Mark M.
turned on guest access
Shawn V.
has entered the room
Mark M.
hello, Shawn!
how can I help you today?
Shawn V.
I've got a complex question.
I will try to state it as briefly as possible
Erik
has entered the room
Mark M.
hello, Erik! Shawn arrived first, so I will take a question from you after Shawn's!
Shawn: go right ahead!
Erik
sure
9:00 AM
Shawn V.
I am working on an Android TV application. The video player appears to reset approximately once a week when Android updates the android.webkit APK. I am looking to remove any import android.webkit elements to its own apk to prevent the update from causing the app to reset.
Mark M.
what are you using for the video player? VideoView? MediaPlayer? ExoPlayer? something in a WebView? something else?
Shawn V.
I have them removed from the code temporarily, I plan to place them into their own APK. However, I have a large number of libraries. How can I make sure that no element has the android.webkit library included as well
Exoplayer
However, the video player is very large and includes menu comfiguration elements which contained the webview elements
Mark M.
ah, OK
Shawn V.
I removed those elements but I'm continuing to see the issue so my next thought is it might be one or more libraries
Mark M.
if you do a ProGuard build without obfuscation, you could then use Analyze APK in Android Studio to see your method references, across everything in that APK, including libraries
Shawn V.
Excellent, thanks. I will try that. I appreciate the help
Mark M.
note that this will not readily tell you which library is the culprit, but it will at least tell you if there is more research needed
and the ProGuard would help reduce false positives from references that you are not really using; just analyze a debug build for a quick-and-dirty checkout without such minimization
let me take a question from Erik, and I will return to you shortly
Erik: your turn! do you have a question?
Shawn V.
Thank you.
9:05 AM
Erik
Hi Mark, I tried to create a new package in Android Studio through the right click menu when I select a parent directory. It was not there. How do I make a directory into a pkg
Mark M.
was the parent directory inside of java/ (or kotlin/)?
Erik
kotlin, in its product flavor
so src/flavor/kotlin/
Mark M.
and you are not seeing Package as an option from the New fly-out menu in the context menu
?
Erik
no
Mark M.
hang on, let me try to repro this
what version of Studio are you using?
Erik
3.4.1
Mark M.
it is showing up for me
on 3.4.1
Erik
try creating a new directory under src called flavor
Mark M.
ah
9:10 AM
Mark M.
is it configured as a flavor in build.gradle?
Erik
yeah
Mark M.
looks like a Studio bug
a java/ directory allows package creation, but a kotlin/ directory does not
Erik
what would I need to add to the gradle?
Mark M.
I don't know if there is a way to fix the Studio bug, let alone by a Gradle setting
though let me try something...
ah!
View paste
    sourceSets {
        flavor {
            java.srcDirs += ['src/flavor/kotlin']
        }
    }
add that to your android{} closure
with that in place, and after the obligatory Gradle project sync, the kotlin/ folder shows up with a blue folder, and I get the New > Package context menu option
I haven't used kotlin/ in Android Studio, only IDEA, and for non-Android projects
9:15 AM
Mark M.
while you try that, let me take another question from Shawn, and I will be back with you shortly
Shawn: back to you! do you have another question?
Shawn V.
Nope, but after the build finishes and I will use the Analyze APK feature and see what I can determine. Thank you
Mark M.
OK, if you come up with another question, let me know!
Erik: back over to you!
Erik
that worked thankyou
Mark M.
great! lucky for me I had a project handy with the sourceSets syntax -- I needed that for something else yesterday
ideally, Studio would recognize kotlin/ directories "out of the box"
hopefully they will add that in a future version
Erik
yeah esp since kotlin is becoming the standard language
Mark M.
basically, once the Kotlin Gradle plugins are requested, kotlin/ should be a recognized source directory
9:20 AM
Erik
now I see my flavored files reference the file under app/src/main. I want it to reference the file under app/src/flavor
Mark M.
sorry, I do not understand what "reference" means here
Shawn V.
Now I have a question, I performed an AnalyzeAPK and I can see lots of folders: lib, res, assets, tons of dex files. Any guess where I could find the android.webkit library in the folder structure?
Mark M.
you will need to look through the DEX files
AFAIK, that's going to be one at a time, unfortunately
9:25 AM
Mark M.
when you click on one, you will get a class hierarchy pane in the bottom half of the analysis tab
look in there for android.webkit references
Shawn V.
Thank you very much
I appreciate the help
Erik
flavor A in app/src/main has SomeFile() and flavor B in app/src/flavor has SomeFile(int). AnotherFile in app/src/flavor invokes SomeFile(int) and the IDE says it does not recognize that
Mark M.
are you sure that you tied the flavors each to their own flavor-specific kotlin/ directory?
View paste
sourceSets {
        flavor {
            java.srcDirs += ['src/flavor/kotlin']
        }
    }
Erik
yes because without that I don't see the compilation errors
Mark M.
wait
flavor A is not app/src/main/
that is the main source set
flavor A needs its own source set
Shawn V.
Excellent, I can see references. Is there any way to trace the dex file back to what source and libraries was used to make it?
Mark M.
and you cannot have the same class file in both main/ and a flavor
Erik
what if I just want to create a single flavor
Mark M.
Shawn: not that I know of, sorry
Erik: the flavor still needs its own source set
main/ should already have supported kotlin/, based on my test
Shawn V.
Thank you very much, at least I will be able to tell when the work is complete.
Erik
are you saying I need to create 2 flavors?
I need the version I had PLUS the flavored one
9:30 AM
Erik
if I can't have the same class in main/ and a flavor, would I need to move the class out of main and into 2 flavors
Mark M.
Shawn: for the open source libraries, a quick search of the repo or source code for android.webkit is probably the quickest route
Erik: you cannot have the same class in main/ and a flavor -- this has nothing to do with Kotlin and everything to do with how product flavors are implemented
so, yes, if you want two different implementations, you would need two product flavors, with the two class variants each in their own flavor
Erik
thank you
Mark M.
when you choose a build variant (e.g., Build Variants tool in Studio), you will choose which of those two flavors you are building
9:35 AM
Mark M.
if either of you have another question, go right ahead!
9:40 AM
Shawn V.
Thanks. I hope you have a good day.
9:45 AM
Mark M.
you too!
Erik
I have a module on the same level as the app module called Database. Database contains logic and models for both flavor A and flavor B. The models are in this Database module under A and B, respectively. Since the functionality in flavor A is equivalent to the application before flavorB, how do I exclude Databse/B if I am building flavorA? I don't want to exclude flavorA stuff from flavorB because Database contains general logic.
basically I want to exclude a subdirectory in another module if I am on flavor B.,
Mark M.
off the cuff, I do not know how to do that
other than by pulling that stuff out into another module, and only conditionally depending upon it
9:50 AM
Erik
that might work. So pull the models into their own module, ie moduleModelsA and moduleModelsB. Then the app would import Database, moduleModelsA, moduleModelsB.
9:55 AM
Erik
appreciate your help
bye guys
Erik
has left the room
10:00 AM
Shawn V.
has left the room
Mark M.
turned off guest access

Friday, July 5

 

Office Hours

People in this transcript

  • Erik
  • Mark Murphy
  • Shawn Vines

Files in this transcript