Reputation: 79
I have an app I'm working on and when I open build.gradle
file
Several errors appeared
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 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.example.shopapp"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
Console Output:
Launching lib\main.dart on AOSP on IA Emulator in debug mode... Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:stripDebugDebugSymbols'.
No version of NDK matched the requested version 20.0.5594570. Versions available locally: 21.0.6113669
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 1s Finished with error: Gradle task assembleDebug failed with exit code 1
Also there is a message in logcat
Please configure Android SDK
I looked for a solution and did not find a solution for it
I just need help and don't know if I have violated the laws of the site because I do not speak English fluently
Upvotes: 8
Views: 10788
Reputation: 2623
Modify app/build.gradle with adding ndkVersion. I have used below version. You have to use your compatible version
Upvotes: 3
Reputation: 5482
Try changing your classpath in android/build.gradle to
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
...
}
and make sure sure your gradle/wrapper/gradle-wrapper.properties has
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
or version as indicacted here https://developer.android.com/studio/releases/gradle-plugin
Upvotes: 2
Reputation: 340
modify app\build.gradle file to be like that: add this inside the android block
ndkVersion "21.0.6113669"
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 = '2'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.1'
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
ndkVersion "21.0.6113669"
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.dawamisr.app"
minSdkVersion 19
targetSdkVersion 28
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.1.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' implementation 'com.google.firebase:firebase-core:17.2.1' implementation 'com.google.firebase:firebase-messaging:20.1.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" }
apply plugin: 'com.google.gms.google-services' apply plugin: 'kotlin-android'
Upvotes: 1
Reputation: 166
This issue is due to incompatibility with the latest android gradle plugin version. You can try to downgrade its version to 3.5.0 in your android/build.gradle
:
classpath 'com.android.tools.build:gradle:3.5.0'
Upvotes: 7
Reputation: 23
Upvotes: 1
Reputation: 79
The solution is to reinstall Android Studio Taking into account the correct installation of (Java & All packages) from android studio
Upvotes: -1
Reputation: 111
one of the solutions is this,
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 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.example.shopapp"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
signingConfig signingConfigs.debug
}
}
ndkVersion "21.0.6113669" /// <<---Add this,
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
The reason is because you have installed other NDK, and android studio has other version, the other solutions is, -> Go to sdk tools, and uninstall NDK and Cmake.
Sorry for my english, im not native speaker. Good luck!
Upvotes: 11