alwx / react-native-photo-view

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

Photoview empty on android with red border #16

Open logileifs opened 8 years ago

logileifs commented 8 years ago

photoview-android

When running the example code on android all I get is an empty view with a red frame

edolfuchs commented 8 years ago

Same bug here

tomershohet commented 8 years ago

same here

alwx commented 8 years ago

@logileifs @edolfuchs @tomershohet how do you run it guys? when I run the example project on AVD I see the following:

screen shot 2016-09-25 at 22 53 44
alwx commented 8 years ago

Also, please, check it with new 1.2.0 version.

esgudnason commented 7 years ago

Still getting red border in Android with React Native 0.34.1 and version 1.2.0

logileifs commented 7 years ago

@alwx I figured out that this error was due to it not being linked correctly. However after fixing the linking error I can run the example fine but I get an empty view when using uri with a local path.

superandrew213 commented 7 years ago

@logileifs what linking error did you have? Mine is linked correctly but still not working

ufon commented 7 years ago

+1

logileifs commented 7 years ago

@superandrew213 I just looked at all the usual android files that need to be linked settings.gradle, build.gradle, MainApplication.java and MainActivity.java. It was missing in some of them so I added where was needed. But like I said, once I got that working it only worked for remote URI

ufon commented 7 years ago

@logileifs tell pls what u added?

logileifs commented 7 years ago

@ufon I really don't remember anymore where the problem was exactly, if you post the content of the files I mentioned I can tell you where you are missing something

rwillemsandroid commented 7 years ago

As suggested by @logileifs the problem is indeed related to the linking of the library, to fix this @ufon, you need to do the following:

In MainApplication.java

add import com.reactnative.photoview.PhotoViewPackage; to the imports and in function getPackages() add new PhotoViewPackage()

@Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
      new MainReactPackage(),
          ...
           new PhotoViewPackage(),
         ...
              );
    }
  };
affibox commented 7 years ago
<PhotoView

source={{uri: 'https://facebook.github.io/react/img/logo_og.png'}} minimumZoomScale={0.5} maximumZoomScale={3} androidScaleType="center" onLoad={() => console.log("Image loaded!")} style={{width: 300, height: 300}} />

This doesn't work at all

vspedr commented 7 years ago

TL;DR: check if rnpm link actually made all the necessary changes (indicated in Manual Installation) to MainActivity.java or MainApplication.java depending on your React Native Version.

I was having the same problem using React Native 0.32.0. I tried debugging and this is what I got:

screen shot 2016-11-17 at 10 40 37 am

So I noticed that even after linking the library with rnpm link, the app could not find the native component. Then I used diff to see the changes caused by rnpm link and noticed it had only added the following line to MainActivity.java (build.gradle was fine):

'import com.reactnative.photoview.PhotoViewPackage;'

Actually, that line should have been added to MainApplication.java along with other imports. It was also missing the following part, which should also go in MainApplication.java.

@Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new PhotoViewPackage() // add this manager
      );
    }

Fix'd ;)

jr-k commented 7 years ago

@everyone try to import libART.a

jjdp commented 7 years ago

did you all run react-native run-android again? and dont forget to add in build.gradle compile project(':react-native-photo-view')

sudoaza commented 7 years ago

Same here, i had my getPackages function in MainActivity.java instead of MainApplication.java, moved the import there and added the new PhotoViewPackage() and worked. It works for local files too!

kccheung commented 7 years ago

I still suffer the same issue. I saw my ReactActivity.java does not have a member function getPackages to allow MainActivity.java to override.

affibox commented 7 years ago

Guys.... Try to manually link the module. Then put the inside a tag.

This actually helped me. Ex:

<View>
 <PhotoView /* add the extra parameters and props*/ />
</View>
Obooman commented 7 years ago

After I run react-native link it works well.react-natove@0.45 and Android@7.0.1

nihp commented 4 years ago

I am getting a blank screen in Android. Works fine in iOS

I have linked correctly. @alwx Any workarounds