alwx / react-native-photo-view

Pinch-to-zoom view for React Native (both iOS and Android)
MIT License
815 stars 434 forks source link

Build issue on Android #23

Open pvanliefland opened 7 years ago

pvanliefland commented 7 years ago

Hello,

After letting Android Studio update various things (SDK, SDK tools etc...), my app does not build anymore.

The error I get is

/Users/my-user/Reactnative/my-project/node_modules/react-native-photo-view/android/src/main/java/com/reactnative/photoview/ImageEvent.java:37: error: no suitable constructor found for Event(int)
    super(viewId);
    ^
    constructor Event.Event() is not applicable
      (actual and formal argument lists differ in length)
    constructor Event.Event(int,long) is not applicable
      (actual and formal argument lists differ in length)

Looks like the class constructor of the Event class extended by ImageEvent now expects two arguments.

As a workaround, I did this

public ImageEvent(int viewId, @ImageEventType int eventType) {
    super(viewId, eventType);
    mEventType = eventType;
    mMap = null;
  }

Of course, I have no idea about what I'm doing there but at least my app compiles :)

zfedoran commented 7 years ago

@pvanliefland Which version of ReactNative are you on?

rwillemsandroid commented 7 years ago

I've run into the same issue running the following version(s):

"react": "15.2.1",
"react-native": "0.31.0",
"react-native-photo-view": "1.2.0",
waleedarshad-vf commented 7 years ago

I am using react native 0.27.2 @pvanliefland your solutions works no doubt :)

waleedarshad-vf commented 7 years ago

@pvanliefland If i add these changes directly in node modules, the next time anyone install same library on my project he will not get any changes, what is the right way to add changes so next time the person who install this library will also get changes that we added manually. @rwillemsandroid if you can help that would be more appreciated as well :)

pvanliefland commented 7 years ago

@zfedoran I'm having the issue with React Native 0.35.0

tinajohnson commented 7 years ago

Hello,

I faced the same errors as @pvanliefland while compiling my react-native project but they were resolved by using the workaround he has provided. But now that I try to zoom by pinching the image, my app crashes.

The error I get is:

java.lang.NoSuchMethodError: No direct method <init>(IJ)V in class Lcom/facebook/react/uimanager/events/Event; or its super classes (declaration of 'com.facebook.react.uimanager.events.Event' appears in /data/data/com.reportbee.parent/files/instant-run/dex/slice-com.facebook.react-react-native-0.34.1_0b6c20ec3410a20a85e40c61dad9510f0e6dff75-classes.dex)
                                                                          at com.reactnative.photoview.ImageEvent.<init>(ImageEvent.java:0)
                                                                          at com.reactnative.photoview.PhotoView$4.onScaleChange(PhotoView.java:190)
                                                                          at me.relex.photodraweeview.Attacher.onScale(Attacher.java:328)

My PhotoView component is:

<View style={{ height: heightChange, marginTop: 15, padding: 10, alignItems: 'flex-start' }}>
          {
            this.props.url
            ?

              <PhotoView
                source={{uri: this.props.url}}
                minimumZoomScale={0.5}
                maximumZoomScale={2}
                style={{ height: heightChange / 2, width: width - 20, resizeMode: 'contain' }} />
            :
            <View />
          }
</View>

Is the error because there is no constructor matching Event(viewId, eventType)? Is there a workaround for this error?

sakshityagi commented 7 years ago

@pvanliefland were you able to fix the issue(not be making changes in node module ofcourse)? I am also getting same errors while building my android app.

Is it react-native version issue?

px-amaac commented 7 years ago

I know this is a few months old now but This seems to be a react-native version issue. It is not really an issue with this library or RN. Basically upgrade to better versions. The issue is caused by this PR PR

That PR was a response to this one from RN

When i had this issue it was actually an issue with how i was retrieving react-native library. My library was defaulting to react-native:0.20.1 from here instead of using the local one in my node_modules folder.

That version of RN does not have the change from above that was added I believe in 0.38. My problem was solved after i found this Essentially i added my local RN maven repo to the buildscript section instead of allprojects. That little detail is easily missed in the docs and will cause this library to fail to build.

u-kan commented 7 years ago

my project caused exactly same issue #23

And this solution fix it. So this promlem should be reconsidered

my react native version is 0.43.3

and this pull request, which is closed without mergerd, solve my problem.

I think this issue should be rediscussed now ..

omairvaiyani commented 6 years ago

If anyone stumbles upon this issue, I boiled the issue to package.json -> "react-native":"...tz"

My boilerplate (ignite) was using a direct .tz link for "react-native", rather than saying "v0.54.0" (or what ever the latest version is when you read this). This change along with a clean npm install allowed me to build successfully.

gansri commented 6 years ago

i am having similar react native build problems:, Any help to fix this problem will be very helpful.

:app:compileDebugJavaWithJavacE:\chewy\chewy-reactjs\android\app\src\main\java\com\users\MainActivity.java:3: error: package com.facebook.react does not exist import com.facebook.react.ReactActivity; ^ here are my version: "react": "16.3.1", "react-native": "0.55.3", "react-native-camera": "^1.1.4", "react-native-elements": "^0.19.1", "react-native-fbsdk": "^0.7.0", "react-native-popup-dialog": "^0.11.46", "react-native-qrcode-scanner": "^1.0.1", "react-native-slider": "^0.11.0", "react-native-swipe-recognizer": "^0.2.0", "react-native-swiper": "^1.5.13", "react-navigation": "^1.5.11"

aspidvip commented 6 years ago

me to