-
Notifications
You must be signed in to change notification settings - Fork 12
nativescript v2.4 + android support v25.1.0 ClassNotFoundError #16
Comments
A small after-prepare hook (as a better workaround) if anyone is interested;
|
Changing this plugin code is not solving the problem (runtime errors) the solution I used was to fix the line at the bindings.txt file (android.support => com.android.support) Probably not an issue with this plugin rather with ASBG. Can close this one |
You have an issue for sure but I'm fairly certain it's nothing with the plugin. I just created a fresh app from |
Hi, Thanks for checking this out. What version of android support library did you used? |
I have everything up to date in the sdk manager. |
well dang, nevermind there is an update available, on a different laptop 😄 . Let me try one more time and see. |
Alright I did encounter an error after just updating the libs and building. Not the exact error you had but an error when running. To fix I did the following:
Something must be messed up in the project you have, I would try cleaning the platform remove/add and then do a complete build. Uninstall the old .apk from the device and then run the new build and see if that cleans it up. |
Already tried all that =/ (including the plugging remove/add) The thing is fixing the file manually does solve the problem, from the other hand no other dependency is needed the 'com.' prefix so this indeed strange... I will try on a template project like you did and will see what the different. Thanks again! |
Well, after the exact project was build successfully on an other computer I tries several thing - the thing that got that fixed was removing SDK platform 7.1.1 (API 25). @bradmartin did you had this installed when trying to reproduce? |
If that's the latest available then yes I did. |
@Pip3r4o Ref: NativeScript/android#665 @SBD580 @bradmartin I can confirm this plugin is causing this error. It's been driving me nuts for the past 3 days 🤕 lol To rule out project discrepancies, every time I added a plugin I ran this npm script ( "scripts": {
"init": "npm install && tns install",
"a": "tns livesync android --watch",
"ra": "sudo rm -rf hooks && sudo rm -rf node_modules && sudo rm -rf platforms && sleep 1 && npm run init && npm run au && npm run a",
"au": "adb uninstall org.nativescript.wtf"
},
|
Good info Rob. I hit the error but then got it working as I mentioned so it was hit or miss for me. Nonetheless hopefully Pete knows something. |
[UPDATE]What I've tried so far:
So far commenting the |
@bradmartin comment back in a couple of hours to remind me this is an issue :D |
@Pip3r4o ping |
@Pip3r4o bump 🍔 |
On a vacation atm, but I inspected the thing yesterday and couls not
reproduce the crash. Any additional information is appreciated
…On Dec 29, 2016 7:59 PM, "Rob Laverty" ***@***.***> wrote:
@Pip3r4o <https://github.com/Pip3r4o> bump 🍔
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#16 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJ-u2no4P6BhXSChXDZbrKJVD-OAbHgDks5rM_UDgaJpZM4LP70N>
.
|
@Pip3r4o Get off github right meow...! go enjoy vacation 🏖 👙 🍺 🍻 🌞 |
@Pip3r4o any word on this by any chance? |
@roblav96 @bradmartin I ran a couple of tests today and these are my findings:
I ran the tests on Geny emulators API 23 and API 19, as well as on a device API 19 And this is what my Android SDK manager looks like: I try to have the latest build tools, support libraries and platforms installed. My guess is that the design library v. 22.x.x's Snackbar.Callback refers to some internals that aren't present in any of the other support libraries of similar or close version. I'd suggest you try hardcoding the dependency to |
@bradmartin I am facing the same issue, ( I firstly thought it was a tns core issue ), then I went through the exact same debugging pipe as @roblav96 , which led me to nativescript-snackbar. I'm trying to find a correct fix, I will write it down as sool as I can. A real fix would be very welcome. |
@echap can you say what the latest installed android SDK versions you have installed and which versions your project uses (normally becomes evident from the build log) |
@bradmartin @echap @roblav96 I inspected the jars used in a project compiled with As I suggested earlier - you can hardcode the version to 23+ or check if a lower one is used and output a warning message that the plugin won't work properly (at all) on android. As for the original error reported in the post, I am unable to reproduce it, the static binding generator, when debugged, does not output
|
@Pip3r4o @bradmartin @roblav96 You propose to hardcore version 23 in
This fix seems to work for me Edit : It dos not work that much 👎 |
@echap any output or crash log? Edit: Good news, I got the build-time crash! |
@Pip3r4o just let me know what you find out and a good fix for the plugin going forward to avoid issues 👍 |
@Pip3r4o Still the same issue as I initially reported here. |
Since I did not have any efficient fix, I downgraded my sdk for the moment. |
While this hasn't been building properly, I whipped up a snackbar for Android and iOS if you want it. //
import * as application from 'application'
import { EventData } from 'data/observable'
import { Color } from 'color'
import { Page } from 'ui/page'
import { topmost } from 'ui/frame'
import { View } from 'ui/core/view'
import { StackLayout } from 'ui/layouts/stack-layout'
import { AbsoluteLayout } from 'ui/layouts/absolute-layout'
import { GestureTypes, GestureEventData } from 'ui/gestures'
import { action, ActionOptions } from 'ui/dialogs'
import { DockLayout } from 'ui/layouts/dock-layout'
import { GridLayout } from 'ui/layouts/grid-layout'
import { LayoutBase } from 'ui/layouts/layout-base'
import { device, screen, isIOS, isAndroid } from 'platform'
import { isNullOrUndefined } from 'utils/types'
import { Animation, AnimationDefinition } from 'ui/animation'
import { AnimationCurve } from 'ui/enums'
import { Button } from 'ui/button'
import { Label } from 'ui/label'
export interface SnackBarOptions {
text: string
timeout?: number
button?: string
align?: 'top' | 'bottom'
textColor?: Color
backgroundColor?: Color
buttonColor?: Color
buttonBackgroundColor?: Color
}
export class SnackBar {
private _opts: SnackBarOptions
get opts() {
return this._opts
}
set opts(opts) {
this._opts = opts
}
private _resolve
get resolve() {
return this._resolve
}
set resolve(resolve) {
this._resolve = resolve
}
private _reject
get reject() {
return this._reject
}
set reject(reject) {
this._reject = reject
}
private _timeout: number
build(opts: SnackBarOptions): Promise<boolean> {
let page = topmost().currentPage
if (!page) {
return new Promise(function(resolve, reject) {
setTimeout(function() {
resolve(opts)
}, 1000)
}).then(() => this.build(opts))
}
let theOpts = {
text: 'SnackBar',
timeout: 3000,
align: 'bottom',
textColor: new Color('white'),
backgroundColor: new Color('#323232'),
buttonColor: new Color('white'),
buttonBackgroundColor: new Color('#585858'),
} as SnackBarOptions
Object.keys(opts).forEach(function(key) {
theOpts[key] = opts[key]
})
this.opts = theOpts
let layout = new DockLayout()
layout.backgroundColor = this.opts.backgroundColor
layout.verticalAlignment = this.opts.align
layout.opacity = 0
layout.padding = '15 30'
let button: Button
if (this.opts.button) {
let wrapper = new StackLayout()
wrapper.verticalAlignment = 'center'
button = new Button()
button.text = this.opts.button
button.color = this.opts.buttonColor
button.backgroundColor = this.opts.buttonBackgroundColor
if (application.ios) {
button.style.padding = '5 10'
}
wrapper.addChild(button)
DockLayout.setDock(wrapper, 'right')
layout.addChild(wrapper)
}
let label = new Label()
label.text = this.opts.text
label.color = this.opts.textColor
label.verticalAlignment = 'center'
label.textWrap = true
label.fontSize = 16
label.marginRight = 10
layout.addChild(label)
let t = 1
if (application.android) {
page._addView(layout, (<any>page)._childrenCount)
if (button) {
button.on(<any>GestureTypes.tap, (args: EventData) => {
button.off(GestureTypes.tap)
clearTimeout(this._timeout)
this.destroy(layout, true)
})
}
let aparent: android.view.ViewGroup = layout.parent.android
let root: android.view.ViewGroup = <any>aparent.getRootView()
let delta = 0
let which = (this.opts.align == 'top') ? 'statusBarBackground' : 'navigationBarBackground'
// console.log('screen.mainScreen.heightPixels', screen.mainScreen.heightPixels)
let i: number, len: number = root.getChildCount()
for (i = 0; i < len; i++) {
let child = root.getChildAt(i)
// console.log('child.toString()', child.toString())
// console.log('child.getHeight()', child.getHeight())
if (child.toString().indexOf(which) != -1) {
delta = child.getHeight()
break
}
}
delta = SnackBar.getMeasure(delta)
if (this.opts.align == 'top') {
layout.marginTop = delta
} else {
layout.marginBottom = delta
}
let alayout: android.view.ViewGroup = layout.android
alayout.setClickable(true)
aparent.removeView(alayout)
if (SnackBar._keyboard != 0) {
// console.log('delta', delta)
let params = alayout.getLayoutParams() as org.nativescript.widgets.CommonLayoutParams
// console.log('SnackBar._keyboard', SnackBar._keyboard)
// console.log('params.bottomMargin', params.bottomMargin)
params.bottomMargin = params.bottomMargin + SnackBar._keyboard + 120 // + 144 // + 72 // + (delta * screen.mainScreen.scale)
// console.log('params.bottomMargin', params.bottomMargin)
alayout.setLayoutParams(params)
}
root.addView(alayout, root.getChildCount() - 2)
}
if (application.ios) {
t = 50
let base: LayoutBase = <any>page.layoutView
if (this.opts.align == 'top') {
let uiutils = require('ui/utils')
layout.paddingTop = layout.paddingTop + uiutils.ios.getStatusBarHeight()
}
base.addChild(layout)
setTimeout(() => {
let iview: UIView = layout.ios
base.removeChild(layout)
let rootCtrl: UINavigationController = application.ios.rootController
rootCtrl.view.addSubview(iview)
if (this.opts.align == 'bottom') {
let y = screen.mainScreen.heightDIPs - iview.frame.size.height - SnackBar._keyboard
iview.frame = CGRectMake(iview.frame.origin.x, y, iview.frame.size.width, iview.frame.size.height)
}
if (button) {
button.onLoaded()
button.on(<any>GestureTypes.tap, (args: EventData) => {
button.off(GestureTypes.tap)
clearTimeout(this._timeout)
this.destroy(layout, true)
})
}
}, 25)
}
setTimeout(() => {
let height = SnackBar.getMeasure(layout.getMeasuredHeight()) / 2
layout.translateY = (this.opts.align == 'top') ? -height : height
layout.animate({
opacity: 1,
translate: { x: 0, y: 0 },
curve: AnimationCurve.easeOut,
duration: SnackBar.getAnimDuration(150),
})
}, t)
this._timeout = setTimeout(() => {
if (button) {
button.off(<any>GestureTypes.touch)
}
this.destroy(layout)
}, this.opts.timeout)
return new Promise((resolve, reject) => {
this._resolve = resolve
this._reject = reject
})
}
private destroy(layout: DockLayout, action?: boolean) {
let height = SnackBar.getMeasure(layout.getMeasuredHeight()) / 2
let y = (this.opts.align == 'top') ? -height : height
layout.animate({
opacity: 0,
translate: { x: 0, y },
curve: AnimationCurve.easeOut,
duration: SnackBar.getAnimDuration(150),
}).then(() => {
if (application.android) {
let aview: android.view.ViewGroup = layout.android
let root: android.view.ViewGroup = <any>aview.getRootView()
root.removeView(aview)
}
if (application.ios) {
let iview: UIView = layout.ios
iview.removeFromSuperview()
}
this.resolve(action)
}).catch((error) => {
this.reject(error)
})
}
private static getMeasure(dim: number): number {
return Math.round((application.android) ? dim / screen.mainScreen.scale : dim)
}
private static getAnimDuration(t: number): number {
return (application.android) ? t * 1.5 : t
}
private static _keyboard: number = 0
private static _t: number = null
public static _initKeyboard() {
let top = topmost()
if (
(isAndroid == true && (!top || !top.android || !top.android.rootViewGroup))
||
(isIOS == true && !application.ios)
) {
clearTimeout(this._t)
this._t = setTimeout(() => SnackBar._initKeyboard(), 100)
return
}
clearTimeout(this._t)
if (application.android) {
let group = top.android.rootViewGroup as android.view.ViewGroup
group.getViewTreeObserver().addOnGlobalLayoutListener(new android.view.ViewTreeObserver.OnGlobalLayoutListener({
onGlobalLayout: function() {
let pageHeight = topmost().currentPage.getMeasuredHeight()
if (!isFinite(this.maxHeight)) {
this.maxHeight = pageHeight
}
let shown = pageHeight != this.maxHeight
if (this.showing != shown) {
this.showing = shown
SnackBar._keyboard = this.maxHeight - pageHeight
}
}
}))
}
if (application.ios) {
application.ios.addNotificationObserver(UIKeyboardWillChangeFrameNotification, function(notification: NSNotification) {
let rect: CGRect = notification.userInfo.valueForKey(UIKeyboardFrameEndUserInfoKey).CGRectValue
SnackBar._keyboard = (screen.mainScreen.heightDIPs == rect.origin.y) ? 0 : rect.size.height
})
}
}
}
application.on(application.launchEvent, () => SnackBar._initKeyboard()) Also respects keyboard size and position. Usage:return new SnackBar().build({
text: '😎 Wanna rate us?',
button: 'YES!',
timeout: 5000,
}).then(function(result) {
if (result == true) {
return buildRatePrompt()
}
}) |
@bradmartin @roblav96 now that I managed to reliably reproduce the crash, I found the cause - a little bug in the static-binding-generator related to java inner class name strings. Pushing the fix in master shortly. Snackbars should still be used with design library 23+ in their current state. Thanks for all your help in dealing with this bug! |
@roblav96 that's very nice, I might use that for the iOS version to get rid of the cocoapod dependency. If you have time to make a PR for it that's cool too, if not no worries 👍 |
@Pip3r4o No problem! <3 tns @bradmartin Ye for sure! |
@roblav96 any update on this ? :) |
@echap use the latest android runtime ( |
I'm having the same error at
|
Hi,
Just try to upgrade the application to latest nativescript, seems like the plugin break the static binding generation. I'm not sure if this is an issue of the plugin or of the nativescript runtime.
I'm getting this exception:
After hours of trying to figure out what the problem is I tried to remove the plugin and the build did well.
I have found a workaround, changing "android.support" to "com.android.support" (either in this plugin sourcecode, or at the bindings.txt of the ASBG).
Shay
The text was updated successfully, but these errors were encountered: