【问题标题】:Failed to transform annotation-experimental-1.3.0-rc01.aar React-Native无法转换 annotation-experimental-1.3.0-rc01.aar React-Native
【发布时间】:2023-01-14 11:12:48
【问题描述】:

我在 React Native 上的项目。 8 月 24 日之后,我遇到了这个问题。 怎么修?

* What went wrong:
Could not determine the dependencies of task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':app:debugCompileClasspath'.
   > Failed to transform annotation-experimental-1.3.0-rc01.aar (androidx.annotation:annotation-experimental:1.3.0-rc01) to match attributes {artifactType=jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
      > Execution failed for JetifyTransform: C:\Users\twent\.gradle\caches\modules-2\files-2.1\androidx.annotation\annotation-experimental\1.3.0-rc01\21f058f7e73e25cb36ea7093686ec9334f5b588e\annotation-experimental-1.3.0-rc01.aar.
         > Failed to transform 'C:\Users\twent\.gradle\caches\modules-2\files-2.1\androidx.annotation\annotation-experimental\1.3.0-rc01\21f058f7e73e25cb36ea7093686ec9334f5b588e\annotation-experimental-1.3.0-rc01.aar' using Jetifier. Reason: null. (Run with --stacktrace for more details.)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings

我想做什么:

  1. 禁用 jetifier (jetifier = false);

  2. 接下来 - 在 build.gradle 中添加:

    packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/license.txt'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/notice.txt'
            exclude 'META-INF/ASL2.0'
            exclude("META-INF/*.kotlin_module")
            exclude 'androidsupportmultidexversion.txt'
          }  
    
    packagingOptions{
         pickFirst "androidsupportmultidexversion.txt"
      }
    
    1. build.gradle (android) 中的 minSdkVersion 21

    2. 在 build.gradle (android) 中添加 classpath("com.android.tools:r8:1.6.84")

    3. 添加 gradle.properties android.minifyEnabled=false adnroid.shrinkResources=false

    4. 但这无济于事,并且有很多错误;)

【问题讨论】:

  • 你得到解决方案了吗?

标签: react-native annotations


【解决方案1】:
  1. 在 gradle wrapper 中更改 distributionurl

    distributionUrl=https://services.gradle.org/distributions/gradle-6.8.1-all.zip

    1. 在 dependencies{} 下更新 build.gradle 中的构建工具

    类路径(“com.android.tools.build:gradle:4.1.3”)

    1. 在 buildscript{} ext{} 下添加和更改它
    minSdkVersion = 21
    compileSdkVersion = 31
    targetSdkVersion = 31
    androidXCore = "1.5.0"
    

【讨论】:

  • 这对我有用,我想知道问题是什么以及您是如何提出解决方案的
  • 只是得到了一些参考和错误,并将它们组合起来
【解决方案2】:

尝试这个:

添加 implementation "androidx.annotation:annotation-experimental:1.3.0-rc01" 在 app/build.gradle 下的 dependencies{}

【讨论】:

    【解决方案3】:

    如果出于某种原因您不想按照@Jonathan Suhangita 的建议升级您的 SDK。您可以通过将其插入您的应用程序级别build.gradle来将版本覆盖为稳定版本:

    configurations.all {
      resolutionStrategy {
        force "androidx.annotation:annotation-experimental:1.2.0"
      }
    }
    

    据我了解,annotation 的 1.3.0 版是稳定的,不再包含在 annotation-experimental 包中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-09-27
      • 2016-12-15
      • 1970-01-01
      • 2021-12-27
      • 1970-01-01
      • 2019-12-30
      • 2020-02-27
      相关资源
      最近更新 更多