Android Wear: Google Play services out of date. Requires x but found y - android-studio

I have an Android Wear app that I'm trying to migrate from Eclipse to Android Studio. It's working (more or less) on my LG G Watch, but when run on my Moto 360 I get the following message in logcat:
GooglePlayServicesUtil﹕ Google Play services out of date. Requires 6111000 but found 5091534
followed immediately by Connection to Google API client has failed. Running on the emulator gives a similar message:
GooglePlayServicesUtil﹕ Google Play services out of date. Requires 6111500 but found 5077534
It strikes me as odd that the Requires version is slightly different in each case, but there you are.
I've been through the similar questions here on SO, and the answers usually boil down to ensuring that the module's Gradle dependencies are using play-services-wearable rather than just play-services. I've checked this and it appears to be correct; here's the relevant section from my build.gradle file:
dependencies {
compile project(':wearableCommon')
compile 'com.google.android.support:wearable:+'
compile 'com.google.android.gms:play-services-wearable:+'
}
Note that wearableCommon is a library of my own, containing code I'm using in several wearable projects, and it doesn't use GMS.
I'm particularly bothered by the fact that this works on one device but not another. If I didn't have the 360 in-house, I might well have released this code after testing it on my G Watch. I would have then been in the position of trying to debug this in the wild, while simultaneously doing damage control for hundreds of angry 360 owners.

Easiest "fix":
Set your play-services-wearable to specifically look for 5.0.77
compile 'com.google.android.gms:play-services-wearable:5.0.77'
More info:
https://plus.google.com/u/0/101581283591300788111/posts/5bHfmjtvQ6R
I literally had this exact same problem. Wayne is trying to help me out with it. Join the discussion if you like.

The latest version of Google Play Services was rolled out to Android Wear devices recently. The latest SDK update for play-services-wearable requires that your wearable is updated, which is shown in the error message that you report. Make sure you have the latest companion app installed on your phone, and it will install the update to your wearable as well. Make sure that you have your wearable paired with your phone, otherwise it will not be able to update the wearable!
If you have your wearable paired with your phone, these things will automatically update and there should be not be a problem.
I would not recommend hard coding your build.gradle to 5.0.77, because then you will never update to use the new APIs for Play Services.

Related

How to use HttpClient in android studio app?

unfortunately this question was closed however it is spot on. Let me go through the steps as I am reproducing a legacy app issue that uses httpclient so switching is not an option YET (6 months out maybe).
create android studio app
try to use Httpclient and as he shows in the post above it is in red
I try to add this line in build.gradle to bring it in as a work around(even though core android also brings it in)
implementation 'org.apache.httpcomponents:httpclient:4.5.13'
Then I get this error in android studio
`httpclient` defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for `httpclient` use `HttpUrlConnection` or `okhttp` instead), or repackaging the library using something like `jarjar`.
Ok, so I am using the wrong version so I run build scan and I see this so I bring this one in instead of the other version (android studio now sees HttpClient and can import it at this point)
I still get the same error though about conflicting android libs.
QUESTION: How do I fix the red in my legacy project and not have this error either?
My best bet seems to ignore the error. Will I have issues that I am not seeing though in the future?

Using flutter mobile packages in flutter web

I am using flutter web and I want to use some packages that are available for the mobile in the web version of flutter. The pubspec of flutter web look a bit different from that of flutter mobile but this is not the real problem. What I am concerned about is that is it possible to add the packages availble for mobile into that of the web. If yes, what is the proper way to do so?
This is not currently possible (as of June 2019) for any package which is dependent on the mobile OS. The reason for this is that the plugins on mobile use platform channels to communicate with platform-dependent code implementations for Android and iOS written in java/kotlin for android or objc/swift for iOS.
The only way those packages would ever work on the web is if a web-specific implementation were written for them which I assume would either use an emscripten-compiled library or more likely some sort of javascript bridge to call the relevant browser APIs.
From the flutter for web readme:
flutter_web does not have a plugin system yet. Temporarily, we provide access to dart:html, dart:js, dart:svg, dart:indexed_db and other web libraries that give you access to the vast majority of browser APIs. However, expect that these libraries will be replaced by a different plugin API.
For any plugin that is 100% dart code, you should be able to just include it in your pubspec.yaml the same way you would in flutter - under dependencies.
yes you can by take source code packages from github and take codes inside lib file inside package and put it in your project and fix errors may happen inside files by change path import to:
import 'package:flutter_web/material.dart';
and some more changes may need to do it.
it will work 100% and so easy :)

