NervJS / taro

开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
https://docs.taro.zone/
Other
35.59k stars 4.8k forks source link

新建项目运行android环境失败 #13332

Open CodFrm opened 1 year ago

CodFrm commented 1 year ago

相关平台

React Native

使用框架: React

复现步骤

taro init 创建完成项目

taro upgradePeerdeps

taro podInstall

taro android

期望结果

能够运行android环境

实际结果

产生如下错误:

yarn run v1.22.17
$ react-native run-android
info JS server already running.
info Launching emulator...
info Successfully launched emulator.
info Installing the app...

> Task :react-native-gradle-plugin:compileKotlin
w: /Users/codfrm/Code/caco/caco-mobile/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (10, 37): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/caco-mobile/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (119, 30): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/caco-mobile/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (135, 26): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/caco-mobile/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (157, 32): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/caco-mobile/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (163, 31): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/caco-mobile/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (171, 36): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/caco-mobile/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt: (114, 48): 'reactRoot: DirectoryProperty' is deprecated. reactRoot was confusing and has been replace with root to point to your root project and reactNativeDir to point to the folder of the react-native NPM package
w: /Users/codfrm/Code/caco/caco-mobile/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (10, 37): 'ApplicationVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/caco-mobile/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (11, 37): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/caco-mobile/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (12, 37): 'LibraryVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/caco-mobile/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (27, 51): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/caco-mobile/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (130, 12): 'ApplicationVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/caco-mobile/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (131, 12): 'LibraryVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/caco-mobile/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (251, 14): 'BaseVariant' is deprecated. Deprecated in Java

> Configure project :expo-application
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :expo-av
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
5 actionable tasks: 1 executed, 4 up-to-date

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Script '/Users/codfrm/Code/caco/caco-mobile/node_modules/expo-modules-autolinking/scripts/android/autolinking_implementation.gradle' line: 272

* What went wrong:
A problem occurred evaluating project ':expo'.
> A problem occurred configuring project ':expo-av'.
   > Failed to notify project evaluation listener.
      > java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because "versionOutput" is null
      > Could not get unknown property 'release' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.

* 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: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':expo'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle

* 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 9s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Script '/Users/codfrm/Code/caco/caco-mobile/node_modules/expo-modules-autolinking/scripts/android/autolinking_implementation.gradle' line: 272

* What went wrong:
A problem occurred evaluating project ':expo'.
> A problem occurred configuring project ':expo-av'.
   > Failed to notify project evaluation listener.
      > java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because "versionOutput" is null
      > Could not get unknown property 'release' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.

* 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: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':expo'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle

