Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classes using fields from compileSdk > Platform Sdk on device cause crash when extended in TS #626

Closed
petekanev opened this issue Nov 14, 2016 · 1 comment
Assignees
Milestone

Comments

@petekanev
Copy link
Contributor

petekanev commented Nov 14, 2016

Instantiating, or causing the instantiation of a class that extends another native (Android) class in TypeScript can cause a crash if the class being extended exposes public members not present on the device that runs the application.

Suppose we extend a class that introduces a new static member with Platform SDK 24, then compile the application with compileSdk 24/25, and finally install the application on a device running on API Level 23. If we attempt to create an instance of our custom class the application will crash.

Android:

class AccessibilityService {
   ...
   static int GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN = 7; // available with SDK 24+
   ...
}

TypeScript:

declare class MyAccessibilityService extends AccessibilityService { ... }

The ts_helpers script will iterate through all public properties of the class being extended, some of which may not be available on the device that runs the app, (when extending a native class) thus causing the crash.

As a workaround we may add an explicit check to make sure that the traversed fields are not specific to the android Sdk

@alexrainman
Copy link

@Pip3r4o installing android@next solved my problem 👍

@Plamen5kov Plamen5kov assigned Plamen5kov and petekanev and unassigned Plamen5kov Dec 7, 2016
@petekanev petekanev added this to the 2.5.0-RC milestone Dec 19, 2016
@pkoleva pkoleva removed the done label Jan 5, 2017
@pkoleva pkoleva closed this as completed Jan 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants