我的 IDE Android 工作室中有 3 个版本的项目。版本 4、版本 6 和版本 7。 前一周我将 IDE 从 ArcticFox 更新为 Giraffe,它破坏了我的项目。最后我删除了IDE并重新安装了ArticFox。在转移到 giraffe 并再次返回 articFox 之前,版本 7 确实可以工作,所以不确定发生了什么变化。
版本 4 和版本 6 工作正常,但版本 7 不行。在版本 7 中,我放弃了 appCompt 库,现在使用 AndroidX。
尝试运行该应用程序时,我收到以下信息。
Failed to transform 'C:\Users\mattheww\.gradle\caches\modules-2\files-2.1\androidx.activity\activity\1.6.0\4bee9777c02790cb99e68cd397036b1d5508a630\activity-1.6.0.aar' using Jetifier. Reason: null. (Run with --stacktrace for more details.) To disable Jetifier, set android.enableJetifier=false in your gradle.properties file.
我尝试过的:
我尝试通过在 gradle 文件中将其设置为 false 来修改 android.enableJetifier=true ,并在清单中的标签上设置以下内容 - tools:replace="android:appComponentFactory
我似乎也没有在任何地方引用旧的 appCompat 库。
还有什么我可以尝试的吗?
这是我的成绩:
apply plugin: 'com.android.application'
android {
compileSdkVersion 31
buildToolsVersion '28.0.3'
useLibrary 'org.apache.http.legacy'
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
defaultConfig {
applicationId "xxxxxxxx.xxxxxxx.rr3"
minSdkVersion 24
targetSdkVersion 31
versionName "7.0"
setProperty("archivesBaseName", "RR7v$versionName" + "DEV")
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
multiDexKeepProguard file('multidex-config.pro')
}
}
}
dependencies {
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
//compile files('libs/core.jar')
compile files('libs/mail.jar')
compile files('libs/ndeftools-1.2.3.jar')
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.android.gms:play-services-gcm:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-base:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.firebase:firebase-jobdispatcher:0.8.4'
implementation 'joda-time:joda-time:2.1'
implementation 'net.zetetic:android-database-sqlcipher:4.5.4@aar'
implementation 'org.apache.directory.studio:org.apache.commons.io:2.4'
implementation 'com.android.volley:volley:1.1.0'
implementation('com.journeyapps:zxing-android-embedded:3.6.0') { transitive = false }
implementation 'com.google.zxing:core:3.3.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.github.florent37:singledateandtimepicker:2.1.4' //https://github.com/florent37/SingleDateAndTimePicker
implementation 'androidx.drawerlayout:drawerlayout:1.0.0'
implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
[更新1]
我尝试过以下方法:
gradlew clean:app:processDebugResources
输出是:
* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Failed to transform file 'activity-1.6.0.aar' to match attributes {artifactType=processed-aar} using transform JetifyTransform
> Failed to transform 'C:\Users\mattheww\.gradle\caches\modules-2\files-2.1\androidx.activity\activity\1.6.0\4bee9777c02790cb99e68cd397036b1d5508a630\activity-1.6.0.aar' using Jetifier. Reason: null. (Run with --stackt
race for more details.) To disable Jetifier, set android.enableJetifier=false in your gradle.properties file.
> Failed to transform file 'activity-1.6.0.aar' to match attributes {artifactType=processed-aar} using transform JetifyTransform
> Failed to transform 'C:\Users\mattheww\.gradle\caches\modules-2\files-2.1\androidx.activity\activity\1.6.0\4bee9777c02790cb99e68cd397036b1d5508a630\activity-1.6.0.aar' using Jetifier. Reason: null. (Run with --stackt
race for more details.) To disable Jetifier, set android.enableJetifier=false in your gradle.properties file.
> Failed to transform file 'activity-1.6.0.aar' to match attributes {artifactType=processed-aar} using transform JetifyTransform
> Failed to transform 'C:\Users\mattheww\.gradle\caches\modules-2\files-2.1\androidx.activity\activity\1.6.0\4bee9777c02790cb99e68cd397036b1d5508a630\activity-1.6.0.aar' using Jetifier. Reason: null. (Run with --stackt
race for more details.) To disable Jetifier, set android.enableJetifier=false in your gradle.properties file.
> Failed to transform file 'annotation-experimental-1.3.0.aar' to match attributes {artifactType=processed-aar} using transform JetifyTransform
> Failed to transform 'C:\Users\mattheww\.gradle\caches\modules-2\files-2.1\androidx.annotation\annotation-experimental\1.3.0\5087c6f545117dcd474e69e1a93cacec9d7334af\annotation-experimental-1.3.0.aar' using Jetifier.
Reason: null. (Run with --stacktrace for more details.) To disable Jetifier, set android.enableJetifier=false in your gradle.properties file.
> Failed to transform file 'annotation-experimental-1.3.0.aar' to match attributes {artifactType=processed-aar} using transform JetifyTransform
> Failed to transform 'C:\Users\mattheww\.gradle\caches\modules-2\files-2.1\androidx.annotation\annotation-experimental\1.3.0\5087c6f545117dcd474e69e1a93cacec9d7334af\annotation-experimental-1.3.0.aar' using Jetifier.
Reason: null. (Run with --stacktrace for more details.) To disable Jetifier, set android.enableJetifier=false in your gradle.properties file.
> Failed to transform file 'annotation-experimental-1.3.0.aar' to match attributes {artifactType=processed-aar} using transform JetifyTransform
> Failed to transform 'C:\Users\mattheww\.gradle\caches\modules-2\files-2.1\androidx.annotation\annotation-experimental\1.3.0\5087c6f545117dcd474e69e1a93cacec9d7334af\annotation-experimental-1.3.0.aar' using Jetifier.
Reason: null. (Run with --stacktrace for more details.) To disable Jetifier, set android.enableJetifier=false in your gradle.properties file.
> Failed to transform file 'annotation-experimental-1.3.0.aar' to match attributes {artifactType=processed-aar} using transform JetifyTransform
> Failed to transform 'C:\Users\mattheww\.gradle\caches\modules-2\files-2.1\androidx.annotation\annotation-experimental\1.3.0\5087c6f545117dcd474e69e1a93cacec9d7334af\annotation-experimental-1.3.0.aar' using Jetifier.
Reason: null. (Run with --stacktrace for more details.) To disable Jetifier, set android.enableJetifier=false in your gradle.properties file.
* 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.
[更新2]
我正在使用以下gradle
有四种方法可以解决迁移到AndroidX后无法转换的错误。
1. Update some dependencies in build.gradle file.
i.e. change
classpath 'io.fabric.tools:gradle:1.25.1'
to
classpath 'io.fabric.tools:gradle:1.27.0'
android.enableJetifier=true
android.useAndroidX=true
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
to
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
classpath 'com.android.tools.build:gradle:8.1.1'