在flutter中找不到参数android()的方法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在flutter中找不到参数android()的方法相关的知识,希望对你有一定的参考价值。

我将本地android库(.aar)推送到我的flutter项目中,并在android diractory中更改gradle文件,这是我的build.gradle

buildscript 
repositories 

    google()
    jcenter()
    maven  url 'https://maven.fabric.io/public' 

dependencies 
    classpath 'com.android.tools.build:gradle:3.3.0'
    classpath 'io.fabric.tools:gradle:1.+'






allprojects 
repositories 

    google()
    jcenter()
    flatDir
            
                dirs 'pecpayment-release'
            
    Maven  url 'https://maven.fabric.io/public' 


  
 

  rootProject.buildDir = '../build'
 subprojects 
 project.buildDir = "$rootProject.buildDir/$project.name"
 
subprojects 
project.evaluationDependsOn(':app')


task clean(type: Delete) 
delete rootProject.buildDir

这是我的app / build.gradle

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) 
localPropertiesFile.withReader('UTF-8')  reader ->
    localProperties.load(reader)



def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) 
throw new GradleException("Flutter SDK not found. Define location with          flutter.sdk in the local.properties file.")


def flutterVersionCode =     localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) 
flutterVersionCode = '1'


def flutterVersionName =                                                localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) 
flutterVersionName = '1.0'


apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android 
compileSdkVersion 28
lintOptions 
    disable 'InvalidPackage'


defaultConfig 
    // TODO: Specify your own unique Application ID       (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.shabakieh.art_man"
    minSdkVersion 22
    targetSdkVersion 28
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"


buildTypes 
    release 
        // TODO: Add your own signing config for the release build.
        // Signing with the debug keys for now, so `flutter run --release` works.
        signingConfig signingConfigs.debug
    



 flutter 
source '../..'
 

 dependencies 
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-        core:3.0.2'
androidTestCompile 'com.android.support:support-annotations:22.0.0'


implementation project(':pecpayment-release')
implementation fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:LAST_VER'
implementation 'com.android.support:design:LAST_VER'
implementation (name:'pecpayment-release', ext:'aar')
implementation 'com.mcxiaoke.volley:library:1.0.19'
implementation ('com.crashlytics.sdk.android:crashlytics:2.10.1@aar')
    transitive = true;
 

 

但是在构建我的项目时出现此错误

 * Error running Gradle:
ProcessException: Process "C:\Users\Mohammad\Desktop\flutter    project\ArtMan\android\gradlew.bat" exited abnormally:

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\Mohammad\Desktop\flutter project\ArtMan\android  \build.gradle' line: 27

* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not find method Maven() for arguments   [build_c9fbu96kunvkjy5e4z3tft0zv$_run_closure1$_closure5$_closure7@4ff63451]     on repository container of type   org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler.

* 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 3s
Command: C:\Users\Mohammad\Desktop\flutter project\ArtMan\android   \gradlew.bat app:properties

Finished with error: Please review your Gradle project setup in the     android/ folder.

我从该站点和github读取了许多代码并对其进行了测试,但是没有任何效果,我不知道如何解决它,如何找到maven问题呢

答案

更改此(在repositories内部):

 Maven  url 'https://maven.fabric.io/public' 

进入此:

 maven  url 'https://maven.fabric.io/public' 

maven()方法包含小写的m

以上是关于在flutter中找不到参数android()的方法的主要内容,如果未能解决你的问题,请参考以下文章

Flutter配置好后,在Android Studio中找不到设备,no devices

在 Flutter/Android 构建中找不到 protoc-3.9.2-osx

在使用 Flutter 时,我在 Android Studio 4.2 中找不到用于修复图标的“图像资源”

在 Flutter 项目中找不到 layout.xml

Flutter:kotlin在java安装中找不到需要的jdk工具

在 Android Studio 项目中找不到参数的方法 android()