flutter app not running - Could not find aapt2-windows.jar - android

i am new to flutter; i created a new project (nothing in code or files is changed) and when i try to run it, i get this error message:
Execution failed for task ':app:mergeDebugResources'.
> Could not resolve all files for configuration ':app:_internal_aapt2_binary'.
> Could not find aapt2-windows.jar (com.android.tools.build:aapt2:3.5.0-5435860).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.5.0-5435860/aapt2-3.5.0-5435860-windows.jar
can anyOne tell what's wrong? i used to run my apps and there was no issue; i don't know what happened! weird thing is when i click on the link i can download aapt2-3.5.0-5435860-windows.jar manually. idk why gradlew can't resolve it.
p.s: my gradle.build is the default file; nothing is changed.

you should try out the following two steps
Add mavenCentral() in build.gradle if missing
buildscript {
repositories {
mavenCentral()
jcenter()
}
update your minimum sdk version 16 to 21
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.jahid.testing_stackoverflow"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

This problem occurred when trying build android app, and off course it's related to gradle!
Solution 1, if you are using android studio and lucky!:
Open your flutter project android module as a separate project with a android studio.
As project open, android studio suggest you update gradle, click update and waiting for downloading to finish, run project again, it should work now.
Solution 2, if you are using android studio and don't lucky:
If for any reason in the previous solution android studio didn't show you recommended dialog, as you open android module as a separate project, click on project structure button and set versions manually.
Remember last version might not always working properly, so be wise!
Solution 3, if you are not using android studio:
You can also set these versions manually by going to following locations:
For setting android gradle plugin version go to YOUR_FLUTTER_PROJECT\android\build.gradle and changing:
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
}
For setting gradle version go to YOUR_FLUTTER_PROJECT\android\gradle\wrapper\gradle-wrapper.properties and changing:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip

Related

Android Studio build fail with minSDK=29

