欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

引入科大讯飞 例子程序时Execution failed for JetifyTransform(执行JetifyTransform失败)

程序员文章站 2022-03-23 11:24:55
在引入《Android Studio开发实战 从零基础到APP上线 第2版》欧阳燊的 第三方 例子 语音时出现其中的import android.support.v7.app.AppCompatActivity;无法引入,导致AppCompatActivity报错,重新引入后,发现只能引入import androidx.appcompat.app.AppCompatActivity;此时编译后出现Execution failed for JetifyTransform类似于...

在引入《Android Studio开发实战 从零基础到APP上线 第2版》欧阳燊的 第三方 例子 语音时出现

其中的

import android.support.v7.app.AppCompatActivity;

无法引入,导致AppCompatActivity报错,重新引入后,发现只能引入

import androidx.appcompat.app.AppCompatActivity;

此时编译后出现Execution failed for JetifyTransform

类似于

Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
> Could not resolve all artifacts for configuration ':app:debugCompileClasspath'.
   > Failed to transform artifact 'common.jar (com.android.tools:common:26.4.0)' to match attributes {artifactType=android-classes, org.gradle.usage=java-runtime-jars}.
      > Execution failed for JetifyTransform: C:\Users\Dave\.gradle\caches\modules-2\files-2.1\com.android.tools\common\26.4.0\539939e284fba9fe343b890a6e21c9333767c886\common-26.4.0.jar.
         > Failed to transform 'C:\Users\Dave\.gradle\caches\modules-2\files-2.1\com.android.tools\common\26.4.0\539939e284fba9fe343b890a6e21c9333767c886\common-26.4.0.jar' using Jetifier. Reason: The given artifact contains a string literal with a package reference 'android.support.design.widget' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.. (Run with --stacktrace for more details.)
   > Failed to transform artifact 'bundletool.jar (com.android.tools.build:bundletool:0.7.2)' to match attributes {artifactType=android-classes, org.gradle.usage=java-runtime-jars}.
      > Execution failed for JetifyTransform: C:\Users\Dave\.gradle\caches\modules-2\files-2.1\com.android.tools.build\bundletool\0.7.2\31f71b66edcbe41de0268e14c961a7799a03d42a\bundletool-0.7.2.jar.
         > Failed to transform 'C:\Users\Dave\.gradle\caches\modules-2\files-2.1\com.android.tools.build\bundletool\0.7.2\31f71b66edcbe41de0268e14c961a7799a03d42a\bundletool-0.7.2.jar' using Jetifier. Reason: The given artifact contains a string literal with a package reference 'android.support.design.widget' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.. (Run with --stacktrace for more details.)

Suggestions:
            - If you believe this library doesn't need to be jetified (e.g., if it already supports AndroidX, or if it doesn't use support libraries/AndroidX at all), add android.jetifier.blacklist = {comma-separated list of regular expressions (or simply names) of the libraries that you don't want to be jetified} to the gradle.properties file.
            - If you believe this library needs to be jetified (e.g., if it uses old support libraries and breaks your app if it isn't jetified), contact the library's authors to update this library to support AndroidX and use the supported version once it is released.

翻译了一下:

-如果您认为这个库不需要被jetified(例如,如果它已经支持AndroidX,或者它根本不使用支持库/AndroidX),请添加android.jetifier.黑名单={不想被jetifid}到的库的正则表达式(或简单名称)的逗号分隔列表梯度属性文件。

这个是报错信息中,谷歌给的建议,就是直接不往AndroidX中迁移这个包。也就是这样:
在项目的gradle.properties文件中,加入:

android.jetifier.blacklist = Msc.jar

其中Msc.jar可以根据报错信息进行替换,替换后既可以顺利运行。

引入科大讯飞 例子程序时Execution failed for JetifyTransform(执行JetifyTransform失败)

类似文章请见:https://blog.csdn.net/zhaochengfang/article/details/109675934

 

 

 

本文地址:https://blog.csdn.net/liaoweihaoren/article/details/110222231

相关标签: android java