Skip to content
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

No ViewManager defined for class RNSVGGroup #135

Closed
afilp opened this issue Sep 5, 2016 · 21 comments
Closed

No ViewManager defined for class RNSVGGroup #135

afilp opened this issue Sep 5, 2016 · 21 comments

Comments

@afilp
Copy link

afilp commented Sep 5, 2016

I get the following error (red)...

"No ViewManager defined for class RNSVGGroup"

...when running my RN Android app with the react-native-svg package:

"react-native link react-native-svg"

Not sure if the problem is related to the following issuse:
When I use this...
react-native link react-native-svg

...I get this:
image

It appears the the links have been completed though.
I am using Windows 10.

Any ideas why I get the above message? Thank you.

@ezsper
Copy link

ezsper commented Sep 6, 2016

Getting the same issue, but my output didn't throw any errors whatsoever.

$ rnpm link react-native-svg
rnpm-link info Linking react-native-svg android dependency 
rnpm-link info Android module react-native-svg has been successfully linked 
rnpm-link info Linking react-native-svg ios dependency 
rnpm-link info iOS module react-native-svg has been successfully linked 

But still getting a similar error

screenshot_20160906-115854

This doesn't happen on iOS, only on the Android.

This can be verified by simply starting a new React Native project from the react-native-cli, using these dependencies and versions:

{
  "name": "AwesomeProject",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start"
  },
  "dependencies": {
    "react": "15.3.1",
    "react-native": "0.32.0",
    "react-native-svg": "^4.2.1"
  }
}

@magicismight
Copy link
Collaborator

It seems like you failed to link the native code
try

rnpm unlink react-native-svg
rnpm link react-native-svg

@ezsper
Copy link

ezsper commented Sep 6, 2016

Nop. I did what you said, but I already knew the results, still the same thing. Remember, I did this to a new project. So I can replicate this by simply starting a new project from the cli and adding react-native-svg to package.json like I showed above, and trying to use
the library on index.android.js

$ rnpm unlink react-native-svg
rnpm-link info Unlinking react-native-svg android dependency 
rnpm-link info Android module react-native-svg has been successfully unlinked 
rnpm-link info Unlinking react-native-svg ios dependency 
rnpm-link info iOS module react-native-svg has been successfully unlinked 
$ rnpm link react-native-svg
rnpm-link info Linking react-native-svg android dependency 
rnpm-link info Android module react-native-svg has been successfully linked 
rnpm-link info Linking react-native-svg ios dependency 
rnpm-link info iOS module react-native-svg has been successfully linked

@afilp
Copy link
Author

afilp commented Sep 7, 2016

If this helps (I am the OP), I also use Android (not iOS), so could it be an issue with Android? I hope this can be addressed soon as I cannot use the library at all. Thanks!

(also, the error messages in "react-native link" could be due to my Windows environment?)

@magicismight
Copy link
Collaborator

maybe duplicated with #83

@ezsper
Copy link

ezsper commented Sep 7, 2016

It doesn't seem to be the same issue, as the module is definitely been linked properly, couldn't it be an issue in 4.2.1? Could you replicate the issue with the package.json above?

@afilp
Copy link
Author

afilp commented Sep 8, 2016

@ezsper Do you use Windows? Because I also have this problem: facebook/react-native#9787 (which may be the reason for non-appropriate linking)

But: even when I manually linked everything, I still get this error message and cannot continue development. I hope someone can help, thanks!

@ezsper
Copy link

ezsper commented Sep 8, 2016

No, I'm using Mac.

@afilp
Copy link
Author

afilp commented Sep 9, 2016

@ezsper So, this is a general problem, it needs to be addressed as even with manual linking the error appears.

@darvi-sh
Copy link

darvi-sh commented Sep 9, 2016

Same problem here. Developing android in windows.

@magicismight
Copy link
Collaborator

Could you check the MainApplication.java file?
In MainApplication.java add the following import:

import com.horcrux.svg.RNSvgPackage;

and add the RNSvgPackage to the getPackages method like this:

@Override
protected List<ReactPackage> getPackages() {
    return Arrays.asList(
        ... other packages ...
        new RNSvgPackage()
    );
}

@darvi-sh
Copy link

Now it works, thanks.

But it's interesting because I've tried your suggestion in the past and I was getting a compilation error when running react-native run-android.

@magicismight
Copy link
Collaborator

I'm closing this now.
It's the native code linking problem.

@paulsoh
Copy link

paulsoh commented Feb 26, 2017

For people using react-native-svg>5.1.5 (I'm not quite sure when exactly the changes were made), note that RNSvgPackage is now changed to SvgPackage. So the proper way to add it to MainApplicatoin.java would be

import com.horcrux.svg.SvgPackage;
...
@Override
protected List<ReactPackage> getPackages() {
    return Arrays.asList(
        ... other packages ...
        new SvgPackage()
    );
}

@ShepelE
Copy link

ShepelE commented Jan 12, 2018

Thanks, paulsoh. In my case there was no 'new SvgPackage()' or 'new RNSvgPackage()' at all, so I just added 'new SvgPackage()'. Now it works

@tetogomez
Copy link

Thanks @paulsoh !!

@GANESHSHARMA1
Copy link

Can Anyone help.

I'm getting this error during the Implementation of React Navigation.
I checked all dependencies and Many YT Videos to solve this issue but didn't get any solution..

image

@YahyaNamir
Copy link

YahyaNamir commented Oct 17, 2024

Delete AVD from Android Studio and re-install the lastest phone version, it worked for me 100%🌟

@GANESHSHARMA1
Copy link

@YahyaNamir Thanks! I will try this.

@YahyaNamir
Copy link

@YahyaNamir Thanks! I will try this.

Tell me what u found when you finish!

@GANESHSHARMA1
Copy link

@YahyaNamir Thanks! I will try this.

Tell me what u found when you finish!

It's showing same error. Now I don't have any option except reset my Android studio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants