反应本地构建错误:包android.support.annotation不存在 [英] react native build error: package android.support.annotation does not exist

查看:436
本文介绍了反应本地构建错误:包android.support.annotation不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不得不完全重写问题.

I had to completely rewrite the question.

我有一个React native android应用.当我使用 ./gradlew assembleRelease -x bundleReleaseJsAndAssets 构建 apk 文件时,它运行良好,但此后它完全停止了编译.甚至 react-native run-android 都不再起作用.

I have a react native android app. When I built the apk file with ./gradlew assembleRelease -x bundleReleaseJsAndAssets, it went fine, but after that it stopped compiling at all. Even react-native run-android is not working anymore.

到目前为止,我发现了什么:首先,错误是这样

What I found so far: First, the error is this

Task :app:processDebugResources FAILED
resource android:attr/fontVariationSettings not found.
resource android:attr/ttcIndex not found.

如果我将这些行添加到 gradle.properties

If I add these lines to gradle.properties,

android.useAndroidX=true
android.enableJetifier=true

错误发生变化.现在就是这个

the error changes. Now it's this

Task :@JWWon_react-native-universal-pedometer:compileDebugJavaWithJavac FAILED

error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
                                 ^
cannot find symbol
  private void sendPedometerUpdateEvent(@Nullable WritableMap params) {
                                         ^
  symbol:   class Nullable
  location: class BMDPedometerModule

问题不在于库.如果我从项目中删除它,它将开始抱怨另一个项目.要使其编译,我必须删除7个库.一个例子:

The problem is not with the library though. If I remove it from the project, it start complaining about another one. To get it to compile, I have to remove 7 libraries. An example:

Task :@react-native-community_netinfo:compileDebugJavaWithJavac FAILED
error: package android.support.v4.net does not exist
import android.support.v4.net.ConnectivityManagerCompat;
error: cannot find symbol
    promise.resolve(ConnectivityManagerCompat.isActiveNetworkMetered(getConnectivityManager()));
                    ^
  symbol:   variable ConnectivityManagerCompat
  location: class ConnectivityReceiver
2 errors

然后如果我删除另一个,则会发生这种情况:

then if I remove another, this happens:

Task :react-native-camera-kit:compileDebugJavaWithJavac FAILED
package android.support.annotation does not exist
import android.support.annotation.ColorInt;
                                 ^
package android.support.annotation does not exist
import android.support.annotation.IntRange;
                                 ^
...
92 errors

因此,如果我从项目中删除7个库,它将进行编译.他们是:

So it will compile if I remove 7 libraries from the project. They are:

react-native-camera-kit@ react-native-community_netinfo反应本地推送通知反应本机传感器@ JWWon_react-native-universal-pedometer反应本机保持清醒反应本机土司本机

没有它们,它可以完美地编译.因此,有一个更大的问题使它无法正常工作.2天前,所有这些库都正常运行,没有问题.但是现在有些东西压垮了它.

Without them, it compiles perfectly. So there's a bigger problem that doesn't let it work. 2 days ago, all of those libraries were working perfectly with no problem. But now something crushes it.

推荐答案

allprojects {
  repositories {
      bla bla bla...
  }
  subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "26.+"
            }
            if (details.requested.group == 'com.google.android.gms'
            && !details.requested.name.contains('multidex') && !details.requested.name.contains('play-services-stats')) {
                details.useVersion "12.+"
            }
            if (details.requested.group == 'com.google.android.gms'
            && !details.requested.name.contains('multidex') && details.requested.name.contains('play-services-stats')) {
                details.useVersion "+"
            }
         }
      }
   }
}

在build.gradle(android)中添加子项目

dependencies {
     ...bla bla bla

    implementation "com.google.android.gms:play-services-gcm:12.+"
}

添加实施"com.google.android.gms:play-services-gcm:12. +"在build.gradle(android/app)

,因此您无需迁移到Androidx

代码格式

缺少括号

这篇关于反应本地构建错误:包android.support.annotation不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