nativescript-community / ui-material-components

Monorepo that contains all of the NativeScript Material Design plugins.
https://nativescript-community.github.io/ui-material-components/
Apache License 2.0
216 stars 80 forks source link

Calling js method onCreateView failed #438

Closed stumpykilo closed 1 year ago

stumpykilo commented 1 year ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

StackTrace: createNativeView(file:///data/data/myapp/files/app/vendor.js:697:24) at _setupUI(file:///data/data/myapp/files/app/vendor.js:19010:31) at (file:///data/data/myapp/files/app/vendor.js:19054:19) at eachChildView(file:///data/data/myapp/files/app/vendor.js:29958:28) at eachChild(file:///data/data/myapp/files/app/vendor.js:21484:14) at _setupUI(file:///data/data/myapp/files/app/vendor.js:19053:14) at (file:///data/data/myapp/files/app/vendor.js:19054:19) at eachChildView(file:///data/data/myapp/files/app/vendor.js:29958:28) at eachChild(file:///data/data/myapp/files/app/vendor.js:21484:14) at _setupUI(file:///data/data/myapp/files/app/vendor.js:19053:14) at (file:///data/data/myapp/files/app/vendor.js:19054:19) at eachChildView(file:///data/data/myapp/files/app/vendor.js:29958:28) at eachChild(file:///data/data/myapp/files/app/vendor.js:21484:14) at _setupUI(file:///data/data/myapp/files/app/vendor.js:19053:14) at (file:///data/data/myapp/files/app/vendor.js:19054:19) at eachChildView(file:///data/data/myapp/files/app/vendor.js:16205:13) at eachChildView(file:///data/data/myapp/files/app/vendor.js:31945:15) at eachChild(file:///data/data/myapp/files/app/vendor.js:21484:14) at _setupUI(file:///data/data/myapp/files/app/vendor.js:19053:14) at _addViewCore(file:///data/data/myapp/files/app/vendor.js:18903:18) at _addView(file:///data/data/myapp/files/app/vendor.js:18892:14) at onCreateView(file:///data/data/myapp/files/app/vendor.js:25761:19) at onCreateView(file:///data/data/myapp/files/app/vendor.js:23539:40) at com.tns.Runtime.callJSMethodNative(Native Method) at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1302) at com.tns.Runtime.callJSMethodImpl(Runtime.java:1188) at com.tns.Runtime.callJSMethod(Runtime.java:1175) at com.tns.Runtime.callJSMethod(Runtime.java:1153) at com.tns.Runtime.callJSMethod(Runtime.java:1149) at com.tns.FragmentClass.onCreateView(FragmentClass.java:55) at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3104) at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:524) at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261) at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1899) at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1817) at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1760) at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:547) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7872) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 3: TypedValue{t=0x2/d=0x7f0300d0 a=7}, theme={InheritanceMap=[id=0x7f0f0008myapp:style/AppTheme, id=0x7f0f000bmyapp:style/AppThemeBase29, id=0x7f0f000amyapp:style/AppThemeBase21, id=0x7f0f0009myapp:style/AppThemeBase, id=0x7f0f0219myapp:style/Theme.AppCompat.Light.NoActionBar, id=0x7f0f0213myapp:style/Theme.AppCompat.Light, id=0x7f0f0052myapp:style/Base.Theme.AppCompat.Light, id=0x7f0f00admyapp:style/Base.V28.Theme.AppCompat.Light, id=0x7f0f00aamyapp:style/Base.V26.Theme.AppCompat.Light, id=0x7f0f00a4myapp:style/Base.V23.Theme.AppCompat.Light, id=0x7f0f00a2myapp:style/Base.V22.Theme.AppCompat.Light, id=0x7f0f0098myapp:style/Base.V21.Theme.AppCompat.Light, id=0x7f0f00b0myapp:style/Base.V7.Theme.AppCompat.Light, id=0x7f0f012emyapp:style/Platform.AppCompat.Light, id=0x7f0f0139myapp:style/Platform.V25.AppCompat.Light, id=0x1030241android:style/Theme.Material.Light.NoActionBar, id=0x1030237android:style/Theme.Material.Light, id=0x103000candroid:style/Theme.Light, id=0x1030005android:style/Theme], Themes=[myapp:style/AppTheme, forced, myapp:style/LaunchScreenTheme, forced, myapp:style/Theme.AppCompat.Empty, forced, android:style/Theme.DeviceDefault.Light.DarkActionBar, forced]} at android.content.res.TypedArray.getColorStateList(TypedArray.java:600) at com.google.android.material.resources.MaterialResources.getColorStateList(MaterialResources.java:81) at com.google.android.material.resources.TextAppearance.(TextAppearance.java:86) at com.google.android.material.resources.MaterialResources.getTextAppearance(MaterialResources.java:145) at com.google.android.material.tooltip.TooltipDrawable.loadFromAttributes(TooltipDrawable.java:158) at com.google.android.material.tooltip.TooltipDrawable.createFromAttributes(TooltipDrawable.java:119) at com.google.android.material.slider.BaseSlider.parseLabelDrawable(BaseSlider.java:502) at com.google.android.material.slider.BaseSlider.access$000(BaseSlider.java:195) at com.google.android.material.slider.BaseSlider$1.createTooltipDrawable(BaseSlider.java:378) at com.google.android.material.slider.BaseSlider.createLabelPool(BaseSlider.java:756) at com.google.android.material.slider.BaseSlider.setValuesInternal(BaseSlider.java:737) at com.google.android.material.slider.BaseSlider.setValues(BaseSlider.java:693) at com.google.android.material.slider.BaseSlider.processAttributes(BaseSlider.java:421) at com.google.android.material.slider.BaseSlider.(BaseSlider.java:384) at com.google.android.material.slider.Slider.(Slider.java:71) at com.google.android.material.slider.Slider.(Slider.java:67) at com.google.android.material.slider.Slider.(Slider.java:63) ... 22 more


In our component we are using the slider like this:
                <MDSlider :value="myValue" minValue="0" :maxValue="maxValue-1" @valueChange="onValueChange"
                    stepSize="1" elevation="40"
                    rippleColor="white" trackFillColor="black" trackBackgroundColor="white" thumbColor="white" 
                />
farfromrefug commented 1 year ago

@stumpykilo tried with your sample and it works fine here. Did you set the android theme to material? i think the error is somewhere there

stumpykilo commented 1 year ago

@farfromrefug thank you for your quick response! I did not, can you provide a Vue sample or point me to documentation on how to do that?

farfromrefug commented 1 year ago

@stumpykilo https://github.com/nativescript-community/ui-material-components/blob/bdebd9caaade717c1f2a32d5b1d80f28ed8e2e83/demo-snippets/App_Resources/Android/src/main/res/values/styles.xml#L22

vallemar commented 1 year ago

Hi @stumpykilo, how did you make axios work? he believed that versions higher than 1.x didn't work

stumpykilo commented 1 year ago

@farfromrefug that change to the styles.xml resolved the error but am now getting Cannot read property 'nativeView' of undefined upon the initial load of the component.

@vallemar that is actually an old dependency that we are not using any longer. But when we did it worked with no problems. Here is some of the old code we had in production that was hitting an Azure Function that was using GraphQL:

import axios from "axios";

export const myApi = axios.create({
     baseURL: <api_url>
});

var request = {
    query: `query {
        getSeries {
            id,
            name
        }
    }`,
    variables: {}
};

var response = await myApi.post("Series", request);

response.data.data.getSeries.forEach(element => 
    series.push({
        id: element.seriesId,
        name: element.name
}));
farfromrefug commented 1 year ago

@stumpykilo please share the error stack

stumpykilo commented 1 year ago

@farfromrefug for the first error that you resolved it was showing that by default but for this other error I don't see anything. Is there a way to turn that on?

stumpykilo commented 1 year ago

I can get it to work if I use v-if="myValue" but not sure why that is required for Android and not iOS.

vallemar commented 1 year ago

Puedo hacer que funcione si lo uso, v-if="myValue"pero no estoy seguro de por qué es necesario para Android y no para iOS.

how do you have myValue declared? it looks like sometime is null or undefined, i don't think it will work with a non-numeric value

stumpykilo commented 1 year ago
        data: () => {
            return {
                myValue: 0
            };
        },
stumpykilo commented 1 year ago

I think it is related to my @valueChange="onValueChange". It must be firing when the MDSlider is initialized and something is not ready.

stumpykilo commented 1 year ago

Confirmed that is what it was. This issue is resolved. Thank y'all for the help!

stumpykilo commented 1 year ago

Well, I may have spoken too soon.

Now when I try and Archive in XCode for iOS I am getting Framework not found MDFInternationalization. I see this warning: ld: warning: directory not found for option '-F/Users/me/Library/Developer/Xcode/DerivedData/MyApp-foivrqltrnczhecwsrrqmitobbov/Build/Products/Debug-iphoneos/MaterialComponents'.

Do I need to do something similar as what I had to do for Android styles.xml?

vallemar commented 1 year ago

@stumpykilo What file are you opening in xcode to open the project?

Note: this conversation would be much faster on discord https://nativescript.org/discord

stumpykilo commented 1 year ago

@vallemar thank you for your help. Closing again.