Skip to content
New issue

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

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

Already on GitHub? # to your account

Error when running on real android device #628

Closed
slavchev opened this issue Nov 15, 2016 · 1 comment
Closed

Error when running on real android device #628

slavchev opened this issue Nov 15, 2016 · 1 comment
Assignees
Labels
Milestone

Comments

@slavchev
Copy link

Moved from NativeScript/nativescript-cli#2140
related to #404

Hey,

I don't know if i'm doing something wrong, but when i try to run a very basic app on a device with :

tns livesync android --watch

Then app install and run well, but the console spam (a lot) this error, making debug very difficult :

https://gist.github.com/DavidBabel/b595ef8d3b9f5e064ae804dbf9aff5eb

My device is a serrano LTE (samsung galaxy S4 mini) running a 6.0 CyanogenMod, and here are my Nativescript components versions :

https://gist.github.com/DavidBabel/fb9283040ca891f1873f503cb6d7cd3a

Am i doing something wrong ?
Thanks.

@slavchev
Copy link
Author

Here is more info. Thanks to @thiagoa1 who provided framework.jar from Redmi 2 Pro device I found that they provided both Bundle and BaseBundle as follows:

public class BaseBundle { ... }

public final class Bundle implements Parcelable, Cloneable { ... }

This is all fine, however up to API level 20 (including) android.jar provides android.os.Bundle class only as follows:

// up to API level 20 (including)
public final class Bundle implements Parcelable, Cloneable { ... }

Starting from API level 21 android.jar provides both Bundle and BaseBundle classes as follows:

// starting from API level 21
public class BaseBundle { ... }

public final class Bundle extends BaseBundle implements Cloneable, Parcelable { ... }

So, when we generate matadata from android.jar we consider that Bundle inherits from BaseBundle which is not the case on Redmi 2 Pro (and other Xiaomi) devices. This is unusual case but I would try to handle it, cosidering the popularity of Xiaomi devices. The suggested workaround is to check if the class inheritance chain from the metadata is the same as in runtime and attach the members of the missinng class to the current availble leaf (or indirect descendant) . This heuristics will handle such breaking changes in the class inheritance chain and is a relatively easy to implement without performance hit.

/cc @calebeaires @alphmega @thiagoa1 @danieloprado

@slavchev slavchev added this to the 2.5.0-RC milestone Nov 24, 2016
slavchev pushed a commit that referenced this issue Nov 28, 2016
Android API level 21 introduces class hierarchy change. The base class of
android.os.Bundle is changed from java.lang.Object to
android.os.BaseBundle and some of its methods are hoisted to the base
class. However, on some devices like Xiaomi Redmi BaseBundle is not super
class of Bundle as it is in android.jar from which we generate the
metadata. This causes JNI error when trying to call any of the hoisted
methods.
slavchev pushed a commit that referenced this issue Nov 28, 2016
Android API level 21 introduces class hierarchy change. The base class of
android.os.Bundle is changed from java.lang.Object to
android.os.BaseBundle and some of its methods are hoisted to the base
class. However, on some devices like Xiaomi Redmi BaseBundle is not super
class of Bundle as it is in android.jar from which we generate the
metadata. This causes JNI error when trying to call any of the hoisted
methods.
slavchev pushed a commit that referenced this issue Nov 28, 2016
@pkoleva pkoleva closed this as completed Jan 5, 2017
@pkoleva pkoleva removed the done label Jan 5, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants