Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
ringu0
Feb 24, 2013


Thank you! I'll try the shell trick.

Jabor posted:

Either package it with the binary you're shipping, or have a first-run state where the user can provide that information.

Unfortunately neither of these solutions is in the cards. The web services are self-hosted by the customers, so there's no single URL to package. There is a first-run state and the UI to type in the URL, but the deployment team requested a config file for mass deployment. It's an enterprise app, and we provide hardware with preinstalled software.

Adbot
ADBOT LOVES YOU

Glimm
Jul 27, 2005

Time is only gonna pass you by

ringu0 posted:

Thank you! I'll try the shell trick.


Unfortunately neither of these solutions is in the cards. The web services are self-hosted by the customers, so there's no single URL to package. There is a first-run state and the UI to type in the URL, but the deployment team requested a config file for mass deployment. It's an enterprise app, and we provide hardware with preinstalled software.

Is MDM (or Android Enterprise Management) an option instead?

ringu0
Feb 24, 2013


Glimm posted:

Is MDM (or Android Enterprise Management) an option instead?

Hm-m... that's a good question. I would need to ask the deployment team. Thanks!

kitten smoothie
Dec 29, 2001

ringu0 posted:

Unfortunately neither of these solutions is in the cards. The web services are self-hosted by the customers, so there's no single URL to package. There is a first-run state and the UI to type in the URL, but the deployment team requested a config file for mass deployment. It's an enterprise app, and we provide hardware with preinstalled software.

Last time I worked on such an enterprise app, we provided the clients with the apk and instructions for the client to use apktool to re-pack it with their configuration and customization. We instructed them to sign it and distribute it themselves using their MDM.

dirby
Sep 21, 2004


Helping goons with math
I'm going through the "Android Kotlin Fundamentals" codelabs (and the nearly identical Udacity class).
Basically, I can write R.drawable.image_1 without repeating the package name. But I'd need it for resources.getIdentifier("image_1","drawable",packageName).
Is there a different way to get an identifier from a string that doesn't need this.packageName or similar?

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

dirby posted:

I'm going through the "Android Kotlin Fundamentals" codelabs (and the nearly identical Udacity class).
Basically, I can write R.drawable.image_1 without repeating the package name. But I'd need it for resources.getIdentifier("image_1","drawable",packageName).
Is there a different way to get an identifier from a string that doesn't need this.packageName or similar?

I'm not quite sure what you mean. The R class is getting fully referenced (albeit likely silently by virtue of being in the same package as your class), which is why you don't need to repeat it. For Resources.getIdentifier, the Resources class is going to a lookup table, and the package name is part of it. If you look at the docs, you can set the package name and the resource type in the name argument, but it's usually more readable and more convenient to just do what you're doing now and provide both the packagename and the resource type.

Volguus
Mar 3, 2009
I have a question about a very "interesting" (to put it mildly) thing a company I work with is trying to do with an Android app. What they're trying to sell at some point in the future is a library, and one of the platforms they want to support is Android and therefore be able to sell the .aar for other people to build on it. Now, they are very protective of their IP and very much are afraid of other people trying to steal their stuff. But since they need customers they reluctantly gave a sample application that's showcasing the library to certain people. How is the library protected? Via a license file that needs to be provided to the library upon initializing it. That license file contains information about the period is available for, software version is valid for and device identification. Right now, that device identification has been a MAC address. Device's wifi card MAC. I presume you can see where this is going.

