Open YuriOlepir opened 1 month ago
Same here
same issue
same here
same here, any solutions?
same here, any solutions?
Temporary Workaround.
You can try modifying the library code until the library is officially updated.
Open the file causing issues: /node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageSource.java.
Replace the code with the one below.
package com.dylanvann.fastimage;
import android.content.Context;
import android.content.res.Resources;
import android.net.Uri;
import android.text.TextUtils;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.load.model.Headers;
import com.facebook.react.views.imagehelper.ImageSource;
import javax.annotation.Nullable;
public class FastImageSource {
private static final String DATA_SCHEME = "data";
private static final String LOCAL_RESOURCE_SCHEME = "res";
private static final String ANDROID_RESOURCE_SCHEME = "android.resource";
private static final String ANDROID_CONTENT_SCHEME = "content";
private static final String LOCAL_FILE_SCHEME = "file";
private final Headers mHeaders;
private Uri mUri;
private final ImageSource imageSource; // Composition instead of inheritance
public static boolean isBase64Uri(Uri uri) {
return DATA_SCHEME.equals(uri.getScheme());
}
public static boolean isLocalResourceUri(Uri uri) {
return LOCAL_RESOURCE_SCHEME.equals(uri.getScheme());
}
public static boolean isResourceUri(Uri uri) {
return ANDROID_RESOURCE_SCHEME.equals(uri.getScheme());
}
public static boolean isContentUri(Uri uri) {
return ANDROID_CONTENT_SCHEME.equals(uri.getScheme());
}
public static boolean isLocalFileUri(Uri uri) {
return LOCAL_FILE_SCHEME.equals(uri.getScheme());
}
public FastImageSource(Context context, String source) {
this(context, source, null);
}
public FastImageSource(Context context, String source, @Nullable Headers headers) {
this(context, source, 0.0d, 0.0d, headers);
}
public FastImageSource(Context context, String source, double width, double height, @Nullable Headers headers) {
imageSource = new ImageSource(context, source, width, height); // Create ImageSource instance
mHeaders = headers == null ? Headers.DEFAULT : headers;
mUri = imageSource.getUri(); // Get URI from ImageSource
if (isResource() && TextUtils.isEmpty(mUri.toString())) {
throw new Resources.NotFoundException("Local Resource Not Found. Resource: '" + getSource() + "'.");
}
if (isLocalResourceUri(mUri)) {
// Convert res:/ scheme to android.resource:// so
// Glide can understand the URI.
mUri = Uri.parse(mUri.toString().replace("res:/", ANDROID_RESOURCE_SCHEME + "://" + context.getPackageName() + "/"));
}
}
public boolean isBase64Resource() {
return mUri != null && FastImageSource.isBase64Uri(mUri);
}
public boolean isResource() {
return mUri != null && FastImageSource.isResourceUri(mUri);
}
public boolean isLocalFile() {
return mUri != null && FastImageSource.isLocalFileUri(mUri);
}
public boolean isContentUri() {
return mUri != null && FastImageSource.isContentUri(mUri);
}
public Object getSourceForLoad() {
if (isContentUri()) {
return getSource();
}
if (isBase64Resource()) {
return getSource();
}
if (isResource()) {
return getUri();
}
if (isLocalFile()) {
return getUri().toString();
}
return getGlideUrl();
}
public Uri getUri() {
return mUri;
}
public Headers getHeaders() {
return mHeaders;
}
public GlideUrl getGlideUrl() {
return new GlideUrl(getUri().toString(), getHeaders());
}
public String getSource() {
return imageSource.getSource(); // Delegate to ImageSource
}
}
Finally you can use patch package (https://github.com/ds300/patch-package) to patch it.
Hello use https://www.npmjs.com/package/@d11/react-native-fast-image It is actively maintained and issue will be resolved soon
I am also getting the same issue, i am using latest 0.75.1 version of react native library
Temporary Workaround.
You can try modifying the library code until the library is officially updated.
Open the file causing issues: /node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageSource.java.
Replace the code with the one below.
package com.dylanvann.fastimage; import android.content.Context; import android.content.res.Resources; import android.net.Uri; import android.text.TextUtils; import com.bumptech.glide.load.model.GlideUrl; import com.bumptech.glide.load.model.Headers; import com.facebook.react.views.imagehelper.ImageSource; import javax.annotation.Nullable; public class FastImageSource { private static final String DATA_SCHEME = "data"; private static final String LOCAL_RESOURCE_SCHEME = "res"; private static final String ANDROID_RESOURCE_SCHEME = "android.resource"; private static final String ANDROID_CONTENT_SCHEME = "content"; private static final String LOCAL_FILE_SCHEME = "file"; private final Headers mHeaders; private Uri mUri; private final ImageSource imageSource; // Composition instead of inheritance public static boolean isBase64Uri(Uri uri) { return DATA_SCHEME.equals(uri.getScheme()); } public static boolean isLocalResourceUri(Uri uri) { return LOCAL_RESOURCE_SCHEME.equals(uri.getScheme()); } public static boolean isResourceUri(Uri uri) { return ANDROID_RESOURCE_SCHEME.equals(uri.getScheme()); } public static boolean isContentUri(Uri uri) { return ANDROID_CONTENT_SCHEME.equals(uri.getScheme()); } public static boolean isLocalFileUri(Uri uri) { return LOCAL_FILE_SCHEME.equals(uri.getScheme()); } public FastImageSource(Context context, String source) { this(context, source, null); } public FastImageSource(Context context, String source, @Nullable Headers headers) { this(context, source, 0.0d, 0.0d, headers); } public FastImageSource(Context context, String source, double width, double height, @Nullable Headers headers) { imageSource = new ImageSource(context, source, width, height); // Create ImageSource instance mHeaders = headers == null ? Headers.DEFAULT : headers; mUri = imageSource.getUri(); // Get URI from ImageSource if (isResource() && TextUtils.isEmpty(mUri.toString())) { throw new Resources.NotFoundException("Local Resource Not Found. Resource: '" + getSource() + "'."); } if (isLocalResourceUri(mUri)) { // Convert res:/ scheme to android.resource:// so // Glide can understand the URI. mUri = Uri.parse(mUri.toString().replace("res:/", ANDROID_RESOURCE_SCHEME + "://" + context.getPackageName() + "/")); } } public boolean isBase64Resource() { return mUri != null && FastImageSource.isBase64Uri(mUri); } public boolean isResource() { return mUri != null && FastImageSource.isResourceUri(mUri); } public boolean isLocalFile() { return mUri != null && FastImageSource.isLocalFileUri(mUri); } public boolean isContentUri() { return mUri != null && FastImageSource.isContentUri(mUri); } public Object getSourceForLoad() { if (isContentUri()) { return getSource(); } if (isBase64Resource()) { return getSource(); } if (isResource()) { return getUri(); } if (isLocalFile()) { return getUri().toString(); } return getGlideUrl(); } public Uri getUri() { return mUri; } public Headers getHeaders() { return mHeaders; } public GlideUrl getGlideUrl() { return new GlideUrl(getUri().toString(), getHeaders()); } public String getSource() { return imageSource.getSource(); // Delegate to ImageSource } }
Finally you can use patch package (https://github.com/ds300/patch-package) to patch it.
@hpanwar521 try this solution. It will work.
This is also not working for me ... is there any other solution
I am also getting the same issue. I am using the latest 0.75.1 version of the React Native library. Please heeeeeeeeeeeeeelp!
I am also getting the same issue. I am using the latest 0.75.1 version of the React Native library. Please heeeeeeeeeeeeeelp!
@mohsenfl2022 follow these steps:-
Put the attached patch file inside the patches folder. If there is no patches folder, create one and put that file
Install patch-package
.
After installation, run npx patch-package react-native-fast-image
.
After that try building the app. It will work fine
facing the same issue with react-native 0.75.1 version while running the application in android.
node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageSource.java:14: error: cannot inherit from final ImageSource public class FastImageSource extends ImageSource { ^
@DylanVann Kindly look into this
This is fixed in https://github.com/facebook/react-native/pull/46092/files You can also try @d11/react-native-fast-image
it's a fork of this. can we upgrade this in the same?
it's a fork of this. can we upgrade this in the same?
react-native is the peer dependency of react-native-fast-image. So when you upgrade your app to the fixed version of react-native , it will automatically work
Here are the versions of libs. still, it's not working.
"react": "18.3.1",
"react-native": "0.75.1",
"react-native-fast-image": "^8.6.3",
0.75.2 is fixed this issues
not fixed for me
it's not working with 0.75.2 also
Getting below errors with 0.75.2 version
/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageSource.java:72: error: isResource() in FastImageSource cannot override isResource() in ImageSource public boolean isResource() { ^ overridden method is final
/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageSource.java:101: error: getUri() in FastImageSource cannot override getUri() in ImageSource public Uri getUri() { ^ overridden method is final
+1
+1
This PR on react-native will solve this issue:
+1
Any progress on this fam
Someone have a solution for this issue, can someone contact with the repo owner?
There's also a new alternative, Faster Image, https://github.com/candlefinance/faster-image
same question.Hope fix this error coming soon.
I've setup a patch file for this issue for version 0.75.2 in ./patches/react-native+0.75.2.patch
diff --git a/node_modules/react-native/ReactAndroid/api/ReactAndroid.api b/node_modules/react-native/ReactAndroid/api/ReactAndroid.api
index e647de2..6a14ffd 100644
--- a/node_modules/react-native/ReactAndroid/api/ReactAndroid.api
+++ b/node_modules/react-native/ReactAndroid/api/ReactAndroid.api
@@ -6459,9 +6459,9 @@ public class com/facebook/react/views/imagehelper/ImageSource {
public final fun getSize ()D
public final fun getSource ()Ljava/lang/String;
public static final fun getTransparentBitmapImageSource (Landroid/content/Context;)Lcom/facebook/react/views/imagehelper/ImageSource;
- public final fun getUri ()Landroid/net/Uri;
+ public fun getUri ()Landroid/net/Uri;
public fun hashCode ()I
- public final fun isResource ()Z
+ public fun isResource ()Z
}
public final class com/facebook/react/views/imagehelper/ImageSource$Companion {
diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/ImageSource.kt b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/ImageSource.kt
index 583b4a0..947044c 100644
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/ImageSource.kt
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/ImageSource.kt
@@ -23,12 +23,14 @@ constructor(
) {
/** Get the URI for this image - can be either a parsed network URI or a resource URI. */
- public val uri: Uri = computeUri(context)
+ public open val uri: Uri = computeUri(context)
/** Get the area of this image. */
public val size: Double = width * height
/** Get whether this image source represents an Android resource or a network URI. */
- public var isResource: Boolean = false
- private set
+ public open val isResource: Boolean
+ get() = _isResource
+
+ private var _isResource: Boolean = false
override fun equals(other: Any?): Boolean {
if (this === other) {
@@ -58,7 +60,7 @@ constructor(
}
private fun computeLocalUri(context: Context): Uri {
- isResource = true
+ _isResource = true
return ResourceDrawableIdHelper.instance.getResourceDrawableUri(context, source)
}
However the same build error happens after:
rm -Rf node_modules/
npm install
cd android && ./gradlew clean && cd ../
watchman watch-del all
npm run start --reset-cache
Is it possible to patch this?
Hello use https://www.npmjs.com/package/@d11/react-native-fast-image It is actively maintained and issue will be resolved soon
does not work.
Hello use https://www.npmjs.com/package/@d11/react-native-fast-image It is actively maintained and issue will be resolved soon
does not work.
It will be fixed in react-native@0.75.3
Any idea when react-native@0.75.3 will be released?
Yup, I can confirm that the above repo does not fix the problem. Even though the most recent release was less than 24 hours ago.
Yup, I can confirm that the above repo does not fix the problem. Even though the most recent release was less than 24 hours ago.
@JohnSmall The issue has been fixed in react-native. Once they release new version it will automatically gets fixed in fast image. Currently i am triggering a cron based nightly build for everyone to see whats coming. That is reason last publish is less than 24 hours ago. I am working on nightly build optimisation.In future this will be triggered only if changes are there. Let me know if you have more concerns i am happy to help.
@YuriOlepir Issue has been fixed in @d11/react-native-fast-image
Hello, i updated react-native to the latest 0.75.1 version and now have got such errors after executing
run android
command.