我不得不完全重写这个问题。
我有一个反应原生的 android 应用程序。当我使用 ./gradlew assembleRelease -x bundleReleaseJsAndAssets
构建 apk
文件时,它运行良好,但之后它完全停止编译。甚至 react-native run-android
也不再工作了。
到目前为止我发现了什么:首先,错误是这样的
Task :app:processDebugResources FAILED
resource android:attr/fontVariationSettings not found.
resource android:attr/ttcIndex not found.
如果我将这些行添加到 gradle.properties
,
android.useAndroidX=true
android.enableJetifier=true
错误改变。现在是这个
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 个库。一个例子:
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
然后如果我删除另一个,就会发生这种情况:
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 个库,它将编译。他们是:
react-native-camera-kit
@react-native-community_netinfo
react-native-push-notification
react-native-sensors
@JWWon_react-native-universal-pedometer
react-native-keep-awake
react-native-toast-native
没有它们,它可以完美编译。因此,有一个更大的问题无法让它发挥作用。 2 天前,所有这些库都运行良好,没有任何问题。但现在有什么东西把它压碎了。
原文由 irondsd 发布,翻译遵循 CC BY-SA 4.0 许可协议
在 build.gradle (android) 中添加子项目
在 build.gradle (android/app) 中添加实现“com.google.android.gms:play-services-gcm:12.+”
所以你不需要迁移到 Androidx
编辑1:代码格式
编辑2:缺少括号