Android 27: LogLogcatRule and RuleLoggingUtils replacement? - android

How does one test log output for Android classes. Prior to Android 27 LogLogcatRule and related classes like RuleLoggingUtils served these purposes, but it appears they were removed.

Related

Why Android 7 devices show error messages related to native shared libraries

My Android app is using 3rd party library that uses native libraries.
It is built with targetSdkVersion 21.
When running my app on Android 7 phones (in my example, LG G20), users start getting a visible error message upon process initialization.
The error message screenshot is attached.
When running the same app on Android 5.x and 6.x, there is no error shown to the user, although there is still a matching warning message in the log. Log message looks like:
library "/data/app/org.iotivity.base.examples.simpleclient-1/lib/arm/libocstack-jni.so" has invalid DT_NEEDED entry "./obj/local/armeabi/libocprovision.so"
ךibrary "/data/app/org.iotivity.base.examples.simpleclient-1/lib/arm/libocstack-jni.so" has invalid DT_NEEDED entry "./obj/local/armeabi/libocpmapi.so"
So it looks likes Android 7 "decides" to show to the end user a warning which is kept for the log only in previous versions.
I would appreciate:
1. Ideas on how the error message can be suppressed
2. Hints on what is the right solution for the issue (this is a 3rd party code, but I may try to tweak the build process)
Thanks in advance
Max

Android TimePicker methods being stubs

