-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
NS 3.0 rc: docs needed on how to migrate NS 2.5 code using native APIs on Android and iOS? #3996
Comments
Hey @andy-tai could you please share some code that we can use to reproduce this locally? We haven't made any changes in the way native APIs are accessed so there might be something else causing the issue here. |
OK let me create a simple app to demonstrate the problem https://github.com/andy-tai/nsrc3apibug the program works fine on iOS and Android with NS 2.5. The port to NS 3.0 crashes on both Android and iOS |
Hey @andy-tai! First off, I'd like to reassure you that there are no changes in how native code marshalling works in NativeScript in the upcoming 3.0.0 release.
branch ns_3:
branch master:
Note: I deleted I didn't make any particular modifications to any of the files present in the repository, meaning package versions should be as you've left them. |
oh,,, ok... I will double check the code on my part. good to know that thing should just work when moving to NS 3.0 |
@Pip3r4o I double checked the refresh.png in the app/App_Resources/ directory and in the subdirectories of Android and iOS (as symbolic links to the copy in app/App_Resources/) and the image looks valid. (This usage works for me in NS 2.5 although I am not sure if it is officially recommended or discouraged) As seen from the web browser, https://github.com/andy-tai/nsrc3apibug/blob/master/app/App_Resources/Android/drawable-nodpi/refresh.png is a symbolic link. On Fedora Linux and Ubuntu, I was able to build iOS and Android apps with no problem, on NS 2.5 In any case, I also tried to put the real image (instead of a symbolic link) in the app/App_Resources/Android/drawable-nodpi folder and my Android app still crashes at run time (on the Android emulator). adb logcat output attached I am not sure what is the difference of my configuration from yours... so I will probably wait for the NS 3.0 release, supposely coming today? (April 26?) and try that. |
Is nothing that I've seen before. @tsonevn might have a better idea. Also - symbolic links - I don't think those work on Windows. I am worried that you may be experiencing the error mentioned above because the actual thing copied is the symlink, and not the image file. Please upload the apk produced in |
apk placed inside a zip file uploaded |
I get rid of the symbolic links in another branch ns_3_nosymbollink and on Android the behavior stays the same |
@andy-tai The APK you sent starts up on 4/4 emulator images I fired up, as well as on a physical Android API 21 device. At this point I am suspecting that the problem is with stale resources somewhere on the device. To confirm my suspicions you could create a new branch where the application has a different name. That will ensure that you won't have stale files that overwrite yours on startup. The problem has since been fixed and is expected to be shipped with 3.0 Please perform the following before running your app again.:
|
OK, I restarted the emulator with "wiping out the user data" and the app
runs fine now on the emulator. Thanks!
…On Wed, Apr 26, 2017 at 8:04 AM, Peter Kanev ***@***.***> wrote:
@andy-tai <https://github.com/andy-tai> The APK you sent starts up on 4/4
emulator images I fired up, as well as on a physical Android API 21 device.
At this point I am suspecting that the problem is with stale resources
somewhere on the device. To confirm my suspicions you could create a new
branch where the application has a different name. That will ensure that
you won't have stale files that overwrite yours on startup. The problem has
since been fixed and is expected to be shipped with 3.0
Please perform the following before running your app again.:
adb shell
cd data/local/tmp
rm -rf org.atai.rc3apibug
exit
tns run android
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3996 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE89fEDRlSekPSEt6SmhMjXOPxuksK_Cks5rz10KgaJpZM4M9_FG>
.
--
Andy Tai, [email protected], Skype: licheng.tai, Line: andy_tai, WeChat:
andytai1010
Year 2017 民國106年
自動的精神力是信仰與覺悟
自動的行為力是勞動與技能
|
Closing this as related to NativeScript/android#591 With a workaround available in the issue, and a fix coming in the following release. |
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. |
Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?
yes, none found
Tell us about the problem
Please, ensure your title is less than 63 characters long and starts with a capital
letter.
no documentation on how to migrate pre-3.0 code using native APIs (Android and iOS) to NS 3.0
Both
Please provide the following version numbers that your issue occurs with:
tns --version
to fetch it)3.0.0-rc1
node_modules/tns-core-modules/package.json
file in your project)3.0.0-rc2
"tns-android"
and"tns-ios"
properties in thepackage.json
file of your project)3.0.0-rc1
package.json
file of yourproject)
"nativescript": {
"id": "com.leeco.apollo11.NScreen.nativescript",
"tns-ios": {
"version": "3.0.0-rc.1"
},
"tns-android": {
"version": "3.0.0-rc.1"
}
},
"dependencies": {
"@angular/common": "4.0.0",
"@angular/compiler": "4.0.0",
"@angular/core": "4.0.0",
"@angular/forms": "4.0.0",
"@angular/http": "4.0.0",
"@angular/platform-browser": "4.0.0",
"@angular/platform-browser-dynamic": "4.0.0",
"@angular/router": "4.0.0",
"es6-shim": "^0.35.3",
"nativescript-angular": "^2.0.0-rc.1",
"nativescript-couchbase": "^1.0.17",
"nativescript-orientation": "^1.5.5",
"nativescript-theme-core": "~1.0.2",
"nativescript-videoplayer": "^2.4.0",
"reflect-metadata": "~0.1.8",
"rxjs": "~5.2.0",
"serializer.ts": "0.0.12",
"tns-core-modules": "^3.0.0-rc.2",
"zone.js": "~0.8.2"
},
"devDependencies": {
"babel-traverse": "6.23.1",
"babel-types": "6.23.0",
"babylon": "6.16.1",
"lazy": "1.0.11",
"nativescript-dev-android-snapshot": "^0..",
"nativescript-dev-typescript": "^0.4.2",
"tns-platform-declarations": "rc",
"typescript": "^2.2.2"
}
}
Please tell us how to recreate the issue in as much detail as possible.
I have the NS 2.5/Angular project that accesss the native platform APIs on both Android and iOS, following the documentation at
https://docs.nativescript.org/runtimes/android/marshalling/overview.html
and
https://docs.nativescript.org/runtimes/ios/marshalling/Marshalling-Overview.html
and works well. The same code builds with Nativescript 3.0 rc, following the instructions/solutions at
#3928
At the point of accessing native platform APIS from typescript, I get the error messages of
ios:
CONSOLE ERROR file:///app/tns_modules/@angular/core/./bundles/core.umd.js:1092:24: ERROR Error: Uncaught (in promise): Error: This value is not a native object.
Android:
JS: ERROR Error: Uncaught (in promise): Error: No java object found on which to call "toString" method. It is possible your Javascript object is not linked with the corresponding Java class. Try passing context(this) to the constructor function.
JS: Error: No java object found on which to call "toString" method. It is possible your Javascript object is not linked with the corresponding Java class. Try passing context(this) to the constructor function.
These indicate some interface change in the native code APIs when accessing from Javascript/Typescript. However, no existing NS 3.0 documentation shows what changes in nativescript code using natve APIs in js/ts needed to upgrade to NS 3.0
The text was updated successfully, but these errors were encountered: