In our javafx mobile application, we are using Okhttp3 4.9.1 for http requests. One of our developers told me that even if we specify Okhttp as an external dependency, in android device it will only use the Okhttp bundled with android. So I just wanted to verify it and tried to print the okhttp versions at the runtime like this one. It didn't work (ClassNotFoundExceptions). So, my question is,
Do javafx mobile apps use 'okhttp bundled with android' or the one that we specified as a dependency?
How to get the version of 'okhttp' bundled with android in javafx mobile application?
If you bundle OkHttp in your app it will use that version instead of the built in Android version. They differ in package also, so you can't easily mistake them. I don't think you can directly use https://android.googlesource.com/platform/external/okhttp/+/master/repackaged/okhttp/src/main/java/com/android/okhttp/OkHttpClient.java in your app, but I'm not certain.
You should be able to use okhttp3.OkHttp.VERSION directly, but it has a bug that it's const value and so inlined at compile time. So you can read this using reflection, assuming proguard isn't applied and moving the classes.
You can also look at the default user agent in an interceptor which uses this version field.
Class.forName("okhttp3.internal.Version") won't work because it's an internal detail and has since moved. It got moved in 4.7.0 https://github.com/square/okhttp/commit/72cb889c867481c578bce663d3ea0d92e648fcac#diff-6e62984ccabc6dc7bb9bbda58768b4af28bf789f6415d09c2d89de4387ecf816
Related
I need to compare my app's version with the latest version from PlayStore/AppStore. I used react-native-version-check but it's not working properly for my app.
Is there a way to call directly to the stores which will contain the version in the response? (using react native)
I implemented your scenario using a mixture of react-native-config and react-native-appstore-version-checker.
The installed app version I used react-native-config to create an app version variable that I retrieve with: Config.REACT_APP_VERSION
For the app store version, I used the react-native-appstore-version-checker module. The installation instructions worked great.
For my use-case, I wanted to do something different if the upgrade was a major or minor, so I then split the two app versions and did major/minor/build comparisons.
I have built a project with all Firebase features including Firebase Performance Plugin. Now we are trying to make it as Library, While trying to convert from Application to Library we are facing an issue from Firebase as
ERROR: FirebasePerformancePlugin must only be used with Android application projects. Need to apply the 'com.android.application' plugin with this plugin.
May I know the reason why I am facing this issue. I am excepting a quick reply from the Team.
Thanks in advance
As the error suggests, Firebase Performance Monitoring is not supported for libraries, only apps. You currently can't use the product to collect performance information for you library if it gets integrated into other apps. You can only use it for monitor the behavior of a specific app that's added to your Firebase project.
If this is not what you want, you can file a feature request with Firebase support. Though, for this request, I suspect nothing will happen in the short term.
I have a project using an old version of google play services that I need to keep otherwise it would need to be heavily rewritten. Now I have added a new library that uses a newer version of google play services and I get a duplicate class error.
How can I force android studio to use the newer version of google play services in the library for the library but also be able to use the older version in my app?
Unfortunately, this isn't possible. The classes for your app and the library are combined to form your APK, so you can only have one version of a given library. You could force it to use one of the two versions (for example, something like this), but based on your statement that it would need to be extensively rewritten, I assume that the two versions are not API compatible.
There are utilities like Jar Jar Links that can solve this in some cases, but (especially based on the embedded proguard rules, which reference classes found via reflection) I'd be surprised if it worked in the case of something as complex as Google Play Services, which is likely depending on its class names remaining unchanged.
Recently I've been working on integrating a GRPC API in a size sensitive android app. The API only had a couple of Unary calls. I noticed that the resulting APK had io.grpc (613KB) & io.opencensus (178.9KB) which was further reduced to 387.2KB and 39.4KB respectively using Proguard. I noticed that Proguard was able to remove many streaming call related classes/methods from the APK. However, I noticed that the app already had com.google.protobuf package, which I suspect is from something like Firebase SDK.
If Firebase SDK imported com.google.protobuf, why didn't it need io.grpc for transport? Does it use something else?
The protobuf protocol is used by some Firebase SDKs as part of their internal communications. The first one that comes to mind is Firebase Analytics, but there are others too.
The Cloud Firestore SDK in Firebase uses grpc as part of its transport protocol. If you're not using Cloud Firestore then the grpc library will not be included as far as I know.
To ensure that unused methods are removed, be sure to use ProGuard as part of your release build.
I am working on an Android project that needs three versions of the same application (for example: Admin version, User version, Custom version). I have already created a Google-App-Engine endpoints backend in the User version of the app. I have to start working on the other two versions now and I want to connect these two versions to the backend I created in the User version. I have tried finding the answer to this on the internet but I haven't been successful in doing so. I believe it is possible to connect the other versions of the app to the backend by importing the endpoint libraries from the cloud into the android projects somehow but I haven't been able to find a way to do so yet.
I did come across a way to import an existing module in the Android project but if I do that, then any time when I make changes to the backend in the "User" version, I will have to re-import the module in other versions of the app. I am so lost and confused.
Any help will be deeply appreciated.
Thank you!
After you build your cloud module there is a YOUR_CLOUD_MODULE_NAME-android-endpoints.jar under YOUR_CLOUD_MODULE_NAME/build/libs.
You can copy this jar into libs directory of all your android projects that need to interact with your back-end.
This approach makes it really easy to get out of sync though. After every change to back-end you would need to update the .jar in all dependent modules.
Are all of your Android applications in the same Android Studio project? If so I think you might be able to just add
compile project(path: ':{yourBackendModuleGoesHere}', configuration: 'android-endpoints')
to each of your Android apps build.gradle.
You could probably also make it work even if your backend is in a separate AndroidStudio project as long as they're part of the same gradle build.