(I am unsure if everyone else faces this problem, but I do)
I am accessing setHour(int) and getHour() (and the minute's getter and setter) of android.widget.TimePicker - IntelliJ doesn't complain of their inexistence, but when i run the program from my phone (or emulator) it crashes and i see an error log of java.lang.NoSuchMethodError android.widget.TimePicker.getHour. (Other minute/hour getter/setter include).
I tried accessing the definition for the TimePicker class (Ctrl+B) and I realised every method contained a line: throw RuntimeException("Stub");
So what's this; How can I move on?
IntelliJ doesn't complain of their inexistence
That is because you are compiling against API Level 23.
but when i run the program from my phone (or emulator) it crashes and i see an error log of java.lang.NoSuchMethodError android.widget.TimePicker.getHour
That is because getHour() was added in API Level 23, and your device or emulator is running Android 5.2 or below.
I don't use IntelliJ, but it should be complaining about your build. In Eclipse and Android Studio, you would get an error from Lint indicating that you are calling a method (getHour()) that exists in your compileSdkVersion (23) but does not exist in your minSdkVersion (whatever you have that set to, as the oldest API level that you are willing to support).
I tried accessing the definition for the TimePicker class (Ctrl+B) and I realised every method contained a line: throw RuntimeException("Stub")
That is because it is decompiling the android.jar that is in your compile-time classpath, which consists purely of stub implementations to satisfy the javac compiler. At runtime, your process' VM will have a version of that JAR that has actual implementations.
How can I move on?
Probably stop calling getHour(), unless you can get away with doing so only on Android 6.0+ devices.

Google play configuration to push different APKs for different Android versions

At the moment we have two app versions in production:
as you may see, we have version 1420028 for API levels 19+ and 218 for API levels 7+
Now we've prepared a build for API levels from 16 to 18
We see following error after uploading that build to the GP:
Frankly I can't get what following error message says, it looks grammatically incomplete to me.
This configuration cannot be published for the following reason(s):
It is forbidden that a device upgrading from API levels in range 16-18 to API levels in range 19+ should downgrade from version 1420029 to version 218, which would occur when
Screen layouts containing any of [small#mdpi, small#hdpi, small#xhdpi, small#xxhdpi, normal#mdpi, normal#hdpi, normal#xhdpi, normal#xxhdpi, large#mdpi, large#hdpi, large#xhdpi, large#xxhdpi] and
Features containing all of [android.hardware.LOCATION, android.hardware.location.GPS, android.hardware.screen.PORTRAIT, android.hardware.TOUCHSCREEN, android.hardware.WIFI].
Any way to achieve configuration explained above? Is it a Google Play bug or just me getting something wrong?

Compatibility for Java library methods that require Android API level 9?

Some Java library methods like DecimalFormat.setRoundingMode have a #since 1.6 entry in their documentation.
/**
...
* #since 1.6
*/
public void setRoundingMode(RoundingMode roundingMode) {
...
}
When I tried to use this method compiled under Android 4.2.2 and JDK 1.6 with my android:minSdkVersion set to 7 as shown,
myNumberFormat.setRoundingMode(RoundingMode.DOWN);
Android Lint underlined setRoundingMode in red for me and told me that
Call requires API level 9 (current min is 7): java.text.NumberFormat#setRoundingMode
How and why can the Android API restrict which Java library methods I can and cannot use? I cleaned my project and the Lint error disappeared. My project compiled with no errors and ran on a device running Android 2.2.3 (API 8).
My program crashed with:
05-09 11:32:38.436: E/AndroidRuntime(2074): Caused by: java.lang.NoSuchMethodError: java.text.NumberFormat.setRoundingMode
The Android documentation confirms that setRoundingMode, copySign, and others were added in API level 9. Does that mean that devices running Android OS level 8 and below are specifically compiled/built with JDK 1.5?
And I can understand that. But is it impossible for the Android Support Library (or anything else) to allow us to use these methods?
Related to Rounding Half Up with Decimal Format in Android

Problems with build.xml when using the Android ADK to communicate with an Arduino Mega ADK

So a few days ago I got my hands on an Arduino Mega ADK board, and the last couple of nights I have been setting up my development environment, getting to grips with the tools etc. The tools and libraries all work fine, for example I can get a program written in the Processing IDE to compile and run on an Asus Eee Pad Transformer TF101 running Android 4.03. But when I get it to try to compile and run one of the pre-written examples, it gives me a compiler error:
Android SDK Tools Revision 20
Installed at C:\NVPACK\android-sdk-windows
Project Type: Application
Project Target: Android 2.3.3
API level: 10
Library dependencies:
No Libraries
API<=15: Adding annotations.jar to the classpath.
Merging AndroidManifest files into one.
Manifest merger disabled. Using project manifest only.
No AIDL files to compile.
No RenderScript files to compile.
Generating resource IDs...
Generating BuildConfig class.
BUILD FAILED
C:\NVPACK\android-sdk-windows\tools\ant\build.xml:680: The following error occurred while executing this line:
C:\NVPACK\android-sdk-windows\tools\ant\build.xml:693: Compile failed; see the compiler error output for details.
Total time: 7 seconds
And that's all the console seems to output as well, which is rather frustrating! As far as I'm aware all of my SDK versions, tools and plugins are all up to date. I've tried this using a Linux partition I have on my hard drive and it produces the same error message, although it mentions a problem with the package com.Android.future.UsbAccessory. Given what I've seen, it seems that the problem is with the tools, either my directory structure doesn't match up to what the correct setup is, or something else is wrong :S. If anyone has had similar problems, some help would be smashing! (For the record, my setup was done using the instructions on the Arduino website, although I already had the Android SDK tools installed).
Will Scott-Jackson
It sounds like your haven't added in the support library to your project and/or you haven't downloaded it into your Android SDK.
The ADK1 demokit app targets API Level 10 (Android 2.3.3); That means you need to use the support libraries in your project and that's why the compiler is complaining about level 10 library dependencies not being available. The support libraries are a separate download in the SDK Manager, so you might not have them in your development environment.
In Android API Level 12 and higher, the USB Accessory protocol was added to the framework API, so there are two different ways to use the accessory protocol. So, you don't have to use the support libraries if you are targeting Honeycomb and higher versions, but you'll have to update the demokit app code to make this work.
Hope this helps.
So I've double checked my setup and started working on a project I had in mind, it seems to import the libraries appropriately. So far so good, but when I input:
ArduinoAdkUsb arduino;
void setup() {
arduino = new ArduinoAdkUsb(this);
//Other UI initialisation etc.
}
I get this error:
##name## ##version## by ##author##
FATAL EXCEPTION: Animation Thread
java.lang.NoClassDefFoundError: com.android.future.usb.UsbManager
at cc.arduino.ADKCommunication.<init>(Unknown Source)
at cc.arduino.ArduinoAdkUsb.<init>(Unknown Source)
at
processing.android.test.sketch_120730a.
sketch_120730a.setup(sketch_120730a.java:48)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:856)
After the app has been built and installed onto the Android tablet I am using. Any thoughts how I can over come this? From what I can tell, this has no problem finding com.android.future.usb.manager to compile and install the program, but once it tries to run it can find it.
Based on this tutorial from http://stream.tellart.com/controlling-arduino-with-android/
In the examples RGB_Arduino the name, version and author variables are set at the top of the sketch.
Try adding in this section of code at the top of your arduino sketch just underneath the library imports
// accessory descriptor. It's how Arduino identifies itself to Android
char applicationName[] = "Mega_ADK"; // the app on your phone
char accessoryName[] = "Mega_ADK"; // your Arduino board
char companyName[] = "Freeware";
// make up anything you want for these
char versionNumber[] = "1.0";
char serialNumber[] = "1";
char url[] = "http://labs.arduino.cc/adk/"; // the URL of your app online
//initialize the accessory:
AndroidAccessory usb(companyName, applicationName,
accessoryName,versionNumber,url,serialNumber);

Categories

Resources