I have Android Studio build problem.
Build fails only when changing the minSdk=29 with follwing error.
( It's OK with minSdk=28 )
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.example.aaa"
minSdkVersion 29 // build fails with 29, it's OK with 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Fail messages on Android Studio build console
- Build: build failed
- Run build :
...
Caused by: com.android.tools.r8.utils.AbortException
- Andriod issues: (1 error)
Dex file with version '38' cannot be used with min sdk level '29'.
If anyone resolved this problem, please share your know-hows.
Thank you.
I came across this recently when updating a project for Android studio 3.5.3 to 3.6.3, however I manually changed gradle-wrapper.properties and the project's build.gradle before even opening the project.
In my case I was able to clean the build, delete the .gradle and .idea folders and rebuild without issue.
Edit: As stated in the comments, it is worthwhile to try a clean-rebuild first, rather than the "Scorched Earth" approach of deleting .gradle and .idea folders. Deleting them will take longer to recover from and blow away all your nice IDE settings!
This is because of latest gradle version :
classpath 'com.android.tools.build:gradle:3.5.3'
in Android 6.0 and lower android versions. In order to fix it you can downgrade the gradle version as follows :
classpath 'com.android.tools.build:gradle:3.5.1'
It will run on all android versions perfectly.

Stop working project with vector drawables after update build.gradle on API < 21

I have working project.
minSdkVersion 17
com.android.tools.build:gradle:2.3.3
gradle 4.1
Android Studio 3 Canary 6
I have in my gradle files:
defaultConfig {
vectorDrawables.useSupportLibrary = true
vectorDrawables.generatedDensities = []
}
I call in activity too:
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
Application works perfectly. Now change to:
com.android.tools.build:gradle:3.0.0-alpha6
add to repositories google() line
Execute gradle clean assembleDebug.
App continue works on devices with API > 20. But for API < 21 (google android emulator) get crash on start application.
I see in logcat error: Resources$NotFoundException: Resource ID #0x7f080058 (0x7f080058 is drawable abc_vector_test).
Why?
UPD 2017-07-19: It was fixed and released in com.android.tools.build:gradle:3.0.0-alpha7
I'm add to gradle.properties line
android.enableAapt2=false
and it's solve my error.
UPD 2017-07-19: It was fixed and released in com.android.tools.build:gradle:3.0.0-alpha7
Gradle plugin from version 3 use new AAPT, that have some bugs.
After reading some issues on bug tracker, I've found that Gradle has option for full disable AAPT2: android.enableAapt2=false
Also from release notes to alpha5:
AAPT2. We are continuing to stabilize AAPT2 which enables incremental resource processing. If your build fails due to resource
processing issue, please send us a bug report. To temporarily disable
AAPT, set android.enableAapt2=false in your gradle.properties file.
Roboelectric is currently not compatible with AAPT2
I am facing the same problem, downgrade Android Studio to previous version canary5 and write the following in your build.gradle
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha5'
...

Always "aidl" is missing on Android Studio 1.2.1.1

I am using Android Studio version 1.2.1.1,and every time when create a new app ,error log shows "Error:Execution failed for task ':app:compileDebugAidl'.
aidl is missing" ,I know the solution for this problem is ,to write click on the app directory and select open module settings ,and compiled sdk version and build tool version must set accordingly.I need a proper solution for this problem and i don't want to repeat all these steps on every app creation.Can anybody help me out plz???
You have an invalid combination of project settings in your Gradle build files, probably caused by your installing the M Developer Preview bits from the SDK Manager.
Unless you are specifically trying to test the M Developer Preview, change your buildToolsVersion to be 22.0.1 in your app module's build.gradle file. Right now, it is probably something like 23.0.0_rc1.
May be you are using the Build Tools 23.0.0_rc1. In this case you have to use the gradle plugin 1.3.0-beta1.
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0-beta1'
...
}
}
If you are using the build tools 22.0.1, you can use the gradle plugin 1.1.x or 1.2.x
I was also facing the same problem.
Select the app folder and press F4. It'll open the Modular Settings.
(Right-clicking and selecting 'Open Modular Settings' will also do.)
Change 'Build tool version to "22.0.1" from "23.0.0 rc1".
Now this should work.
Downgrading "Build tool version" is a workaround, not a solution.
Please check this answer: https://stackoverflow.com/a/32495797/4160928

Android Studio update -Error:Could not run build action using Gradle distribution

