question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

W/System.err error on calls to getThumbDrawable on Android API level < 21

See original GitHub issue

This 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:closed
  • Created 6 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
petekanevcommented, Jul 12, 2017

@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 version 25.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 your app.gradle, and the very fact that the application doesn’t crash while creating an instance of the android/support/v7/widget/SwitchCompat class 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.

0reactions
lock[bot]commented, Aug 28, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix Expected Android API level 21+ but was 19 in Android
In android api 21+ is not error, but below api 21 show me force close error. ApiClient class codes: class ApiClient constructor(private valΒ ......
Read more >
Behavior changes: apps targeting API 29+ - Android Developers
Android 10 includes updated system behavior changes that may affect your app. ... These changes, which affect apps that target API level 29...
Read more >
Behavior changes: apps targeting API level 28+
Android 9 (API level 28) introduces a number of changes to the Android system. The following behavior changes apply exclusively to apps thatΒ ......
Read more >
CallLog.Calls - Android Developers
Calls #BLOCK_REASON , set as the default value when a call was not blocked by a CallScreeningService or any other system call blocking...
Read more >
<uses-sdk> | Android Developers
Lets you express an application's compatibility with one or more versions of the Android platform, by means of an API Level integer.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found