NativeScript / nativescript-fresco

This repository holds the NativeScript plugin that exposes the functionality of the Fresco image library to NativeScript developers.
Apache License 2.0
53 stars 23 forks source link

Cannot read property 'AnimatedDrawable' of undefined #67

Closed Sbpace closed 6 years ago

Sbpace commented 6 years ago

I am trying to use the nativescript-fresco plugin in a nativescript 4 + angular environment.

Here is the output of my tns info ✔ Component nativescript has 4.0.1 version and is up to date. ✔ Component tns-core-modules has 4.0.0 version and is up to date. ✔ Component tns-android has 4.0.1 version and is up to date. ✔ Component tns-ios has 4.0.1 version and is up to date.

Fresco seems to be initialised correctly but as soon as I view a template which includes the app crashes with the following error: Cannot read property 'AnimatedDrawable' of undefined

package.json

{ "description": "NativeScript Application", "license": "SEE LICENSE IN ", "readme": "NativeScript Application", "repository": "", "nativescript": { "id": "org.nativescript.allsopapp", "tns-ios": { "version": "4.0.1" }, "tns-android": { "version": "4.0.1" } }, "dependencies": { "@angular/animations": "~5.2.0", "@angular/common": "~5.2.0", "@angular/compiler": "~5.2.0", "@angular/core": "~5.2.0", "@angular/forms": "~5.2.0", "@angular/http": "~5.2.0", "@angular/platform-browser": "~5.2.0", "@angular/platform-browser-dynamic": "~5.2.0", "@angular/router": "~5.2.0", "crypto-js": "^3.1.9-1", "email-validator": "^1.1.1", "md5": "^2.2.1", "moment": "^2.20.1", "nativescript-angular": "~5.2.0", "nativescript-carousel": "^3.1.1", "nativescript-downloadmanager": "^0.1.0", "nativescript-fresco": "^3.0.7", "nativescript-google-maps-sdk": "^2.6.0", "nativescript-imagepicker": "^4.0.1", "nativescript-iqkeyboardmanager": "^1.2.0", "nativescript-pdf-view": "^2.0.1", "nativescript-photoviewer": "^1.3.0", "nativescript-pro-ui": "^3.3.0", "nativescript-social-share": "^1.5.0", "nativescript-svg": "^1.3.4", "nativescript-theme-core": "~1.0.4", "numeral": "^2.0.6", "reflect-metadata": "~0.1.8", "rxjs": "~5.5.2", "tns-core-modules": "^4.0.0", "zone.js": "~0.8.2" }, "devDependencies": { "@angular/compiler-cli": "~5.2.0", "@ngtools/webpack": "~1.9.4", "babel-traverse": "6.26.0", "babel-types": "6.26.0", "babylon": "6.18.0", "copy-webpack-plugin": "~4.3.0", "css-loader": "~0.28.7", "extract-text-webpack-plugin": "~3.0.2", "lazy": "1.0.11", "nativescript-dev-typescript": "~0.6.0", "nativescript-dev-webpack": "^0.9.2", "nativescript-worker-loader": "~0.8.1", "raw-loader": "~0.5.1", "resolve-url-loader": "~2.2.1", "typescript": "~2.6.2", "uglifyjs-webpack-plugin": "~1.1.6", "webpack": "~3.10.0", "webpack-bundle-analyzer": "^2.9.1", "webpack-sources": "~1.1.0" } }

DimitarTachev commented 6 years ago

Hi @Sbpace,

This error is thrown when the native Android dependency of the plugin is not installed.

I suggest you try removing your platforms folder and making a clean app build. If you are still getting the same error, please send us a sample application in order to reproduce and fix it on our side.

AradhanaR commented 6 years ago

I am getting same error "Cannot read property 'AnimatedDrawable' of undefined". System.err: Calling js method onCreateView failed System.err: System.err: TypeError: Cannot read property 'AnimatedDrawable' of undefined System.err: File: "file:///data/data/com.proxible.innercircle/files/app/tns_modules/nativescript-fresco/nativescript-fresco.js, line: 96, column: 47 System.err: System.err: StackTrace: System.err: Frame: function:'initializeAnimatedImage', file:'file:///data/data/com.proxible.innercircle/files/app/tns_modules/nativescript-fresco/nativescript-fresco.js', line: 96, column: 48 System.err: Frame: function:'FrescoDrawee.createNativeView', file:'file:///data/data/com.proxible.innercircle/files/app/tns_modules/nativescript-fresco/nativescript-fresco.js', line: 203, column: 9 System.err: Frame: function:'ViewBase._setupUI', file:'file:///data/data/com.proxible.innercircle/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 492, column: 35 System.err: Frame: function:'', file:'file:///data/data/com.proxible.innercircle/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 534, column: 19 System.err: Frame: function:'LayoutBaseCommon.eachChildView', file:'file:///data/data/com.proxible.innercircle/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js', line: 125, column: 26 System.err: Frame: function:'ViewCommon.eachChild', file:'file:///data/data/com.proxible.innercircle/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 868, column: 14 System.err: Frame: function:'ViewBase._setupUI', file:'file:///data/data/com.proxible.innercircle/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 533, column: 14 System.err: Frame: function:'', file:'file:///data/data/com.proxible.innercircle/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 534, column: 19 System.err: Frame: function:'ContentView.eachChildView', file:'file:///data/data/com.proxible.innercircle/files/app/tns_modules/tns-core-modules/ui/content-view/content-view.js', line: 70, column: 13 System.err: Frame: function:'PageBase.eachChildView', file:'file:///data/data/com.proxible.innercircle/files/app/tns_modules/tns-core-modules/ui/page/page-common.js', line: 120, column: 40 System.err: Frame: function:'ViewCommon.eachChild', file:'file:///data/data/com.proxible.innercircle/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js', line: 868, column: 14 System.err: Frame: function:'ViewBase._setupUI', file:'file:///data/data/com.proxible.innercircle/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 533, column: 14 System.err: Frame: function:'ViewBase._addViewCore', file:'file:///data/data/com.proxible.innercircle/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 431, column: 18 System.err: Frame: function:'ViewBase._addView', file:'file:///data/data/com.proxible.innercircle/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 420, column: 14 System.err: Frame: function:'FragmentCallbacksImplementation.onCreateView', file:'file:///data/data/com.proxible.innercircle/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 588, column: 24 System.err: Frame: function:'FragmentClass.onCreateView', file:'file:///data/data/com.proxible.innercircle/files/app/tns_modules/tns-core-modules/ui/frame/fragment.js', line: 27, column: 38 System.err: System.err: at com.tns.Runtime.callJSMethodNative(Native Method) System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101) System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:983) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:970) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:954) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:946) System.err: at com.tns.FragmentClass.onCreateV

I have tried as suggested above but its not working! Please provide fix asap.

VladimirAmiorkov commented 6 years ago

Hi @AradhanaR ,

Can you share more details about your application with us, like the package.json? Are you sure that there is no other NativeScript plugin inside your project that may also use the native Android Fresco library. It is possible in such scenarios that the other plugin overrides the native library with a newer version that does not have the now experimental AnimatedDrawable (the current version of nativescript-fresco uses a pre-release version of the native Fresco library).

We are in the process of publishing a new major version 4.0.0 of the nativescript-fresco plugin that completely removes any usage of the mention AnimatedDrawable and uses the latest official native library. We expect this version to be release as soon as possible, you can follow the plugin for more information in our marketplace here.