Ошибка React Native Gradle: невозможно разрешить класс com.android.build.OutputFileAndroid

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Ошибка React Native Gradle: невозможно разрешить класс com.android.build.OutputFile

Сообщение Anonymous »

Я работаю над большим проектом React Native с React 18.2.0, React Native 0.74.0 и Gradle 7.3. Однако когда я пытаюсь собрать приложение, я сталкиваюсь с ошибками как в терминале, так и на вкладке «Проблемы» кода Visual Studio. Судя по моим исследованиям, эта проблема связана с несовместимостью версий Gradle и AGP, но мне не удалось найти решение. Любая помощь будет принята с благодарностью. Заранее спасибо!

Код: Выделить всё

distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-all.zip

Код: Выделить всё


buildscript {
ext {
//This for rndevice info library
googlePlayServicesIidVersion = "16.0.1"

buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
supportLibVersion = "28.0.3"
googlePlayServicesVersion = "16.1.0"
androidMapsUtilsVersion = "0.5+"
ndkVersion = "21.4.7075529"
kotlinVersion = "1.6.0"
}
Вывод на терминал:

Код: Выделить всё

PS C:\ReactNativeProjects\kaptankosku> npx react-native run-android
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
Starting a Gradle Daemon (subsequent builds will be faster)

info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor

:ReactNative:Running '[node, -e, try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}]' command failed.

FAILURE: Build failed with an exception.

* Where:
Script 'C:\ReactNativeProjects\kaptankosku\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 397
> Could not find method exec() for arguments [ReactNativeModules$_getCommandOutput_closure16@1c644dce] on object of type org.gradle.api.internal.provider.DefaultProviderFactory_Decorated.

* 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

BU�LD FAILED in 5s
error Failed to install the app. Command failed with exit code 1: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
:ReactNative:Running '[node, -e, try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}]' command failed. FAILURE: Build failed with an exception. * Where: Script 'C:\ReactNativeProjects\kaptankosku\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 397 * What went wrong: A problem occurred evaluating script. > Could not find method exec() for arguments [ReactNativeModules$_getCommandOutput_closure16@1c644dce] on object of type org.gradle.api.internal.provider.DefaultProviderFactory_Decorated. * 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 BU�LD FAILED in 5s.
info Run CLI with --verbose flag for more details.
package.json:

Код: Выделить всё

"dependencies": {
"@react-native-async-storage/async-storage": "2.0.0",
"@react-native-clipboard/clipboard": "^1.14.3",
"@react-native-community/checkbox": "^0.5.17",
"@react-native-community/cli-plugin-metro": "^12.3.6",
"@react-native-community/datetimepicker": "^8.2.0",
"@react-native-community/netinfo": "^11.4.1",
"@react-native-community/push-notification-ios": "^1.11.0",
"@react-native-firebase/app": "^21.2.0",
"@react-native-firebase/messaging": "^21.2.0",
"@react-native-masked-view/masked-view": "^0.3.1",
"@react-navigation/bottom-tabs": "6.6.1",
"@react-navigation/native": "6.1.18",
"@react-navigation/stack": "6.4.1",
"@types/react-native-push-notification": "^8.1.4",
"axios": "^1.7.7",
"fbjs": "^3.0.5",
"i18next": "23.16.4",
"moment": "^2.30.1",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-i18next": "15.1.0",
"react-native": "^0.74.0",
"react-native-animatable": "1.4.0",
"react-native-appearance": "^0.0.0",
"react-native-blob-util": "^0.19.11",
"react-native-calendars": "1.1307.0",
"react-native-device-info": "^14.0.0",
"react-native-dotenv": "^3.4.11",
"react-native-fast-image": "8.6.3",
"react-native-gesture-handler": "2.20.2",
"react-native-get-location": "^5.0.0",
"react-native-image-picker": "^7.1.2",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-maps": "1.18.2",
"react-native-modal": "13.0.1",
"react-native-modal-datetime-picker": "^18.0.0",
"react-native-pager-view": "6.4.1",
"react-native-pdf": "^6.7.5",
"react-native-push-notification": "^8.1.1",
"react-native-quick-md5": "^3.0.6",
"react-native-reanimated": "3.16.1",
"react-native-restart": "0.0.27",
"react-native-safe-area-context": "4.12.0",
"react-native-screens": "^3.35.0",
"react-native-share": "^11.0.4",
"react-native-splash-screen": "3.3.0",
"react-native-swiper": "1.6.0",
"react-native-tab-view": "3.5.2",
"react-native-vector-icons": "10.2.0",
"react-native-webview": "^13.12.3",
"react-redux": "9.1.2",
"redux": "5.0.1",
"redux-logger": "3.0.6",
"redux-persist": "6.0.0",
"redux-thunk": "3.1.0",
"rn-range-slider": "2.2.2"
},
"devDependencies": {
"@babel/core": "^7.26.0",
"@babel/plugin-transform-async-generator-functions": "^7.25.9",
"@babel/plugin-transform-class-properties": "^7.25.9",
"@babel/plugin-transform-logical-assignment-operators": "^7.25.9",
"@babel/plugin-transform-nullish-coalescing-operator": "^7.25.9",
"@babel/plugin-transform-numeric-separator": "^7.25.9",
"@babel/plugin-transform-object-rest-spread": "^7.25.9",
"@babel/plugin-transform-optional-catch-binding": "^7.25.9",
"@babel/plugin-transform-optional-chaining": "^7.25.9",
"@babel/preset-env":  "^7.26.0",
"@babel/preset-react": "^7.25.9",
"@babel/runtime": "^7.26.0",
"@babel/traverse": "^7.25.9",
"@react-native-community/eslint-config": "^3.2.0",
"@typescript-eslint/eslint-plugin": "^8.11.0",
"babel-jest": "^29.7.0",
"babel-plugin-transform-remove-console": "^6.9.4",
"eslint": "^8.57.0",
"eslint-plugin-ft-flow": "^3.0.11",
"eslint-plugin-jest": "^28.8.3",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-native": "^4.1.0",
"glob": "^11.0.0",
"jest": "^29.7.0",
"jetifier": "^2.0.0",
"metro-react-native-babel-preset": "^0.77.0",
"prettier": "^3.3.3",
"react-native-codegen": "^0.70.7",
"react-test-renderer": "18.2.0",
"rimraf": "^6.0.1"
}
Я пытался выполнить синхронизацию Gradle в Android Studio, но не получил никаких результатов.

Подробнее здесь: https://stackoverflow.com/questions/791 ... outputfile
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»