react-native-photo-view icon indicating copy to clipboard operation
react-native-photo-view copied to clipboard

Build issue on Android

Open pvanliefland opened this issue 9 years ago • 12 comments

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 :)

pvanliefland avatar Oct 04 '16 15:10 pvanliefland

@pvanliefland Which version of ReactNative are you on?

zfedoran avatar Oct 05 '16 16:10 zfedoran

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",

rwillemsandroid avatar Oct 07 '16 08:10 rwillemsandroid

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

waleedarshad-vf avatar Oct 15 '16 08:10 waleedarshad-vf

@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 :)

waleedarshad-vf avatar Oct 18 '16 07:10 waleedarshad-vf

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

pvanliefland avatar Oct 31 '16 12:10 pvanliefland

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?

tinajohnson avatar Nov 07 '16 06:11 tinajohnson

@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?

sakshityagi avatar Nov 28 '16 08:11 sakshityagi

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.

px-amaac avatar Mar 10 '17 00:03 px-amaac

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 ..

u-kan avatar Apr 29 '17 07:04 u-kan

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.

omairvaiyani avatar Mar 15 '18 13:03 omairvaiyani

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"

gansri avatar Jun 14 '18 09:06 gansri

me to

aspidvip avatar Aug 06 '18 07:08 aspidvip