W/System.err error on calls to getThumbDrawable on Android API level < 21
See original GitHub issueThis is the second time I am reporting this bug. The first report #4471 got closed without proper consideration.
I am getting a cryptic error from the runtime, even though everything works as expected. The device is on API 19. The same test runs fine on API 23 and 25, so I am assuming this is for API levels < 21.
I am using a widget from the compat v7 library to get a better looking βmaterialβ widget on the screen. The library has versions and compileSdkVersion API levels, which might be confusing people into thinking that it requires these API levels at run time; it does not. NS currently targets compileSdkVersion 25 and buildToolsVersion β25.0.2β, so everything should work.
I have made a simple native Android test project, and these methods work fine without any runtime issues.
I have reduced this from a real application to a simple Placeholder component just to demonstrate the problem on a smallest possible setup. Note that even the error is shown in the logs, the function does return the drawable, and I can color it. I get the same message when I call getTrackDrawable(), but not when I call getTextOn().
The test app is available at https://github.com/sserdyuk/ns-bug-4471 The native proof-of-concept app is at https://github.com/sserdyuk/ns-bug-4471-android.git
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
<Page.actionBar>
<ActionBar title="My App" icon="" class="action-bar">
</ActionBar>
</Page.actionBar>
<StackLayout>
<Placeholder loaded="loaded" creatingView="creatingView"/>
</StackLayout>
</Page>
import { EventData } from 'data/observable';
import { Page } from 'ui/page';
import { Color } from 'color';
import { CreateViewEventData } from "ui/placeholder";
export function creatingView(args: CreateViewEventData) {
console.log("Creating view");
const nativeView = new android.support.v7.widget.SwitchCompat(args.context);
// const nativeView = new android.widget.Switch(args.context);
args.view = nativeView;
}
export function loaded(args) {
console.log("Loaded");
let color = new Color("#FF0000");
args.object.nativeView.getThumbDrawable().setColorFilter(color.android, android.graphics.PorterDuff.Mode.SRC_IN);
}
Successfully synced application org.nativescript.ThumbDrawable on device LGVS450PP3a1a880.
JS: Creating view
JS: Loaded
W/System.err( 9576): at com.tns.Runtime.callJSMethodNative(Native Method)
W/System.err( 9576): at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
W/System.err( 9576): at com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
W/System.err( 9576): at com.tns.Runtime.callJSMethod(Runtime.java:912)
W/System.err( 9576): at com.tns.Runtime.callJSMethod(Runtime.java:896)
W/System.err( 9576): at com.tns.Runtime.callJSMethod(Runtime.java:888)
W/System.err( 9576): at com.tns.Runtime.callJSMethodNative(Native Method)
W/System.err( 9576): at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
W/System.err( 9576): at com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
W/System.err( 9576): at com.tns.Runtime.callJSMethod(Runtime.java:912)
W/System.err( 9576): at com.tns.Runtime.callJSMethod(Runtime.java:896)
W/System.err( 9576): at com.tns.Runtime.callJSMethod(Runtime.java:888)
$ tns info
All NativeScript components versions information
ββββββββββββββββββββ¬ββββββββββββββββββ¬βββββββββββββββββ¬ββββββββββββββββ
β Component β Current version β Latest version β Information β
β nativescript β 3.1.1 β 3.1.1 β Up to date β
β tns-core-modules β 3.1.0 β 3.1.0 β Up to date β
β tns-android β 3.1.1 β 3.1.1 β Up to date β
β tns-ios β β 3.1.0 β Not installed β
ββββββββββββββββββββ΄ββββββββββββββββββ΄βββββββββββββββββ΄ββββββββββββββββ
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (6 by maintainers)

Top Related StackOverflow Question
@sserdyuk according to your original post - βI am getting a cryptic error from the runtime, even though everything works as expected. The device is on API 19.β - everything works as expected, and there are no crashes, despite the short stacktrace you are seeing. What I am trying to make clear here is that, despite the fact that you are seeing the βerrorβ, it is harmless, and should not disturb your appβs execution.
Assigning colors directly to the drawable instance of the switch as shown in my code sample works as expected, and changes the button color when the switch is toggled, yes, I see the error the first time in the console, however the application continues functioning. Tested on device API 19.
As for your concerns with the compileSdkVersion - the CLI will automatically pick the highest android platform you have downloaded, and will use that one, along with the support libraries of the highest matching major version. (e.g. your highest installed api level is
platform-25, and your extra support libraries installed from the sdk are of version25.3.1, those versions will be passed on to the gradle build script.) Having said that, it should be unnecessary to explicitly set the dependency versions in yourapp.gradle, and the very fact that the application doesnβt crash while creating an instance of theandroid/support/v7/widget/SwitchCompatclass indicates that your support libraries are of a version high enough that supports it.What device are you testing the code samples on? Iβve tested locally on Geny 19, a Nexus 4 (API 19), Android Studio 19 emulator, the message in the console appeared almost consistently for all 3 devices, but the switch button had its color changed.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.