I have some problems while running flutter in android studio
This is my error
Launching lib\main.dart on Moto C Plus in debug mode...
Initializing gradle...
Resolving dependencies...
Finished with error: Please review your Gradle project setup in the android/ folder.
* Error running Gradle:
Exit code 1 from: D:\FlutterPrograms\app\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 E:\Sdk\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
FAILURE: Build failed with an exception.
Where:
Build file 'D:\FlutterPrograms\app\android\app\build.gradle' line: 25
What went wrong:
A problem occurred evaluating project ':app'.
Could not resolve all artifacts for configuration 'classpath'.
Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar
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
This is my buid.gradle file
buildscript {
repositories {
maven {
url 'https://dl.google.com/dl/android/maven2'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my gradle error
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 27
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.shanmukh.app"
minSdkVersion 16
targetSdkVersion 27
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'
}
There were lots of similar issues raised the past days, that could be solved by adding the google() repository in first position in the repositories block of the build scripts.
See detailed explanation in the following answers:
couldn't locate lint-gradle-api-26.1.2.jar for flutter project
Could not find play-services-basement.aar
https://stackoverflow.com/a/52982816/6899896
Could not find com.android.tools.build:aapt2:3.2.0
The root cause , related to missing libraries in Jcenter, is explained in detail here : https://stackoverflow.com/a/50885939/6899896
Open the root flutter folder in your computer, and open the gradle folder in that root folder (For example C:\flutter\package\flutter_tool\gradle) and add 'google()' to the buildscript. It fixed the issue for me.
Flutter root folder:
Add 'google()' to the buildscript:
I found a solution!
Go to your flutter folder. After you need to find flutter.gradle. On my PC:
C:\src\flutter\packages\flutter_tools\gradle
Open flutter.gradle with note or notepad and change
buildscript from this:
repositories {
jcenter()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
}
to this:
repositories {
maven {
url 'https://dl.google.com/dl/android/maven2'
}
jcenter()
}
Related
Recently after upgrading android studio 4.1 my app started to stuck in "running gradle task assembledebug" so i checked the web for possible solution
Tried flutter clean and gradle commands changed gradle files but nothing worked finally deleted gradle and reinstalled android studio again but now i can't get android sdk 28 to be installed (it doesnt appear in sdk list) so i changed sdk to 29 but whenever i try to run my app it gives the fallowing errors
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:3.5.3.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.5.3.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.3/gradle-3.5.3.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.3/gradle-3.5.3.pom'.
> Connect to localhost:3128 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
> Could not resolve com.android.tools.build:gradle:3.5.3.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.3/gradle-3.5.3.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.3/gradle-3.5.3.pom'.
> Connect to localhost:3128 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
> Could not resolve com.google.gms:google-services:4.3.4.
Required by:
project :
> Could not resolve com.google.gms:google-services:4.3.4.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.3.4/google-services-4.3.4.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.3.4/google-services-4.3.4.pom'.
> Connect to localhost:3128 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
> Could not resolve com.google.gms:google-services:4.3.4.
> Could not get resource 'https://jcenter.bintray.com/com/google/gms/google-services/4.3.4/google-services-4.3.4.pom'.
> Could not GET 'https://jcenter.bintray.com/com/google/gms/google-services/4.3.4/google-services-4.3.4.pom'.
> Connect to localhost:3128 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
* 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
BU�LD FAILED in 1m 24s
Exception: Gradle task assembleDebug failed with exit code 1
My current project level build gradle file is like this.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.4'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App lvl build gradle file is like 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 29
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.farukdurusoy.sayi_avi"
minSdkVersion 16
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
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 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
apply plugin: 'com.google.gms.google-services'
Also disabled my firewalls. Any suggestions?
I want to build APK Flutter with android studio. I also use firestore in this application. When i try to build, i get this error
Exception in thread "ForkJoinPool.commonPool-worker-0" java.lang.IllegalStateException: AAPT Process manager cannot be shut down while daemons are in use
at com.android.builder.internal.aapt.v2.Aapt2DaemonManager.shutdown(Aapt2DaemonManager.kt:96)
at com.android.build.gradle.internal.res.namespaced.RegisteredAaptService.shutdown(Aapt2DaemonManagerService.kt:61)
at com.android.build.gradle.internal.workeractions.WorkerActionServiceRegistry$shutdownAllRegisteredServices$1$1.run(WorkerActionServiceRegistry.kt:96)
at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
Output: D:\Compile\ttpproject\android\app\src\main\res\mipmap-hdpi\book.png: error: failed to read PNG signature: file does not start with PNG signature.
Command: C:\Users\hunterpama\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\d657dbace268bb20677284d59b1f0de8\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
-o \
D:\Compile\ttpproject\build\app\intermediates\res\merged\release \
D:\Compile\ttpproject\android\app\src\main\res\mipmap-hdpi\book.png
Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
* 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 1m 28s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 89.1s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
*******************************************************************************************
Gradle task assembleRelease failed with exit code 1
here my file for: android\app\build.gradle
and on application id i not left empty. I just do not want to display it here
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: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId ""
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// 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 {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
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'
i just wonder is there any confusion in sync with flutter and android. During debug, it works fine. NO error popup
i have know the reason of it. it because of image size. but i do not have proper image size for build.
Migrate your project to AndroidX.
If you have AndroidStudio 3.2 or greater you can refactor
It looks like you might have tried to build your Flutter APK using Android Studio. You need to go to your Flutter console, navigate to your project, and type this is the command line: flutter build apk --split-per-abi
I am getting this error in the gradle file:
Error: Failed to resolve: com.google.android.gms:play-services-measurement:10.2.4
-Install Repository and sync project
-Open File
-Show in Project Structure dialog
But I don't use the play-services-measurement in my app.
In the other hand, if I click on the link "Install Repository and sync project" nothing happens.
Any could help me with this? I have been wasting days with this issue.
This is my full gradle file:
apply plugin: 'com.android.application'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.gms:google-services:3.0.0'
}
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileOptions {
encoding "UTF-8"
}
lintOptions {
disable 'MissingTranslation'
abortOnError false
}
defaultConfig {
applicationId "xxx.yyy.zzz"
minSdkVersion 9
targetSdkVersion 25
versionCode 120
versionName "1.20"
multiDexEnabled true
//Enabling multi dex support due to exceeding the 65K methods dex limit imposed by Android: http://stackoverflow.com/questions/29756188/java-finished-with-non-zero-exit-value-2-android-gradle
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationVariants.all { variant ->
variant.outputs.each { output ->
def formattedDate = new Date().format('yyyyMMddHHmmss')
def newName = output.outputFile.name
newName = newName.replace("app-", "MyAppName")
newName = newName.replace("-release", "-release" + formattedDate)
//noinspection GroovyAssignabilityCheck
output.outputFile = new File(output.outputFile.parent, newName)
}
}
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':simple-crop-image-lib')
compile 'com.google.firebase:firebase-core:9.6.1'
compile 'com.google.firebase:firebase-messaging:10.2.4'
compile 'com.google.android.gms:play-services:10.2.4' //8.3.0' 10.2.4' 9.0.0' 9.6.0'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:mediarouter-v7:25.3.1'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
//For soap:
compile files('libs/ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar')
}
apply plugin: 'com.google.gms.google-services'
Update Google Repository in Android SDK. Works for me with version 47.
From the firebase doc:
dependencies {
// ...
compile 'com.google.firebase:firebase-core:10.2.4'
compile 'com.google.firebase:firebase-messaging:10.2.4'
// Getting a "Could not find" error? Make sure you have
// the latest Google Repository in the Android SDK manager
}
For me worked to remove these lines from the "app build.gradle":
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.gms:google-services:3.0.0'
}
}
And add these to the "project build.gradle":
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
I downloaded the code from this repository (its a app to control a parrot drone):
Github
with the hopes of getting it to work so i can study the code, however im getting this error that seems hard to find a solution after searching the web, i mostly found things for IOS, xcode, etc
I imported the project into android studio, when i try to execute the app i get the following error:
Error:error: linker command failed with exit code 1 (use -v to see invocation)
I am not really into NDK, but from what i saw it could be the reason, things i tried:
Downloaded NDK and added the correct path to it.
Using latest SDK.
Changes to build.gradle like setting buildToolsVersion "25.0.0", etc
Build.gradle (Project: ardrone)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
}
}
allprojects {
repositories {
jcenter()
}
}
Build.gradle (Module:app)
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
multiDexEnabled true
applicationId "com.parrot.freeflight"
minSdkVersion 9
targetSdkVersion 24
versionCode 20000
versionName "2.0-SDK"
ndk {
moduleName "adfreeflight"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
// TODO proguard-rules seem outdated and useless cause it's only Android stuff
}
}
sourceSets.main {
jni.srcDirs = [] // This prevents the auto generation of Android.mk
jniLibs.srcDir 'src/main/jniLibs'
// This is not necessary unless you have precompiled libraries in your project.
}
task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
def ndkCommand = "${android.ndkDirectory}/ndk-build"
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
ndkCommand += ".cmd"
}
commandLine ndkCommand,
'-C', file('src/main/jni').absolutePath,
'-j', Runtime.runtime.availableProcessors(),
'all',
'NDK_DEBUG=1'
}
task cleanNative(type: Exec, description: 'Clean JNI object files') {
def ndkCommand = "${android.ndkDirectory}/ndk-build"
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
ndkCommand += ".cmd"
}
commandLine ndkCommand,
'-C', file('src/main/jni').absolutePath,
'clean'
}
clean.dependsOn 'cleanNative'
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn buildNative
}
}
dependencies {
compile 'com.google.android.gms:play-services:10.0.0'
compile files('libs/android-support-v13.jar')
compile files('libs/com.sony.rdis.receiver-20111206.jar')
compile files('libs/com.sony.rdis.receiver.utility-20111206.jar')
}
local.properties
ndk.dir=C\:\\Users\\BugDroid\\AppData\\Local\\Android\\Sdk\\ndk-bundle
sdk.dir=C\:\\Users\\BugDroid\\AppData\\Local\\Android\\Sdk
You need to check your log for more details as the error 'Linker command failed with exit code 1' is usually followed by the more detailed error.
So to find more details, in Xcode click on the error under Buildtime and choose Reveal in log. This should give you extra hint. Without any specific error, it's difficult to know what's the problem.
I am using Android Studio to develop an Android application and I am using Gradle to handle the build. When I try to compileDebug the project, I errors that some libraries aren't found. These libraries are included in the build.gradle file and should be linked by gradle. Since the libraries aren't found at compilation, I think these files aren't linked correctly by gradle.
Can anyone have a look at the configuration file and look for anything wrong with it? Thanks:
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
mavenCentral()
}
dependencies {
//classpath 'com.android.tools.build:gradle:0.6.+'
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
apply plugin: 'android'
repositories {
maven {
url 'https://github.com/Goddchen/mvn-repo/raw/master/'
}
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:13.0.0'
compile 'com.google.android.gms:play-services:3.1.36'
compile 'com.google.code.gson:gson:2.2.4'
//compile 'com.codeslap:persistence:0.9.24'
compile 'org.apache.commons:commons-io:1.3.2'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.8.4'
//compile 'com.facebook.android:facebook:3.5.2'
compile 'com.facebook.android:facebook:3.17.1'
compile files('libs/rollbar-android-0.0.6.jar')
compile files('libs/libGoogleAnalyticsV2.jar')
//compile files('libs/commons-codec-1.7-SNAPSHOT-android.jar')
compile files('libs/tinylinetry_and.jar')
}
android {
compileSdkVersion 18
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 18
}
signingConfigs {
release {
storeFile file("../keystore.jks")
storePassword "******"
keyAlias "Android Release Key"
keyPassword "******"
}
}
buildTypes {
debug {
applicationIdSuffix ".debug"
}
release {
signingConfig signingConfigs.release
}
}
}
The error I get is from this kind:
:app:compileDebugJava
.../Application.java:55: error: package com.rollbar.android does not exist
import com.rollbar.android.Rollbar;
....
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
So all external libraries that are loaded and should be included by gradle aren't found.