Since Android 10 (maybe before?) there's an option in network settings to use a randomized MAC for wifi (no idea if it's for one network, for all or how exactly this gets controlled). Anyway, when the app runs and if you have that option turned on, obviously the MAC that you get doesn't match the one in the license.
Now, the question is: can a device be identified in a unique way via some information that is available apriori to the user, so that the license file is generated for that particular device and the apk will not work on a different one? Obviously generating an UUID the first time the app gets launched doesn't work. I thought about IMEI (if it can even be read by apps), but only phones have that as far as I can tell. A device that's not a phone (or doesn't have a SIM) doesn't have an IMEI.

Of course, a solution would be to have a server where a key is created and enabled and the license file would contain that key which is then checked by the library at runtime, but they don't want to have a server (make an web app/service or buy off the shelf). They want it to work if the device doesn't have internet connection. Then I thought about Google Play store beta testing, where one can apparently can select the users the beta/alpha test will be available to, but that's user-wide it seems not device wide. And I'm not that familiar with that store and what one can do in it.

Has anyone ever done something like this recently with Android? Am I missing any option that may be available?

Thank you.

FAT32 SHAMER
Aug 16, 2012



Any fingerprinting methods have been largely deprecated and using them requires a permission in your manifest that will get the app blocked from the App Store iirc

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

FAT32 SHAMER posted:

Any fingerprinting methods have been largely deprecated and using them requires a permission in your manifest that will get the app blocked from the App Store iirc

Pretty much this. It's been a long time since I had to consider this but this was the "official" way to do it and basically doesn't work on devices higher than 29. It looks like if they can make their app the official SMS app for the device they may be able to query it but that's quite the hack.

It's likely that there's some dumb native layer fingerprinting that can be done but ultimately this is a technical solution for a legal problem. The play store option may be your best bet ultimately.

FAT32 SHAMER
Aug 16, 2012



You could do like google services does and have google_services.json and a key in your gradle for licensing needs, for demos anyways

Twerk from Home
Jan 17, 2009

This avatar brought to you by the 'save our dead gay forums' foundation.
Has anyone has a successful React Native experience on Android? Can I pick your brain for some best practices?

React Native on Android seems to be second class citizen to iOS. Our performance is terrible, binaries are huge, and our app is tiny and barely does anything yet. When I dug into things a little bit, it looks like RN ships the Safari JS runtime with it, so that your'e always running your Javascript on JavaScript Core, Apple's Safari engine. There's an alternative JS engine available, but it's Facebook's own science project, and doesn't work with Firebase yet, which kills a ton of apps, including ours. https://reactnative.dev/docs/hermes

Anybody have good or bad things to say about React Native?

Edit: With a large number of UI elements, apparently JavaScriptCore eats about 1GB of RAM to what V8 can do in ~100MB: https://medium.com/walmartglobaltech/react-native-memory-profiling-jsc-vs-v8-vs-hermes-1626949a653b

Twerk from Home fucked around with this message at 16:15 on Oct 8, 2020

FAT32 SHAMER
Aug 16, 2012



Iirc Facebook is tearing RN out of their mobile codebases and the companies in my area (automotive) that used it are going all in on native development

It sucks poo poo for everything larger than PoCs or fart apps

Twerk from Home
Jan 17, 2009

This avatar brought to you by the 'save our dead gay forums' foundation.

FAT32 SHAMER posted:

Iirc Facebook is tearing RN out of their mobile codebases and the companies in my area (automotive) that used it are going all in on native development

It sucks poo poo for everything larger than PoCs or fart apps

The counterpoint to this is that Microsoft seems to be all-in on React Native for mobile apps, and a lot of these work pretty well, even! https://appfigures.com/resources/insights/microsoft-goes-all-in-on-react-native

PokeJoe
Aug 24, 2004

hail cgatan


Most of the native devs I know hate react. my last job tried to build an app with it and it took the team twice as long to make a shittier app with fewer features than it's native equivalent

E: the team is approaching 3 years of dev to replace a native app that was built in 10 months lol

PokeJoe fucked around with this message at 18:20 on Oct 8, 2020

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
I'm porting a game and it's basically young-age-appropriate but I want to add achievement support via GPG down the line, and docs say GPG needs to be age-gated or something in that case. Supposedly GPG itself is age-gated though, so I don't get it. I haven't actually looked at the GPG SDK at all yet, but trying to figure out what I'm getting in to. Anyone know what I actually need to do here and what the UI flow has to look like?

Glimm
Jul 27, 2005

Time is only gonna pass you by

FAT32 SHAMER posted:

Iirc Facebook is tearing RN out of their mobile codebases and the companies in my area (automotive) that used it are going all in on native development

It sucks poo poo for everything larger than PoCs or fart apps

I haven’t tried to use it personally in awhile but compared to the work I’ve done in SwiftUI and seen in Compose the past few months RN can be sunsetted now. It’s just awful. Flutter is better and it’s written in Dart.

brand engager
Mar 23, 2011

Anyone have experience with the Compose library in jetpack? It looks like their version of swiftUI view building but I don't know how complete it is.

FAT32 SHAMER
Aug 16, 2012



brand engager posted:

Anyone have experience with the Compose library in jetpack? It looks like their version of swiftUI view building but I don't know how complete it is.

it isn't very complete yet, but it's extremely promising and the moment it's stable and fully released we are planning on tearing all xmls that we possibly can out to replace it

brand engager
Mar 23, 2011

FAT32 SHAMER posted:

it isn't very complete yet, but it's extremely promising and the moment it's stable and fully released we are planning on tearing all xmls that we possibly can out to replace it

Does it work with the databinding stuff since you need to have a <layout> tag at the root for databinding to generate the class?

FAT32 SHAMER
Aug 16, 2012



brand engager posted:

Does it work with the databinding stuff since you need to have a <layout> tag at the root for databinding to generate the class?

i believe databinding exists solely to prevent bullshit npe's from occurring with xmls by generating classes that call findViewById for you to statically reference, so whatever the name of the view you declare it as in compose is what you reference in your fragment logic and it ~just works~

*i haven't played with more recent versions of compose so this may have changed in the last 3 months

FAT32 SHAMER
Aug 16, 2012



i should also add that we flat-out ignored databinding and just stuck to using synthetics correctly since it seemed to be a bullshit makework lib that solved a problem that developers shouldnt have unless they don't understand the lifecycle of a fragment/activity

this also turned out to somewhat bite us in the arse since now we have to refactor to Viewbinding since synthetics are being deprecated and then we'll be refactoring again when compose is stable :v:

brand engager
Mar 23, 2011

FAT32 SHAMER posted:

i believe databinding exists solely to prevent bullshit npe's from occurring with xmls by generating classes that call findViewById for you to statically reference, so whatever the name of the view you declare it as in compose is what you reference in your fragment logic and it ~just works~

*i haven't played with more recent versions of compose so this may have changed in the last 3 months

I think i'll be stuck with xml since we're already redoing our UI. I've been working only on our ios app since late last year, so getting moved back to android has been a mess. UI stuff is already slower than any other work, and I'm also trying to remember how to do anything in android.

FAT32 SHAMER
Aug 16, 2012



brand engager posted:

I think i'll be stuck with xml since we're already redoing our UI. I've been working only on our ios app since late last year, so getting moved back to android has been a mess. UI stuff is already slower than any other work, and I'm also trying to remember how to do anything in android.

eh you could be stuck with worse things, like asynctask :v:

xml works fine as long as you use it right, but as evidenced by the plethora of ways you can reference a view from a layout xml it can get real messy real quick if you dont keep track of things.

i would be willing to bet that for most cases, refactoring into compose won't be a good value-add unless you're rewriting that screen anyways. any time you need to change a view you could rewrite it in compose and eventually replace all of them instead of spending a few weeks doing them all

brand engager
Mar 23, 2011

We're also supposed to change to a model-viewmodel-view architecture so I'll need to figure that out too

Glimm
Jul 27, 2005

Time is only gonna pass you by

One of the Compose devs streams regularly on Twitch (he's live right now) and answers questions and such:
https://twitch.tv/intelligibabble

My company is building a large new product with Compose. Some growing pains here and there but in a lot of ways it feels better than SwiftUI (according to the folks who've looked at both anyway, I've only been using SwiftUI so far).

ringu0
Feb 24, 2013


I'm having the weirdest problem after upgrading to Android Studio 4.1 on a Windows 10 laptop.

One of the layouts displays app version, which is stored in a module-level build.gradle file. The version string is propagated to the XML layout file using this technique followed to the letter: https://stackoverflow.com/a/29525111

When I use the bundled gradle plugin version 4.1.0, I'm getting this error:
code:
Execution failed for task ':app:processDebugVerboseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     app\src\main\res\layout\fragment_login.xml:17: AAPT: error: resource string/versionName (aka com.appname.vdev:string/versionName) not found.
When I downgrade to 4.0.2 or 4.0.1, everything builds without errors.

I checked the generated file mentioned in the StackOverflow post, and sure enough when I use 4.1.0, the file is not there, and the build fails. When I downgrade, the file pops up with the expected content, and everything works.

What's weird is the other developer working on this project doesn't experience this issue. They're on AS 4.1, too, but they run it on a Mac (I'm on a Win10 machine).

What I tried so far:
- clean, rebuild, invalidate and restart;
- manually remove "build" folder;
- fiddle with various combinations of gradle and gradle plugin versions;
- completely nuking Android Studio and its folders, including ".gradle" and ".android" in my user profile.

Nothing helped. What else can I try?

brand engager
Mar 23, 2011

Do you need the 4.1 plugin for something?

ringu0
Feb 24, 2013


I really don't. My question is I guess if it's a feature going forward, or a glitch, and there will be a workaround or a fix.

brand engager
Mar 23, 2011

I didn't see any mention of it in the release notes. Anyways the trick to gradle is to use the oldest version that both has the features you need and isn't busted, and just dont update it until you absolutely have to.

FAT32 SHAMER
Aug 16, 2012



brand engager posted:

I didn't see any mention of it in the release notes. Anyways the trick to gradle is to use the oldest version that both has the features you need and isn't busted, and just dont update it until you absolutely have to.

ringu0
Feb 24, 2013


brand engager posted:

I didn't see any mention of it in the release notes. Anyways the trick to gradle is to use the oldest version that both has the features you need and isn't busted, and just dont update it until you absolutely have to.

That's a solid advice, thank you.

They did fiddle with versionName in the context of app manifest and BuildConfig; it's the only somewhat relevant thing I've found: https://developer.android.com/studio/releases/gradle-plugin#behavior_changes

Vesi
Jan 12, 2005

pikachu looking at?
I have a similar setup and it works with 4.1.0, maybe if you don't have variants with different versionnames you can just have it under defaultconfig like I have:

code:
    defaultConfig {
        ...
        resValue "string", "app_version", "${versionName}"
    }

Ola
Jul 19, 2004

Now this is a real horror you can make Halloween decorations of.

https://twitter.com/sandofsky/status/1321593104298725376

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
But that's tetris for iPhone, not Android :smugdog:

Ola
Jul 19, 2004

Oh god it was meant to go in the coding horrors thread. It's me, in the horror.

Edward IV
Jan 15, 2006

Anyone here have any insight on implementing WebRTC in an app? For class, we're writing a chat program that has to support voice chatting and WebRTC seemed like the best choice. We're kind of crunched on time since the due date is on Sunday so something easy to implement and integrate would be helpful. We already have a Firebase database setup for the texting portion so I'm going to use that for signalling. It seems like every resource and tutorial utilizes Javascript although most of those resources are for video chat so I don't know how appropriate that would be since we're just doing voice. I would also like to be able to support more that 2 users so I'm also looking into setting it up as a mesh network and capping the maximum number of users.

FAT32 SHAMER
Aug 16, 2012



Did you search GitHub for Java/Kotlin projects that contain “import {libraryName”?

Twerk from Home
Jan 17, 2009

This avatar brought to you by the 'save our dead gay forums' foundation.
Is okhttp still the de-facto default http client option? Is there anything else out there?

I spent the day dealing with a nasty bug caused by people trying to work around old okhttp bugs like https://github.com/square/okhttp/issues/3146 and https://github.com/square/okhttp/issues/3974, and it only reproduced on Android 9. Of course, I have test devices on android 7, 8, 10, and 11 but not 9, so it was a PITA to debug. It's crazy to me that making http requests is this fraught at this point in Android's lifecycle.

FAT32 SHAMER
Aug 16, 2012



imo it’s the only one worth using, and most networking libraries use okio for their basis anyways

Adbot
ADBOT LOVES YOU

PokeJoe
Aug 24, 2004

hail cgatan


Is there a simple way to set up a standalone emulator? My goal is to get someone non technical an emulator they can install apks on via click and drag. Im trying to figure out the command line tools but they require essentially the same android sdk and java home setup as Android studio, which I'm trying to avoid. I also don't want to use some 3rd party thing full of ads. Any suggestions?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply