Android Gradle问题-扑动/ dart

8qgya5xd  于 2023-03-08  发布在  Android
关注(0)|答案(6)|浏览(127)

我的Gradle同步出现问题。
我使用IntelliJ和Android Studio构建了一个Flutter / Dart应用程序。
我添加了2个新的依赖项,现在我遇到了Gradle的问题。在Android Studio中,一切正常(Gradle同步完成,没有失败或警告),但在IntelliJ中,它不工作。

* Error running Gradle: Exit code 1 from: C:\Users\stesc\Documents\Programming\timecoder-flutter\android\gradlew.bat app:properties: NDK is missing a "platforms" directory. If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to C:\Users\stesc\AppData\Local\Android\Sdk\ndk-bundle. If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

BUILD FAILED

Total time: 4.669 secs

FAILURE: Build failed with an exception.

* Where:

Build file 'C:\Users\stesc\Documents\Programming\timecoder-flutter\android\build.gradle' line: 25

* What went wrong: A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
   > Could not resolve all dependencies for configuration ':app:_debugApk'. Finished with error: Please review your Gradle project setup in the android/ folder.
      > A problem occurred configuring project ':shared_preferences'.
         > Could not resolve all dependencies for configuration ':shared_preferences:classpath'.
            > Could not find com.android.tools.build:gradle:3.0.1.
              Searched in the following locations:
                  https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
                  https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
              Required by:
                  project :shared_preferences

* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

toe95027

toe950271#

1.从项目-〉android -〉构建更新您的Gradle版本

dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
}

2.使用最新的sdk工具版本
3.工具-〉Flutter打开终端并运行以下命令

flutter upgrade
flutter doctor
cygmwpex

cygmwpex2#

使所有对象-〉存储库构建脚本-〉存储库相同
如果问题仍然存在,请检查您的项目和shared_preferences是否使用相同的gradle版本,如果不是,您可能需要在您的项目或shared_preferences项目中进行少量更改。

lvmkulzt

lvmkulzt3#

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "27.1.0"
            }
        }
    }
}

它为我修复了添加到我的build.gradle在android文件夹。

mrphzbgm

mrphzbgm4#

  • yaa它已经为我解决了...!只需转到flutter sdk文件夹,然后转到此路径\flutter\packages\flutter_tools\gradle\flutter.gradle,并在flutter.gradle文件中更改此代码
buildscript { 
        repositories { 
          jcenter() 
     maven { 
      url 'https://dl.google.com/dl/android/maven2' 
   }
 } 
dependencies { 
         classpath 'com.android.tools.build:gradle:3.1.2' 
       } 
     }
m2xkgtsf

m2xkgtsf5#

我有同样的问题,并解决了它太。也许,将是有用的人。这是我的问题:

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/abc/Desktop/user/project/android/app/build.gradle' line: 14

* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.internal.version-check']
   > Minimum supported Gradle version is 5.6.4. Current version is 5.4.1. If using the gradle wrapper, try editing the distributionUrl in
   /Users/abc/Desktop/user/project/android/gradle/wrapper/gradle-wrapper.properties to gradle-5.6.4-all.zip

* 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
  Command: /Users/abc/Desktop/user/project/android/gradlew app:properties

Please review your Gradle project setup in the android/ folder.

我去了gradle-wrapper.properties,把这一行改了:

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

问题解决了。

jhdbpxl9

jhdbpxl96#

尝试转到android/gradle文件夹,然后找到 Package 器并将其编辑为最新版本,例如7.6-bin,然后转到应用程序gradle并将Kotlin版本重命名为1.7.0,将构建工具重命名为7.4.0,如下所示。

distributionBase=GRADLE_USER_HOME distributionUrl=https\://services.gradle.org/distributions/gradle-7.6- bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME

buildscript { ext.kotlin_version = '1.7.0' repositories {
    google()
    mavenCentral() }

dependencies {
    classpath 'com.android.tools.build:gradle:7.4.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" }

相关问题