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

Error com.horcrux.svg does not exist on Windows/Android #211

Closed
mihaben opened this issue Jan 2, 2017 · 16 comments
Closed

Error com.horcrux.svg does not exist on Windows/Android #211

mihaben opened this issue Jan 2, 2017 · 16 comments

Comments

@mihaben
Copy link

mihaben commented Jan 2, 2017

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"
  }
@mihaben
Copy link
Author

mihaben commented Jan 3, 2017

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
}

@joncursi
Copy link

joncursi commented Jan 9, 2017

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

@seacloud9
Copy link

seacloud9 commented Jan 9, 2017

@joncursi try:

import com.horcrux.svg.SvgPackage;

and

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

looks like they changed the name.

@magicismight
Copy link
Collaborator

The package name in android has been changed in 4.6.0, sorry about that

@joncursi
Copy link

thanks @seacloud9 !

@jorge8989
Copy link

jorge8989 commented Jan 31, 2017

@mihaben 's solution worked for me,
I'm using Windows 10 on my current project,
my dependencies are
{ "react": "~15.4.0-rc.4", "react-native": "0.40.0", "react-native-svg": "^4.4.1", }
I had to run cd android && ./gradlew clean after the changes
I also changed the Package name like @seacloud9 suggested,
So, thanks guys.

@WeIio
Copy link

WeIio commented Feb 3, 2017

change package name works for me , thx @seacloud9 !

@wkrause13
Copy link

I believe the name may have changed again.

To make this compile I needed to import
import com.horcrux.svg.RNSvgPackage;
instead of
import com.horcrux.svg.SvgPackage;

And then make the corresponding change in the package list

      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new RNSvgPackage(),
...

@anwari32
Copy link

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.

@xTMNTxRaphaelx
Copy link

xTMNTxRaphaelx commented Jul 29, 2017

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

package com.horcrux.svg does not exist.

@hlerenow
Copy link

@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

@msand msand closed this as completed Feb 21, 2018
@sujitpk-perennial
Copy link

@xTMNTxRaphaelx Have you found solution for this ?

@linuxgg
Copy link

linuxgg commented Aug 9, 2018

@Funny-dot
Copy link

@joncursi尝试:

import com.horcrux.svg.SvgPackage;

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

looks like they changed the name.

but ,I still have the same problem.
"react": "~15.4.0-rc.4",
"react-dom": "^16.1.1",
"react-native": "0.40.0",
"react-native-svg": "^4.4.1",
"react-native-svg-uri": "^1.2.3",

@Shehzad121
Copy link

check duplication of package import also face same error but on debug got import com.horcrux.svg.SvgPackage; twise

@CurtisTD
Copy link

If you're using expo, try expo install react-native-svg

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