These are chat archives for pybee/general

22nd
Feb 2017
Elias Dorneles
@eliasdorneles
Feb 22 2017 01:01
so, what's the way to add dependency JARs to a project, using briefcase?
Elias Dorneles
@eliasdorneles
Feb 22 2017 01:08
I'm getting errors because the support librarys (android.support.*) aren't in the class path
I checked, and it seems they aren't in the compilation class path, either
Elias Dorneles
@eliasdorneles
Feb 22 2017 15:51
Hey @freakboy3742, I'm having a lot of trouble to find the JAR files needed for these Android support libraries. How did you do it?
Russell Keith-Magee
@freakboy3742
Feb 22 2017 15:52
@eliasdorneles They’re generated as part of the VOC build - in the dist directory
Elias Dorneles
@eliasdorneles
Feb 22 2017 16:01
you mean the python-android-support.jar file, right?
well, AFAIU, that doesn't contain everything
classes for imports like android.support.v4.widget aren't there
you must've done this before, since the demo is also importing that: https://gist.github.com/freakboy3742/7beb22c587e57240610777a44af645d8#file-android-py-L16
and I can't find the JAR files for all these support libraries in anywhere official
Elias Dorneles
@eliasdorneles
Feb 22 2017 16:06
I'm pulling my hair here since yesterday trying to get all the dependencies in place
Russell Keith-Magee
@freakboy3742
Feb 22 2017 16:08
Ah - right. The v4 jarfile is part of a library that ships externally. It’s a support library provided by Android to provide certain new API features to older platforms (if I understand it correctly)
Elias Dorneles
@eliasdorneles
Feb 22 2017 16:08
Yeah, it seems there are a bunch of JAR files for that (not just one)
Russell Keith-Magee
@freakboy3742
Feb 22 2017 16:08
You need to download the v4 support bundle as part of the Android tools, and then copy the jarfile into the project.
Elias Dorneles
@eliasdorneles
Feb 22 2017 16:09
Yes, that's what I've been trying to do the whole morning :)
But they seem to be missing stuff, even if I copy all the JAR files from it, I get some different thing that's not being found
Russell Keith-Magee
@freakboy3742
Feb 22 2017 16:10
There’s one jar file; you can find it as sdk/extras/android/support/v4/android-support-v4.jar
(where sdk is in your ANDROID_HOME)
Elias Dorneles
@eliasdorneles
Feb 22 2017 16:11
hm, that's what you have in your machine? my sdk/extras/android has different content
Russell Keith-Magee
@freakboy3742
Feb 22 2017 16:12
The v4 support library is something you need to install as an extra
run android, and look through the options you can enable.
Elias Dorneles
@eliasdorneles
Feb 22 2017 16:12
yeah, I've done that
Russell Keith-Magee
@freakboy3742
Feb 22 2017 16:12
And no sign of an android-support-v4.jar?
Elias Dorneles
@eliasdorneles
Feb 22 2017 16:12
android sdk, selected the support repository, installed stuff
nope
Russell Keith-Magee
@freakboy3742
Feb 22 2017 16:12
Hrm...
Elias Dorneles
@eliasdorneles
Feb 22 2017 16:12
but, there are a bunch of JAR files with sources
like this:
/home/elias/Android/Sdk/extras/android/m2repository/com/android/support/support-core-utils/25.2.0/support-core-utils-25.2.0-sources.jar
ohhh, there are some .aar files
with classes.jar files inside of them...
I think this is what I need: /home/elias/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/25.1.0/appcompat-v7-25.1.0.aar
holy crap, what a mess
Russell Keith-Magee
@freakboy3742
Feb 22 2017 16:15
Google really does seem to go out of their way to make this difficult...
Elias Dorneles
@eliasdorneles
Feb 22 2017 16:15
yeah...
I wonder if it'll work if I just put these .aar in the resources
Elias Dorneles
@eliasdorneles
Feb 22 2017 16:23
http://stackoverflow.com/questions/21417419/how-to-convert-aar-to-jar
So, this explains why just copying the classes.jar files from the Android Studio projects doesn't work (which was my last attempt before talking here in the chat)
I was getting an error for R.drawable or something, which must've been defined as a resource inside those .aar files
So I guess I have to figure out how to use the resources from these .aar files...
Elias Dorneles
@eliasdorneles
Feb 22 2017 16:45

