gpt4 book ai didi

android - GIF 在我的 React Native 应用程序的 Android 版本中没有动画

转载 作者:行者123 更新时间:2023-12-04 23:41:38 25 4
gpt4 key购买 nike

我正在努力让我的 GIF 在我的 RN 应用程序的 Android 版本上制作动画。 iOS 版本正在按预期为循环 GIF 设置动画,但我只在 Android 设备上看到来自 GIF 的卡住的“单帧”图像。
根据调试和 RN 文档,需要添加几行 implementationdependencies在/android/app/build.gradle 中,但即使在清理 gradle(在/android 文件夹中运行 ./gradlew clean)并删除 RN 应用程序的缓存(在项目根文件夹中运行 react-native start --reset-cache)之后,我也会这样做在我的应用程序中看不到任何区别。
我已经用谷歌搜索并尝试了很多。根据我的调试冒险,我已经尝试并仔细检查了这些建议,这似乎对其他人有用,但似乎对我不起作用......

  • 我已经尝试了几个版本的 fresco-libraries 似乎
    是必需的,我也尝试将这些线放在dependencies 的底部和顶部.
  • 一些答案还建议添加一行或多行代码
    android/app/proguard-rules.pro 但这不会改变
    任何东西。
  • 我在我的应用程序中以不同的方式使用 GIF,但它总是有widthheight包含在 style<Image /> 上的属性(property).
  • 我尝试过使用来自不同 CDN 和域的 GIF-uris。
  • 在我的测试设备上重新安装了该应用程序。
  • 关闭并重新打开我的代码编辑器。

  • 我正在使用以下版本:
  • java :11.0.12
  • react 原生:0.65
  • 安卓 SDK:30.0.2
  • npm: 6.14.4

  • 这是我完整的/android/app/build.gradle:
    apply plugin: "com.android.application"

    import com.android.build.OutputFile


    project.ext.react = [
    enableHermes: false, // clean and rebuild if changing
    ]

    apply from: "../../node_modules/react-native/react.gradle"


    def enableSeparateBuildPerCPUArchitecture = false
    def enableProguardInReleaseBuilds = false
    def jscFlavor = 'org.webkit:android-jsc:+'
    def enableHermes = project.ext.react.get("enableHermes", false);

    android {
    ndkVersion rootProject.ext.ndkVersion

    compileSdkVersion rootProject.ext.compileSdkVersion

    defaultConfig {
    applicationId "com.example.app"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
    }
    splits {
    abi {
    reset()
    enable enableSeparateBuildPerCPUArchitecture
    universalApk false // If true, also generate a universal APK
    include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
    }
    }
    signingConfigs {
    debug {
    storeFile file('debug.keystore')
    storePassword 'android'
    keyAlias 'androiddebugkey'
    keyPassword 'android'
    }
    }
    buildTypes {
    debug {
    signingConfig signingConfigs.debug
    }
    release {
    // Caution! In production, you need to generate your own keystore file.
    // see https://reactnative.dev/docs/signed-apk-android.
    signingConfig signingConfigs.debug
    minifyEnabled enableProguardInReleaseBuilds
    proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
    }

    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
    variant.outputs.each { output ->
    // For each separate APK per architecture, set a unique version code as described here:
    // https://developer.android.com/studio/build/configure-apk-splits.html
    // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
    def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
    def abi = output.getFilter(OutputFile.ABI)
    if (abi != null) { // null for the universal-debug, universal-release variants
    output.versionCodeOverride =
    defaultConfig.versionCode * 1000 + versionCodes.get(abi)
    }

    }
    }
    }

    dependencies {

    implementation fileTree(dir: "libs", include: ["*.jar"])
    //noinspection GradleDynamicVersion
    implementation "com.facebook.react:react-native:+" // From node_modules

    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"

    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.fbjni'
    }

    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.flipper'
    exclude group:'com.squareup.okhttp3', module:'okhttp'
    }

    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.flipper'
    }

    if (enableHermes) {
    def hermesPath = "../../node_modules/hermes-engine/android/";
    debugImplementation files(hermesPath + "hermes-debug.aar")
    releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
    implementation jscFlavor
    }


    implementation project(':react-native-notifications')
    implementation 'com.google.firebase:firebase-core:16.0.0'
    implementation 'com.google.android.gms:play-services-ads:19.8.0'
    implementation "androidx.appcompat:appcompat:1.0.0"

    implementation 'com.facebook.fresco:fresco:2.4.0'
    implementation 'com.facebook.fresco:animated-gif:2.4.0'
    implementation 'com.facebook.fresco:webpsupport:2.4.0'
    }

    // Run this once to be able to run the application with BUCK
    // puts all compile dependencies into folder libs for BUCK to use
    task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
    }

    apply plugin: 'com.google.gms.google-services'

    apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
    让我知道我是否遗漏了一些明显的东西。我在 iOS 开发方面肯定更有经验,所以我很可能错过了一些东西 :-)

    最佳答案

    我在使用 react-native 0.66.3 和更新 com.facebook.fresco:animated-gif 时遇到了同样的问题至2.6.0app/build.gradle为我工作

    关于android - GIF 在我的 React Native 应用程序的 Android 版本中没有动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68883151/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com