我不得不彻底改写这个问题。
我有一个反应本地android应用程序。当我用apk构建./gradlew assembleRelease -x bundleReleaseJsAndAssets文件时,它做得很好,但在那之后它就完全停止编译了。就连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
没有它们,它就能完美地编译。所以还有一个更大的问题不让它起作用。两天前,所有这些图书馆都运转良好,没有问题。但现在有东西压碎了它。
发布于 2019-06-21 23:10:49
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 (安卓/应用程序)中添加实现
,这样就不需要迁移到Androidx了
编辑1:代码格式
编辑2:缺少一个括号
发布于 2019-06-21 04:20:58
试着用奶嘴
npm install --save-dev jetifier
或者使用纱线,但是在项目中本地安装,而不是全局安装。
npx jetify
或
npx jetify -w=1 -指定并行工作人员的数量
npx react-native run-android
发布于 2019-08-14 20:46:28
实际上,我也有过类似的事情发生,而且运行起来很有效。
npx jetify当我在CI管道中运行它时,它没有工作,不得不添加
"scripts": {
...
"postinstall": "jetify"
}npm运行完,在管道中安装,然后运行jetify转换为androidx,并覆盖所有需要转换的库。
https://stackoverflow.com/questions/56667264
复制相似问题