如何修复在根项目“ myProject”中找不到的任务“ $”

时间:2019-08-06 10:10:43

标签: android-gradle-plugin react-native-android

升级到RN 0.59.10后,我正在运行react-native run-android。

我已将gradle版本升级到5.4.1。 上一个运行顺利的RN版本是0.55。

尝试再次克隆项目。

我尝试了很多解决方案,例如

cd android && gradlew clean
cd .. && react-native run-android

完成并出错。

gradlew.bat

正在工作,输出:

Reading env from: .env
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: [http://d.android.com/r/tools/update-dependency-configurations.html](http://d.android.com/r/tools/update-dependency-configurations.html)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

> Task :help

Welcome to Gradle 5.4.1.

To run a build, run gradlew <task> ...

To see a list of available tasks, run gradlew tasks

To see a list of command-line options, run gradlew --help

To see more detail about a task, run gradlew help --task <task>

For troubleshooting, visit [https://help.gradle.org](https://help.gradle.org/)

BUILD SUCCESSFUL in 3s
1 actionable task: 1 executed

所有其他gradlew命令失败。

反应本机环境信息:

System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
Memory: 839.97 MB / 7.89 GB
Binaries:
npm: 6.8.0 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.4.0.0 AI-183.6156.11.34.5692245

RN

react-native-cli: 2.0.1
react-native: 0.59.10

在Android Studio中

Android Gradle插件版本

3.4.0

Gradle版本

5.4.1

android \ build.gradle

buildscript {

ext {

  buildToolsVersion = "28.0.3"
  minSdkVersion = 18
  compileSdkVersion = 28
  targetSdkVersion = 28
  supportLibVersion = "28.0.0"

}

 repositories {
  google()
  jcenter()
 }

 dependencies {
 classpath 'com.android.tools.build:gradle:3.4.0'
 classpath 'com.google.gms:google-services:4.0.2' `

gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME 
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-     all.zip
android.enableAapt2=false`

AndroidManifest.xml

在android studio中进行构建时,他要求删除这些行,而在我删除后,构建成功完成

    <uses-sdk
            android:minSdkVersion="18"
            android:targetSdkVersion="28" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.myProject"
    android:versionCode="1535480392"
    android:versionName="1.0.49">
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.INTERNET" />    
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove" />
    <uses-permission android:name="android.permission.CAMERA" tools:node="remove" />    
--> lines where here
    <application
      android:usesCleartextTraffic="true"
      android:name=".MainApplication"
      android:allowBackup="false"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:theme="@style/AppTheme">

错误react-native run-android

Reading env from: .env
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
FAILURE: Build failed with an exception.

- What went wrong:
Task '$' not found in root project 'myProject'.
- Try:
Run gradlew tasks to get a list of available tasks. 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](https://help.gradle.org/)

BUILD FAILED in 3s
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
[https://facebook.github.io/react-native/docs/getting-started.html](https://facebook.github.io/react-native/docs/getting-started.html)
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.

0 个答案:

没有答案