I have recently updated android studio to the latest version,but then comes the problem.
Gradle 'MyApplication' project refresh failed.
Error:Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.2.1-all.zip'.
Found this in StackOverflow
However trying everything nothing works - cannot create new project of import anything at the moment.Please kindly advice.
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.sclick.myapplication"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
task assemble{}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
**Top Level Gradle.build**
// Top-level build file where you can add configuration options common to all
sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
gradle-wrapper.properties
#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
I had same issue. I have tried many things but nothing worked Until I try following:
Close Android Studio
Delete any directory matching gradle-[version]-all within C:\Users\<username>\.gradle\wrapper\dists\. If you encounter a "File in use" error (or similar), terminate any running Java executables.
Open Android Studio as Administrator.
Try to sync project files.
If the above does not work, try restarting your computer and/or delete the project's .gradle directory.
Open the problem project and trigger a Gradle sync.
I had a similar issue, when I upgraded to the latest version of Android Studio 1.3.2. What seemed to work for me was removing the .gradle folder from my project directory:
rm -rf ~/project/.gradle
I had same issue when first start Android Studio in Window 10, with java jdk 1.8.0_66. The solution that worked is:
Step 1: Close Android Studio
Step 2: Delete Folder C:\Users\Anna\.gradle
(Anna is my username)
Step 3: Open Android Studio as Administrator
Step 4: If you are currently in an opened project, close current project by select File > Close Project.
Step 5: Now you seeing this Quick Start GUI:
Select Open an existing Android Studio project, navigate to your project folder and select it.
Wait for gradle to build again (it would download all the dependency in your build.gradle for every module in your project)
If it has not worked till now, you could restart your computer. Do step 1 again.
This happens sometime when I changed Android Studio version or recently upgrade Window. Hope that helps !
I forced to use a proxy and also forced to add proxy setting on gradle.properties as these:
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=1080
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=1080
And also forced to close and open studio64.exe as administrator .
Now its all seems greate
Event log says
8:21:39 AM Platform and Plugin Updates: The following components are ready to update: Android Support Repository, Google Repository, Intel x86 Emulator Accelerator (HAXM installer), Android SDK Platform-Tools 24, Google APIs Intel x86 Atom System Image, Android SDK Tools 25.1.7
8:21:40 AM Gradle sync started
8:22:03 AM Gradle sync completed
8:22:04 AM Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:prepareDebugUnitTestDependencies, :app:mockableAndroidJar]
8:22:25 AM Gradle build finished in 21s 607ms
I'm using android studio 2.1.2 downloaded as exe setup file. it has its Gradle ( I also forced to use custom install to address the Gradle )
Go on Project->Settings->Compiler(Gradle-based android project), find the text field "VM option" and put there:
-Xmx512m -XX:MaxPermSize=512m
This shouls solve the issue in any case the error shown in the gradle message window is "Could not reserve enough space for object heap"
Hope this helps
You can download the gradle you want from Gradle Service by reading the gradle-wrapper.properties.Download it ,unpack it where you like and then change your grandle configuration use local not the recommended.
I had the same problem and I Just Invalidate caches/restart
Try updating gradle dependency to 2.4. For that you need to go to
File -> Project Structure -> Project -> Gradle version.
There you need to change from 2.2.1 to 2.4. Wait for new gradle version to be downloaded.
And you are ready to go.
I have run into a similar problem on Mac.
Looking at the log under Help -> Show logs in Finder I found the following entry.
You have JVM property "https.proxyHost" set to "127.0.0.1".This may lead to incorrect behaviour. Proxy should be set in Settings | HTTP ProxyThis JVM property is old and its usage is not recommended by Oracle.(Note: It could have been assigned by some code dynamically.)
and it turned out I had Charles as a network proxy running. Shutting down Charles solved the problem.

Old projects are not building after changing SDK path in Android Studio

Recently, I uninstalled my SDK from location /Users/Shared/Downloads/adt-bundle-mac-x86_64-20130729/sdk and installed in /usr/local/android_sdk/sdk
and the same changes I made in Android Studio Settings
Configure->Project Default->Project Structure->Platform Settings->SDK
Now, The problem is with these changes I can build any new project but when I open my old project It gives me this error:
Gradle 'GPSProvider' project refresh failed:
Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.7-bin.zip'.
Build file '/Users/zohrakhan/AndroidStudioProjects/GPSProvider/GPSProvider/build.gradle' line: 9
A problem occurred evaluating project ':GPSProvider'.
A problem occurred evaluating project ':GPSProvider'.
The SDK directory '/Users/Shared/Downloads/adt-bundle-mac-x86_64-20130729/sdk' does not exist.
Please help me to find out the problem.
Edit 1:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 11
targetSdkVersion 16
}
}
dependencies {
compile 'com.android.support:appcompat-v7:18.0.0'
}
Check local.properties file (in /Users/zohrakhan/AndroidStudioProjects/GPSProvider/GPSProviderdirectory). This file may contain:
sdk.dir=/Users/Shared/Downloads/adt-bundle-mac-x86_64-20130729/sdk
So, just replace sdk.dir property.
If it is an Old project and you were using different sdk that time Do the following before import
Delete all the content of .idea directory inside the project directory
Open Studio and import the project and wait until it sync with gradle.
If it gives gradle version related error while sync, update your build.gradle file with whaever version your error message is suggesting.
Now do mentioned below to update your local.propertiesfile
Sync your project with Gradle it will automatically ask if there are any conflicts in your sdk paths in project .
Choose default project sdk to use from dialog.
This is introduced from Android Studio 0.3.7

Categories

Resources