0

Finished with error:

ProcessException: Process "/my_project_directory/android/gradlew" exited abnormally: env: bash\r: No such file or directory

Command: /my_project_directory/android/gradlew -v

Caused by: org.gradle.api.UncheckedIOException: java.net.URISyntaxException: Illegal character in opaque part at index 2: C:\Users\Harsh\Desktop\StandardAppStructureFlutter\lib\ui\page_login.dart at org.gradle.api.internal.file.FileOrUriNotationConverter.convert(FileOrUriNotationConverter.java:119) FlutterTask.getSourceFiles(/Users/harshbhavsar/Desktop/flutter/packages/flutter_tools/gradle/flutter.gradle:604)

When I am trying to run Flutter project with any Android devices its shows me ProcessException. Its working with IOS Simulator but unable to run on Android Devices.

Versions :

Flutter (Channel master, v1.0.1-pre.2, on Mac OS X 10.13.6 17G3025, locale en-IN)

Dart 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

Android Studio (version 3.2)

Android toolchain - develop for Android devices (Android SDK 28.0.3)

Also using list of packages in flutter pubspec.yaml

dependencies:
  flutter:
    sdk: flutter
  connectivity:
  http: ^0.12.0
  path_provider:
  validate: ^1.7.0
  image_picker: ^0.4.10
  shared_preferences: "^0.4.2"
  firebase_auth: ^0.6.2+1
  flutter_facebook_login: ^1.1.1
  flutter_staggered_grid_view:
  dio:
  google_sign_in:
  cupertino_icons: ^0.1.2

My App level 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.")
}

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

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.standardappstructure"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.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'

}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
Harsh Bhavsar
  • 1,561
  • 4
  • 21
  • 39

2 Answers2

0

Go to path where Flutter SDK is installed my Flutter SDK path

i.e : C:\Flutter SDK\flutter\packages\flutter_tools\gradle

Edit the flutter.gradle file by moving

 maven {
    url 'https://dl.google.com/dl/android/maven2'
} 

to nested repositories tag above jcenter() as shown

i.e. flutter.gradle file buildscript section will look like this
buildscript {
    repositories {
        maven {
            url 'https://dl.google.com/dl/android/maven2'
        }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
    }

OR follow this link : Couldn't locate lint-gradle-api-26.1.2.jar for Flutter project

if this does not Work run the following command

flutter doctor 

then you can explore the problem try also to change Android SDK Version**

Karan Harsh Wardhan
  • 1,096
  • 9
  • 22
Mohammed Mahmoud
  • 1,138
  • 10
  • 14
0

Gradle hasn't been installed properly on the system.

Create an Android Studio Project(not a Flutter Project). Click build and it will install the required files.