react-native-svg: Error com.horcrux.svg does not exist on Windows/Android

Hi,

I’m trying to install the react-native-svg package but I have not been able to do it yet.

I followed the instructions in the Readme (npm install and link code), but I have the following error when I execute react-native run-android

C:\rnative-projects\memoshape\android\app\src\main\java\com\memoshape\MainApplication.java:7: error: package com.horcrux.svg does not exist
import com.horcrux.svg.RNSvgPackage;
                      ^
C:\rnative-projects\memoshape\android\app\src\main\java\com\memoshape\MainApplication.java:29: error: cannot find symbol
            new RNSvgPackage()
                ^
  symbol: class RNSvgPackage
2 errors
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

I´m developing with Windows 10.

and…

"dependencies": {
    "react": "15.4.1",
    "react-native": "0.39.2",
    "react-native-svg": "^4.4.1"
  }

Thank you for your help!

Edit:

Same problem with

"dependencies": {
    "react": "15.4.0",
    "react-native": "0.38",
    "react-native-svg": "4.4.0"
  }

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 8
  • Comments: 16

Most upvoted comments

@joncursi try:

import com.horcrux.svg.SvgPackage;

and

 return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
            new SvgPackage()
            new ReactNativeConfigPackage()
      );```

looks like they changed the name.

I found the problem, the installer was not adding the depedence in build.gradle, to fix the problem I added the compile code inside dependences{}, I also excluded the appcompat-v7 to avoid conflicts:

dependencies {
    compile(project(':react-native-svg')) {
        exclude group: "com.android.support", module: "appcompat-v7"
    }
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
}

This error is still coming to me. I have tried a lot. Someone help me please Why?

package com.horcrux.svg does not exist.

@xTMNTxRaphaelx Just do this: added the compile code inside dependences{}, I also excluded the appcompat-v7 to avoid conflicts:

dependencies { compile(project(‘:react-native-svg’)) { exclude group: “com.android.support”, module: “appcompat-v7” } compile fileTree(dir: “libs”, include: [“*.jar”]) compile “com.android.support:appcompat-v7:23.0.1” compile “com.facebook.react:react-native:+” // From node_modules } like @mihaben

I am getting this same issue on mac OS after upgrading from RN 0.39.2 -> 0.40.0. I have cleared out the cache with gradle as suggested in other issue trackers but no luck.

/Users/jcursi/Sites/joncursi/redbirdNative/android/app/src/main/java/com/redbirdnative/MainActivity.java:10: error: cannot find symbol
import com.horcrux.svg.RNSvgPackage;
                      ^
  symbol:   class RNSvgPackage
  location: package com.horcrux.svg
/Users/jcursi/Sites/joncursi/redbirdNative/android/app/src/main/java/com/redbirdnative/MainApplication.java:18: error: cannot find symbol
import com.horcrux.svg.RNSvgPackage;
                      ^
  symbol:   class RNSvgPackage
  location: package com.horcrux.svg
/Users/jcursi/Sites/joncursi/redbirdNative/android/app/src/main/java/com/redbirdnative/MainApplication.java:49: error: cannot find symbol
          new RNSvgPackage(),
              ^
  symbol: class RNSvgPackage
3 errors
:app:compileReleaseJavaWithJavac FAILED

Hello, I also found the same error like this.

MainApplication.java:27: error: cannot find symbol new RNSvgPackage() ^ symbol: class RNSvgPackage 2 errors :app:compileDebugJavaWithJavac FAILED

So I renamed several lines at the code. At first it looked like

import com.horcrux.svg.RNSvgPackage;

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

and I changed them into

import com.horcrux.svg.SvgPackage;

@Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
            new SvgPackage()
      );
    }

After that I could run react-native run-android again. I just installed the svg today so I assumed I have the latest version.