* 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 9s

    at makeError (/Users/codfrm/Code/caco/caco-mobile/node_modules/execa/index.js:174:9)
    at /Users/codfrm/Code/caco/caco-mobile/node_modules/execa/index.js:278:16
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runOnAllDevices (/Users/codfrm/Code/caco/caco-mobile/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
    at async Command.handleAction (/Users/codfrm/Code/caco/caco-mobile/node_modules/@react-native-community/cli/build/index.js:142:9)
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

环境信息

👽 Taro v3.6.1

  Taro CLI 3.6.1 environment info:
    System:
      OS: macOS 13.0.1
      Shell: 5.8.1 - /bin/zsh
    Binaries:
      Node: 16.19.0 - /opt/homebrew/opt/node@16/bin/node
      Yarn: 1.22.17 - /opt/homebrew/bin/yarn
      npm: 8.19.3 - /opt/homebrew/opt/node@16/bin/npm
    npmPackages:
      @tarojs/cli: 3.6.1 => 3.6.1 
      @tarojs/components: 3.6.1 => 3.6.1 
      @tarojs/helper: 3.6.1 => 3.6.1 
      @tarojs/plugin-framework-react: 3.6.1 => 3.6.1 
      @tarojs/plugin-platform-alipay: 3.6.1 => 3.6.1 
      @tarojs/plugin-platform-h5: 3.6.1 => 3.6.1 
      @tarojs/plugin-platform-jd: 3.6.1 => 3.6.1 
      @tarojs/plugin-platform-qq: 3.6.1 => 3.6.1 
      @tarojs/plugin-platform-swan: 3.6.1 => 3.6.1 
      @tarojs/plugin-platform-tt: 3.6.1 => 3.6.1 
      @tarojs/plugin-platform-weapp: 3.6.1 => 3.6.1 
      @tarojs/react: 3.6.1 => 3.6.1 
      @tarojs/rn-runner: 3.6.1 => 3.6.1 
      @tarojs/rn-supporter: 3.6.1 => 3.6.1 
      @tarojs/runtime: 3.6.1 => 3.6.1 
      @tarojs/runtime-rn: 3.6.1 => 3.6.1 
      @tarojs/shared: 3.6.1 => 3.6.1 
      @tarojs/taro: 3.6.1 => 3.6.1 
      @tarojs/taro-rn: 3.6.1 => 3.6.1 
      @tarojs/webpack5-runner: 3.6.1 => 3.6.1 
      babel-preset-taro: 3.6.1 => 3.6.1 
      eslint-config-taro: 3.6.1 => 3.6.1 
      expo: ~47.0.3 => 47.0.13 
      react: ^18.1.0 => 18.2.0 
      react-native: ^0.70.1 => 0.70.7 
    npmGlobalPackages:
      typescript: 4.6.4
CodFrm commented 1 year ago

android相关环境:

image image image
zhiqingchen commented 1 year ago

试试

https://github.com/zhiqingchen/taro-test/tree/tests/3.6.1

CodFrm commented 1 year ago

@zhiqingchen 依旧是这一个错误:

yarn run v1.22.17
$ react-native run-android
info Starting JS server...
* daemon not running; starting now at tcp:5037
* daemon started successfully
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
Starting a Gradle Daemon (subsequent builds will be faster)

> Task :react-native-gradle-plugin:compileKotlin
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (10, 37): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (119, 30): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (135, 26): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (157, 32): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (163, 31): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (171, 36): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt: (114, 48): 'reactRoot: DirectoryProperty' is deprecated. reactRoot was confusing and has been replace with root to point to your root project and reactNativeDir to point to the folder of the react-native NPM package
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (10, 37): 'ApplicationVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (11, 37): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (12, 37): 'LibraryVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (27, 51): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (130, 12): 'ApplicationVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (131, 12): 'LibraryVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (251, 14): 'BaseVariant' is deprecated. Deprecated in Java

> Configure project :expo-application
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :expo-av
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
5 actionable tasks: 5 executed

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Script '/Users/codfrm/Code/caco/taro-test/node_modules/expo-modules-autolinking/scripts/android/autolinking_implementation.gradle' line: 272

* What went wrong:
A problem occurred evaluating project ':expo'.
> A problem occurred configuring project ':expo-av'.
   > Failed to notify project evaluation listener.
      > java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because "versionOutput" is null
      > Could not get unknown property 'release' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.

* 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: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':expo'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle

* 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 18s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Script '/Users/codfrm/Code/caco/taro-test/node_modules/expo-modules-autolinking/scripts/android/autolinking_implementation.gradle' line: 272

* What went wrong:
A problem occurred evaluating project ':expo'.
> A problem occurred configuring project ':expo-av'.
   > Failed to notify project evaluation listener.
      > java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because "versionOutput" is null
      > Could not get unknown property 'release' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.

* 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: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':expo'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle

* 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 18s

    at makeError (/Users/codfrm/Code/caco/taro-test/node_modules/execa/index.js:174:9)
    at /Users/codfrm/Code/caco/taro-test/node_modules/execa/index.js:278:16
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runOnAllDevices (/Users/codfrm/Code/caco/taro-test/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
    at async Command.handleAction (/Users/codfrm/Code/caco/taro-test/node_modules/@react-native-community/cli/build/index.js:142:9)
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
zhiqingchen commented 1 year ago

建议检查开发环境,以及对比正常编译过程

https://github.com/zhiqingchen/taro-test/actions/runs/4161455307

CodFrm commented 1 year ago

mac m1 环境 官方react native创建的可正常运行,taro创建的报如上错误

编译过程,是参考官方文档,根据上述github action命令,也错误

zhiqingchen commented 1 year ago

项目提交到git上,我看看

CodFrm commented 1 year ago

@zhiqingchen 就是此项目:https://github.com/zhiqingchen/taro-test/tree/tests/3.6.1,全新创建的模板也不行

CodFrm commented 1 year ago

执行yarn build:rn --platform android成功,但是yarn android失败

 codfrm@192  ~/Code/caco/taro-test   master  yarn build:rn --platform android
yarn run v1.22.17
$ taro build --type rn --platform android
👽 Taro v3.6.1

                Welcome to Metro v0.72.3
              Fast - Scalable - Integrated

watchman warning:  Recrawled this watch 21 times, most recently because:
MustScanSubDirs UserDroppedTo resolve, please review the information on
https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl
To clear this warning, run:
`watchman watch-del '/Users/codfrm/Code/caco/taro-test' ; watchman watch-project '/Users/codfrm/Code/caco/taro-test'`

Recrawled this watch 21 times, most recently because:
MustScanSubDirs UserDroppedTo resolve, please review the information on
https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl
To clear this warning, run:
`watchman watch-del '/Users/codfrm/Code/caco/taro-test' ; watchman watch-project '/Users/codfrm/Code/caco/taro-test'`

info Writing bundle output to:, ./android/app/src/main/assets/index.android.bundle
info Writing sourcemap output to:, ./android/app/src/main/assets/index.android.map
info Done writing bundle output
info Done writing sourcemap output
info Copying 6 asset files
info Done copying assets
✨  Done in 4.58s.
 codfrm@192  ~/Code/caco/taro-test   master  yarn android
yarn run v1.22.17
$ react-native run-android
info Starting JS server...
info Launching emulator...
info Successfully launched emulator.
info Installing the app...

> Task :react-native-gradle-plugin:compileKotlin
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (10, 37): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (119, 30): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (135, 26): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (157, 32): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (163, 31): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (171, 36): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt: (114, 48): 'reactRoot: DirectoryProperty' is deprecated. reactRoot was confusing and has been replace with root to point to your root project and reactNativeDir to point to the folder of the react-native NPM package
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (10, 37): 'ApplicationVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (11, 37): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (12, 37): 'LibraryVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (27, 51): 'BaseVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (130, 12): 'ApplicationVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (131, 12): 'LibraryVariant' is deprecated. Deprecated in Java
w: /Users/codfrm/Code/caco/taro-test/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt: (251, 14): 'BaseVariant' is deprecated. Deprecated in Java

> Configure project :expo-application
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :expo-av
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
5 actionable tasks: 5 executed

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Script '/Users/codfrm/Code/caco/taro-test/node_modules/expo-modules-autolinking/scripts/android/autolinking_implementation.gradle' line: 272

* What went wrong:
A problem occurred evaluating project ':expo'.
> A problem occurred configuring project ':expo-av'.
   > Failed to notify project evaluation listener.
      > java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because "versionOutput" is null
      > Could not get unknown property 'release' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.

* 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: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':expo'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle

* 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 8s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Script '/Users/codfrm/Code/caco/taro-test/node_modules/expo-modules-autolinking/scripts/android/autolinking_implementation.gradle' line: 272

* What went wrong:
A problem occurred evaluating project ':expo'.
> A problem occurred configuring project ':expo-av'.
   > Failed to notify project evaluation listener.
      > java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because "versionOutput" is null
      > Could not get unknown property 'release' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.

* 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: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':expo'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle

* 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 8s

    at makeError (/Users/codfrm/Code/caco/taro-test/node_modules/execa/index.js:174:9)
    at /Users/codfrm/Code/caco/taro-test/node_modules/execa/index.js:278:16
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runOnAllDevices (/Users/codfrm/Code/caco/taro-test/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
    at async Command.handleAction (/Users/codfrm/Code/caco/taro-test/node_modules/@react-native-community/cli/build/index.js:142:9)
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
zhiqingchen commented 1 year ago

https://github.com/zhiqingchen/taro-test/actions/runs/4248901606 https://github.com/zhiqingchen/taro-test/actions/runs/4248902499

重跑的也是正常的,可以尝试使用 Android studio 试一下,以及搜索相关问题,https://github.com/expo/expo/issues/18129

CodFrm commented 1 year ago

使用Android studio build也是类似的错误:相关问题的解决方案,好像并不适合我

image
k1287988804 commented 1 year ago

一样的问题,不知道怎么解决

CodFrm commented 1 year ago

使用npm 作为包管理工具,提示如下问题:

codfrm@wangyizhideMacBook-Pro  ~/Code/caco/caco-mobile   master  npm i
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: caco-mobile@1.0.0
npm ERR! Found: react@18.2.0
npm ERR! node_modules/react
npm ERR!   react@"^18.1.0" from the root project
npm ERR!   peerOptional react@">=17" from @tarojs/plugin-framework-react@3.6.1
npm ERR!   node_modules/@tarojs/plugin-framework-react
npm ERR!     @tarojs/plugin-framework-react@"3.6.1" from the root project
npm ERR!   1 more (react-dom)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! react-native@"^0.70.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react@18.1.0
npm ERR! node_modules/react
npm ERR!   peer react@"18.1.0" from react-native@0.70.7
npm ERR!   node_modules/react-native
npm ERR!     react-native@"^0.70.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/codfrm/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/codfrm/.npm/_logs/2023-02-24T08_06_50_545Z-debug-0.log
zhiqingchen commented 1 year ago

image image image

找了台机器复现了这个问题(原因是ndk没有设置好),用 as 可以编译成功,以上配置供参考

zhiqingchen commented 1 year ago

https://github.com/expo/expo/issues/19614#issuecomment-1285815891

CodFrm commented 1 year ago

android 11?我看官方的文档说是12,所以我就没有安装11,我再试试,谢谢大佬

CodFrm commented 1 year ago

还是没有成功,Android studio也重新安装了,同样的内容找朋友的电脑试了一下,可以,大概率是我自己环境问题了,但是不知道出在哪里

codfrm@192  ~  taro -v
👽 Taro v3.6.1

3.6.1
 codfrm@192  ~  node -v
v16.19.0
 codfrm@192  ~  npm -v
8.19.3
 codfrm@192  ~  yarn -v
1.22.19
 codfrm@192  ~  java --version
openjdk 11.0.18 2023-01-17 LTS
OpenJDK Runtime Environment Zulu11.62+17-CA (build 11.0.18+10-LTS)
OpenJDK 64-Bit Server VM Zulu11.62+17-CA (build 11.0.18+10-LTS, mixed mode)
 codfrm@192  ~  echo $ANDROID_HOME
/Users/codfrm/Library/Android/sdk
yoyo837 commented 1 year ago

使用Android studio build也是类似的错误:相关问题的解决方案,好像并不适合我

image

这个报错信息给的方向排除一下呢?

CodFrm commented 1 year ago

@yoyo837 什么意思呢?不太懂

CodFrm commented 1 year ago
image

有这么一个错误,不知道有没有影响,看配置看不太出来,感觉没问题

disappointao commented 1 year ago

老哥,我也是mac m1 ,官方搭建的脚手架可以,taro模板运行不了。研究了一下解决了,把官方脚手架那个build.gradle文件的buildscript配置替换到taro模板对应配置,然后使用 ./gradlew clean清下缓存再执行命令就可以了 image

CodFrm commented 1 year ago

@disappointao 感谢老哥,不过我好像还是一样报错,很久都没弄了,官方的脚手架好像也跑不了了,到时候需要开发android的时候我再来看看

tianlinzz commented 1 year ago

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

兄弟我也是拉到taro社区模板也报错 就是编译成安卓应用不通过,是不是社区模板的配置有问题呀。毕竟咱们的环境跑rn自己的社区模板是没问题的但是跑taro的就会编译报错

tianlinzz commented 1 year ago

image

tianlinzz commented 1 year ago

感觉主要是这个包的问题但是不知道怎么解决啊