From: https://developer.android.com/studio/projects/android-library.html

Each library module creates its own R class

This is going to be tricky... :point_up_2:
Russell Keith-Magee
@freakboy3742
Feb 22 2017 16:46
R classes are autogenerated out of the resource definitions - not sure why you’re getting problems with those
Elias Dorneles
@eliasdorneles
Feb 22 2017 16:46
That's exactly the issue I get, if I try copying the jars, I get this:
E/AndroidRuntime(30928): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.appcompat.R$drawable" on path: DexPathList[[zip file "/data/app/org.eliasdorneles.myapp.myapp-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
so, the thing is these .aar files are like "APKs for libraries", which can have their own R classes
Russell Keith-Magee
@freakboy3742
Feb 22 2017 16:47
Ah. Oh good...
Elias Dorneles
@eliasdorneles
Feb 22 2017 16:47
good?
I'm more like "oh god..." :D
because sadly, it's not just a matter of adding JARs... =/
I think I have to pry open these .aar files, extract the JARs, copy the resources, and somehow compile these R classes for each library and put somewhere (android/bin/classes ?)
going to take a break, see ya
Elias Dorneles
@eliasdorneles
Feb 22 2017 21:21
So, after some googling and stackoverflowing, it seems that it's best to stick to SDK versions <= 19.1.0 (see comments on: http://stackoverflow.com/a/39104174/149872), which had the support libraries packaged as JAR files
Finding those packages though seems tricky, since in the Maven repositories used by Android studio there are only the AAR versions.
It was a comment on another SO question that pointed me to https://dl-ssl.google.com/android/repository/support_rXX.zip (replace XX by the API level e.g. 19, and you'll get a zip file with the source code and jar files for that version)
using this, I could deploy the app to the emulator without crashing, yay! :)
and now I got another problem, which is the buttons aren't showing up...
Russell Keith-Magee
@freakboy3742
Feb 22 2017 21:24
Ok - that’s good to know.
Elias Dorneles
@eliasdorneles
Feb 22 2017 21:26
yeah. we'll probably have to look at some point into the AAR thing in the future
Russell Keith-Magee
@freakboy3742
Feb 22 2017 21:26
Indeed.
Elias Dorneles
@eliasdorneles
Feb 22 2017 21:26
btw, someone pointed me to this: https://github.com/NativeScript/NativeScript
Russell Keith-Magee
@freakboy3742
Feb 22 2017 21:27
Interesting.
As for AAR - if the Android landscape is changing, it might be an idea to start from scratch.
Elias Dorneles
@eliasdorneles
Feb 22 2017 21:28
I skimmed through their docs, don't know how it works, but it seems to do something similar with the idea of compiling to bytecode and integrating natively
Russell Keith-Magee
@freakboy3742
Feb 22 2017 21:28
i.e., write a hello-world app from scratch in Java using all the latest gradle and aar options
and then port the java app bits to Python.
Elias Dorneles
@eliasdorneles
Feb 22 2017 21:29
ah, I see, build the hello-world app without Android Studio you mean, right?
yeah, that's a good idea!
Russell Keith-Magee
@freakboy3742
Feb 22 2017 21:29
Well a project that can be compiled from the command line. Whether it might be easier to use Android Studio to generate the initial project ,I don’t know.
Elias Dorneles
@eliasdorneles
Feb 22 2017 21:30
yea, I've done one w/ Android Studio already, and it's easy to get it working, but I end up not understanding how things are working, so something more easily reproducible will be nice! :thumbsup:
okay, I'll work on that tomorrow!
today I want try just a bit more to see if I can get these buttons to work...
thanks for the help, and sorry for the noise in the channel! :D
Russell Keith-Magee
@freakboy3742
Feb 22 2017 21:32
Hey - no worries at all - that’s what the channel is for.
Sorry I didn’t always respond quickly - I’ve been in and out all day.
Elias Dorneles
@eliasdorneles
Feb 22 2017 21:33
oh yeah, no worries, I know you've been pretty busy :)
Elias Dorneles
@eliasdorneles
Feb 22 2017 23:37
so, I came up with this minimal Android app using Gradle: https://github.com/eliasdorneles/minimal-android-gradle-app
tomorrow I'll look into how to use that with VOC and briefcase, using a custom template