Android 此版本中使用了不推荐的Gradle功能,使其与Gradle 5.0不兼容
我有一次严重的失败:Android 此版本中使用了不推荐的Gradle功能,使其与Gradle 5.0不兼容,android,unit-testing,gradle,kotlin,junit5,Android,Unit Testing,Gradle,Kotlin,Junit5,我有一次严重的失败: ..."Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0." 案例描述: 将下一个LIB附加到项目代码库: APP/build.gradle //(Required) Writing and executing Unit Tests on the JUnit Platform testImplementation "org.ju
..."Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0."
案例描述:
- 将下一个LIB附加到项目代码库:
//(Required) Writing and executing Unit Tests on the JUnit Platform
testImplementation "org.junit.jupiter:junit-jupiter-api:5.2.0"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.2.0"
// (Optional) If you need "Parameterized Tests"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.2.0"
// (Optional) If you also have JUnit 4-based tests
testImplementation "junit:junit:4.12"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.2.0"
testImplementation "io.mockk:mockk:1.8.5"
- 更新了渐变包装器。属性 distributionUrl=https….gradle-4.4-all。压缩到4.7-all
- 在这一切之后,格拉德尔成功了
- 创建了测试cals
@TestInstance(TestInstance.Lifecycle.PER_CLASS) class TestClass { @Test internal fun testName() { Assert.assertEquals(2, 1 + 1) } }
- 运行测试并收到失败消息。
- 使用命令行参数
运行Gradle构建,以查看不推荐使用的功能到底是什么。/gradlew--warning mode=all
因此,我无法构建该应用程序,我收到了一条失败消息。使用命令行参数运行Gradle构建
--warning mode=all
,以查看不推荐的功能到底是什么
它将为您提供所发现问题的详细描述,并提供指向Gradle文档的链接,以了解如何修复您的构建
添加
--stacktrace
,您还可以确定警告的来源,如果它是由某个插件中的过时代码而不是您的构建脚本触发的。最终决定将junit 5降级为junit 4并重建测试环境。将gradle包装器属性文件中的distributionUrl路径设置为:
分配URL=https://services.gradle.org/distributions/gradle-4.10.2-all.zip更新您的第三方依赖关系。例如,我更新了
implementation'com.github.ybq:Android SpinKit:1.1.0'
至implementation'com.github.ybq:Android SpinKit:1.2.0'
。就我而言,问题已经解决。我遇到了这个错误。事实证明,只有当我彻底清理了RN缓存(相当复杂的过程)并创建了一个发布版本时,才会发生这种情况
如果我清理了缓存,创建了调试版本,然后是发布版本,那么一切都正常了。有点担心,但效果不错
注意:我的clean命令是
rm-r安卓/build;rm-r android/app/src/release/res;rm-r android/app/build/intermediates;守望者守望一切;rm-rf$TMPDIR/react-*;npm启动---重置缓存
重要-回答仅适用于REACT-NATIVE VS-code终端
在VisualStudio代码中,必须按如下方式运行,然后该警告将被忽略
react native run android warning mode=all
如果您在下面运行,那么您将在终端中得到错误
运行react native run android时--warning mode all I get错误:未知选项--warning mode'
问题的解决办法:
此版本中使用了不推荐的gradle功能,使其与gradle 6.0不兼容。安卓工作室
这个解决方案对我很有效
首先更改项目的build.gradle依赖项中的类路径
发件人:classpath'com.android.tools.build:gradle:3.3.1'
致:classpath'com.android.tools.build:gradle:3.6.1'
然后在gradle-wrapper.properties文件中进行更改此文件存在于项目的gradle>wrapper文件夹中
发件人:distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
收件人:distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
然后同步你的渐变。试试这个
cd android && ./gradlew clean && ./gradlew :app:bundleRelease
在一个使用IntelliJ和Gradle的SpringBoot项目中,我在运行集成测试时收到警告“此版本中使用了不推荐的Gradle功能,使其与Gradle 5.0不兼容”。 解决问题的办法是: -转到:文件>设置>生成、执行、部署 -选择“使用构建和运行”:Intellij IDEA(而不是“Gradle”) -与“使用运行测试”相同
这并不能解释为什么Gradle会显示警告,但这让我可以执行测试并在工作中取得进展。在我的例子中,我更新了
build.Gradle
文件,并将类路径从3.5.2
修改为3.6.3
dependencies {
classpath("com.android.tools.build:gradle:3.6.3")
}
在迁移到AndroidX后,修复了此类错误
- 转到重构-->迁移到AndroidX
以下解决方案帮助了我,因为我也收到了同样的警告。
在项目级gradle文件中,尝试在类路径中更改gradle版本
classpath "com.android.tools.build:gradle:3.6.0" to
classpath "com.android.tools.build:gradle:4.0.1"
如果您使用的是react native,请在运行项目之前先尝试以下命令:
npm安装--保存开发人员jetifier
npx凝胶
现在再次运行您的项目。在本期的react native项目中,它对我有效:
此版本中使用了不推荐的Gradle功能,使其与Gradle 7.0不兼容
244项可执行任务:2项已执行,242项最新
D8:无法在单个dex文件中容纳请求的类(#字段:67296>65536)
com.android.builder.dexing.DexArchiveMergerException:合并dex存档时出错:
.dex文件中的方法引用数不能超过64K。
了解如何在上解决此问题
我这样做:
- 从我的设备卸载应用程序:
-
在我的例子中,在Android/build/build.gradle文件中添加multiDexEnabled true编译了这些文件
我将在将来考虑删除此项,正如在中所说的“在配置应用程序以启用64K或更多方法引用之前,您应该采取步骤减少应用程序代码调用的引用总数,包括应用程序代码定义的方法或包含的库。”
defaultConfig {
applicationId "com.peoplesenergyapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true // <-add this
}
defaultConfig{
应用程序ID“com.peopleEnergyApp”
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
版本代码1
版本名称“1.0”
multiDexEnabled true/从设备/em卸载旧应用程序
cd android
./gradlew -v
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
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.