Does Android Things Developer Preview 6.1 support Google Cast

Does NXP i.MX7D support Google Cast via Android Things?
Android Things Version: Developer Preview 6.1 which has 11.6.0 Play Services.
We need to show the UI on external displays like TV with Android Things, but the Google Cast feature does not seem to work with Chrome Cast.
To Test the code we manipulated our source code, so that it can run on Android Device; which runs perfectly fine. But when we try it on Things, it does not discover any devices to cast.
We also tried similar procedure with the Google Sample - CastRemoteDisplay-android
The above sample works on Android Devices but the same does not work on Android Things 6.1 developer preview; after making required changes to run on Things
We also tried different Play Services versions from 10.x and 11.x
We also tried to change the API level from 23 to 27
But all results the same
NOTE: I am not including any code or stack trace as I feel it is not required. But if any one demands will post the required logs
After lots of trial and research, I found out that the version of Play Services installed on Things Developer Preview 6.1 does not support it. It lacks GMS Core, because of which currently not possible.
In the mean time I'll try to search and side load OpenGapps with GMS Core, but I am not sure if it will work

Same code from support7Demos behaves different on different devices on AppCompat DayNight Mode 23.2.0

I have downloaded the Android Support 23.2.0 and imported support7Demos under directory /Android/sdk/extras/android/support/samples/Support7Demos without making any changes. After importing the necessary dependencies, it builds successfully and generate an apk. I installed the apk on Smartisan T1 with API 19. The day night mode works as expected. But it does not work on Nexus 5 with API 23.
Please be noticed that the code is from the Android official Support V7 sample, I did not make any changes at all.
The same apk installed on different devices work different.
This is the link to download the apk to check it out.
You could also check out the two videos that recorded to see the difference.
Is it a bug? And if it is a bug, is there any workaround?
To those who still wonders the answer, here it is :
It's issue with AppCompatActivity.java of support library which is fixed now.
It is the official answer quoted from the bug logged in here

Running J2me apps on Android phones

Is it possible to run J2ME apps on Android phones? If so, what is the installation procedure?
Otherwise, is it possible to convert .jad files to .apk? In this case, what is the procedure.
(I have already tested the procedure offered by netmite but it doesn't seem to work.)
Using this site http://www.netmite.com/android/srv/2.0/getapk.php you can convert your J2ME application in to Android Application. You need to just supply your .Jad & .Jar file in it and it will generate Android's executable file .apk for you.
However in it doesn't able to convert all the feature of Java ME to Android, but basics can be easily converted.
You can try phoneME, netmite j2me app runner, jblend, jbed like jeme emulators in android. For now, phoneME is the best. you can get various version of phoneME here http://davy.preuveneers.be/phoneme
You also need OI file manager to select files in phoneME.
A complete guide can be found here http://w3epic.com/run-java-apps-j2me-on-android-devices-guide/ for rest of other emulators (if you want to try).
#dennis
I got it, thanks.
MicroEmu open source project hasn't been mentioned yet, and here it goes: https://code.google.com/p/microemu/
I searched for a good JavaME emulator for Android for a long time, and finally found one. This here is what you need:
http://davy.preuveneers.be/phoneme/
No doubt the best there is for Android.
Added 15th January 2016:
Reply from the author of phoneME, Davy Preuveneers, in regards to the Android 5.0+ issue commented by Álvaro Gutiérrez:
Hi,
I am testing on a Samsung Galaxy S4 running Android 5.0.1, and the
"phoneME Advanced - Foundation Profile + MIDP FullHD Resolution" build
seems to run just fine on this device.
Also, following this thread
Position Independent Executables and Android Lollipop,
I ran:
$ readelf -l libcvm.so | grep -i "file type"
and it reports:
Elf file type is DYN (Shared object file)
So according to the website this is OK.
However, for the CDC and Foundation profiles (console like
applications), there is indeed an issue where you get this error:
"Error: only position independent executables (PIE) are supported"
However, for those 2 profile I call a native executables and redirect
the native stdout/stderr streams to Android, whereas for the MIDP dual
stack I load a library and create a complicated wrapper to get things going.
I can recompile with -fPIE and -pie options but will then end up with
binaries that are no longer backwards compatible with devices running
Android 4.0 and below. That is why I added some additional builds to my
website for Android 5+ devices:
http://davy.preuveneers.be/phoneme/?q=node/10
Best regards,
Davy

Resources