如何解决此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 7.0 不兼容为什么会出现这个错误?
对使用 React Native Maps 非常陌生。
我正在尝试使用 React Native Maps。我跟着一步一步的教程,我来到了这个错误:
J:\reactnativeTut\mapsExample>react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
(node:20720) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
Jetifier found 1415 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
> Task :app:processDebugResources Failed
Deprecated Gradle features were used in this build,making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
26 actionable tasks: 2 executed,24 up-to-date
FAILURE: Build Failed with an exception.
* What went wrong:
Execution Failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking Failed
C:\Users\xxx\.gradle\caches\transforms-2\files-2.1\1cb9b9ea592aa2ea85233be252327dcf\appcompat-1.1.0\res\values-v28\values-v28.xml:5:5-8:13: AAPT: error: resource android:attr/dialogCornerRadius not found.
C:\Users\xxx\.gradle\caches\transforms-2\files-2.1\1cb9b9ea592aa2ea85233be252327dcf\appcompat-1.1.0\res\values-v28\values-v28.xml:9:5-12:13: AAPT: error: resource android:attr/dialogCornerRadius not found.
C:\Users\xxx\.gradle\caches\transforms-2\files-2.1\639e914bfc1efa21e36199d3ff2c5eef\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontvariationSettings not found.
C:\Users\xxx\.gradle\caches\transforms-2\files-2.1\639e914bfc1efa21e36199d3ff2c5eef\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcIndex not found.
C:\Users\xxx\.gradle\caches\transforms-2\files-2.1\1cb9b9ea592aa2ea85233be252327dcf\appcompat-1.1.0\res\values\values.xml:2772:5-2795:25: AAPT: error: resource android:attr/textFontWeight not found.
* 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.
* Get more help at https://help.gradle.org
BUILD Failed in 7s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command Failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
J:\reactnativeTut\mapsExample>
我不明白为什么我会收到这个错误。
我的代码看起来像这样
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
// ext {
// buildToolsversion = "29.0.2"
// minSdkVersion = 16
// compileSdkVersion = 29
// targetSdkVersion = 29
// }
ext {
buildToolsversion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 26
targetSdkVersion = 26
supportLibVersion = "26.1.0"
playServicesversion = "17.0.0" // or find latest version
androidMapsUtilsversion = "0.5+"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.3")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS,Obj-C sources,Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mapsexample">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<Meta-data
android:name="com.google.android.geo.API_KEY"
android:value="API_KEY"/>
</application>
</manifest>
Package.json
{
"name": "mapsExample","version": "0.0.1","private": true,"scripts": {
"android": "react-native run-android","ios": "react-native run-ios","start": "react-native start","test": "jest","lint": "eslint ."
},"dependencies": {
"react": "16.13.1","react-native": "0.63.4","react-native-maps": "^0.27.1"
},"devDependencies": {
"@babel/core": "7.12.10","@babel/runtime": "7.12.5","@react-native-community/eslint-config": "1.1.0","babel-jest": "25.5.1","eslint": "6.8.0","jest": "25.5.4","metro-react-native-babel-preset": "0.59.0","react-test-renderer": "16.13.1"
},"jest": {
"preset": "react-native"
}
}
请帮忙。我对使用地图很陌生。从那以后,我一直在寻找真正有用的东西,没有什么可展示的。
解决方法
你可以用这个命令试试
cd android
gradlew clean
如果这也不起作用,请检查以下错误,因为它的抛出错误为 任务“:app:processDebugResources”的执行失败。这意味着调试资源存在一些问题。由于您看到路径是缓存,这就是我要求您清理 gradlew 的原因。
res\values-v28\values-v28.xml:5:5-8:13: AAPT: error: resource android:attr/dialogCornerRadius not found.
,
我设法修复了错误。 希望这对未来的人有所帮助。
现在显示地图。但它们很小:(
代码错误位于 android\build.gradle
文件中。像这样重命名 ext
部分会显示地图。虽然地图很小
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
supportLibVersion = "29.1.0"
playServicesVersion = "17.0.0" // or find latest version
androidMapsUtilsVersion = "0.5+"
}
我希望它可以帮助以后的人。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。