The specified task executable location ... is invalid - android

I'm new to Xamarin. I'm having a problem with deployment. The project builds successfully but then I get an error message:
C:\Program Files
(x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2):
Error MSB6004: The specified task executable location
"C:\android\sdk\tools\zipalign.exe" is invalid. (MSB6004) (FirstApp)
". " Deployment failed. Packaging failed ".
I'm not sure what the problem is or what to do to resolve this. Please help.

Because of a new Android version, the zipalign got switched from directory. See over here
Currently, I saw they updated Xamarin with a fix for this. You should try to update Xamarin first. Version 5.1.2 fixes this: "Fixes a regression introduced by Android SDK Tools r23 and Android Build-tools r20 that changed the path of the zipalign tool."

This solution just worked for me:
You need to copy
C:\Program Files (x86)\Android\android-sdk\build-tools\19.1.0\zipalign.exe
not in
C:\Program Files (x86)\Android\android-sdk\tools
but in
C:\Users\yourfolder\AppData\Local\Android\android-sdk\tools
Also see:
ApkClean 0.9.02
https://code.google.com/p/apkclean/downloads/detail?name=ApkClean-0.9.02.zip&can=2&q=
:)

Related

Flutter: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable

I'm building app using different ways, two works but one fails.
Method:1 (Working)
flutter build appbundle
Method:2 (Working)
Opening module in Android Studio, after that, choosing
Build > Generate Signed Bundle/APK... > filling all info afterwards
In this case, I am able to build both app bundle and APK file.
Method:3 (Not working)
flutter build apk
I get this error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android_intent'.
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
If I remove android_intent, I start getting error in other packages, so definitely the package isn't a problem. I double checked that I have
local.properties, gradle.properties and settings.gradle in my android root folder.
And my other projects seem to work.
I have faced this issue with file_picker plugin, Just upgrade gradle version in android/build.gradle to one of these versions :
3.3.3
3.4.3
3.5.4
3.6.4
4.0.1
I followed this link : file_picker troubleshooting
I recommend clearing the android-studio-dir and android-sdk settings, and let flutter automatically detects their path instead: This works for me .
flutter config --android-studio-dir=""
flutter config --android-sdk=""
Sometimes you will see an SDK problem from a plugin that requires the latest gradle to actually run.
I was running into this even though my SDK was properly set:
SDK location not found. Define location with sdk.dir in the
local.properties file or with an ANDROID_HOME environment variable.
More info from:
Here is an example of a plugin failure that will lead to an sdk and query error flutter_file_picker:
Build is failing with unexpected element <queries> found in <manifest>.
Upgrade gradle:
To upgrade gradle in a flutter project, File -> Open and select the Android folder which is part of your Flutter application. When that finishes loading, it will prompt you to upgrade gradle to the latest version. This will resolve the issue
I had the same problem.
In my case, an outdated package was the cause of the problem
To fix this issue try to upgrade the Gradle version to the latest version.
For doing this go to android/gradle/wrapper/gradle-wrapper.properties and then, replace the version of distributionUrl with the latest Gradel version.
for example:
upgrade:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
to:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
I was facing the same issue but there is a file create in
build\app\outputs\apk\release\app-release.apk
which when installed works fine without any issue . Even I don't know why this happens but it works.
So in my case what I feel is happening is that there is a conflict between the new build and the already existing build due to a new package or something else so I did
flutter clean and tried building again and voila it worked.
In android\gradle.properties make sure android.enableR8 is NOT set to false. It may just be related to your apk size, not a specific package.
I had the same issue. Here how I solved it.
Make sure you have a file called local.properties in android folder, and make sure it has a correct Computer user name such as like that:
sdk.dir=C:\\Users\\YOURUSERNAME\\AppData\\Local\\Android\\Sdk
flutter.sdk=C:\\src\\flutter
flutter.buildMode=debug
flutter.versionName=1.0.5
flutter.versionCode=10
for MAC, path should be like that
sdk.dir = /Users/YOURUSERNAME/Library/Android/sdk
In case if this doesn't work, add ANDROID_HOME variable in "Environment Variables" as C:\Users\YOURUSERNAME\AppData\Local\Android\Sdk
in mac os.
open terminal and run below command
nano ~/.bash_profile
type below values in terminal with your user_name
export ANDROID_HOME="/Users/<user_name>/Library/Android/sdk"
export ANDROID_TOOLS="/Users/<user_name>/Library/Android/sdk/tools/"
export ANDROID_PLATFORM_TOOLS="/Users/<user_name>/Library/Android/sdk/platform-tools/"
and save them by control+X and then Enter
after that restart terminal and type below command
source ~/.bash_profile
finally type
echo $ANDROID_HOME
I have to do it on my project folder then it worked for me.

Error when compiling with Gradle (can't find downloaded dependencies)

I develop an app generation system that is regenerating apps by command line Gradle compilation commands.
In my Windows Server 2008, I'm facing a problem after updating to the last Gradle version and Gradle plugin version.
When compiling I'm getting this errors:
C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.0.0.aar\e93435c34d5cae8b6677dcef529711a5\res\drawable-xxhdpi-v4\abc_text_select_handle_middle_mtrl_light.png: error: file not found.
C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.0.0.aar\e93435c34d5cae8b6677dcef529711a5\res\drawable\abc_btn_colored_material.xml: error: file not found.
C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.0.0.aar\e93435c34d5cae8b6677dcef529711a5\res\drawable-hdpi-v4\abc_textfield_search_default_mtrl_alpha.9.png: error: file not found.
and a lot more of errors like those...
I'm not sure why I'm getting this error, because the file is correctly downloaded and it's correctly located on that exactly direction.
It has a path length of 204 characters, so supposedly it's not surpassing the limit of 255 path characters on NTFS Windows file system.
It is possible to change the location where Gradle downloads it's cached dependencies? Is this problem caused by this or by other thing?
finally i solved this setting the environmental variable GRADLE_USER_HOME in windows to c:/gradle-cache
so definitively it's related to file path lenght
I meet this same error in windows jenkins
I solved this error.
gradle assembleDebug -g C:\gradle-cache
-g:
gradle -h
-g, --gradle-user-home Specifies the gradle user home directory
Path length cause failure.
I defined
"-Dorg.gradle.user.home=%GRADLE_USER_HOME%"
in gradle run parameters and it solved the problem.

android studio doesnt build cannot run program

After creating a new project, I met the following error:
java.io.IOException: Cannot run program "C:\NVPACK\android-sdk-windows\build-tools\build-tools-22.0.1\aapt.exe": CreateProcess error=193, %1 is not a valid Win32 application
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
at com.android.builder.png.AaptProcess$Builder.start(AaptProcess.java:154)
at com.android.builder.png.QueuedCruncher$1.creation(QueuedCruncher.java:105)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:206)
I read that it can be beacuse of the space in the file path. But the path does not contain any spaces. How to fix it?
I suggest that you can replace '-' with '_' or just don't use '-'.
I once have same problem.
solved it by change the "Android SDK Build Tool" version 18.0.2 to 18.0.1 .
upgrade or downgrade "Android SDK Build Tool" version may solve it as me.
File-> Settings

Failed to create new project in android studio 0.2.3

After I updated form 0.2.2 to 0.2.3, I create new project failed.
Error message is below:
下午 08:51:58 Gradle 'NotifyViaGoogleMapsProject' project refresh failed:
The SDK directory 'C:\Program Files (x86)\Android\android-studio\bin\Program Files (x86)Androidandroid-studiosdk' does not exist.
Build file 'F:\AndroidStudioDevelop\NotifyViaGoogleMapsProject\NotifyViaGoogleMaps\build.gradle' line: 9
NotifyViaGoogleMapsProject is my project name,and my android studio is install in default path(C:\Program Files (x86)\Android\android-studio), there has no same error in 0.2.2.
I've figured out the problem.
Open 'local.properties' in your project using a text editor.
sdk.dir=..\\sdk
Save and Close
Now Import your project into Android Studio.
Make sure that the SDK folder you mention exists - I'm not sure if it is a typo or not but the path you specified is a bit weird - it should be
C:\Program Files (x86)\Android\android-studio\sdk
On the menu go to File -> Project Structure, then choose SDKs under Platform Settings. Check that the path for the Android Platform you use is correct, and if not, change it to the correct path. Also make sure that the Project is set to use the correct Android Platform.
I have the same problem.
http://i.stack.imgur.com/pPOOi.png
The SDK is correct in Platform Settings, I have no idea what's causing this problem.
http://puu.sh/3TAFi.png

Android - Phonegap - Conversion to Dalvik format failed with error 1

I installed this:
https://github.com/mwbrooks/cordova-plugin-menu
and have cordova 1.8.1 installed.
I copied "libs/phonegap-1.0.0.jar" to ANDROID_PROJECT/libs.
When i try and run the app in the simulator, i get :
"Conversion to Dalvik format failed with error 1"
I believe this is to do with conflicts with libraries, but I don't know what to do to remove the error?
please help.
I have found myself in the same situation after upgrading from 2.0.0 to 2.1.0
First of all make sure you have reconfigured the build path by removing the JAR from the old PhoneGap version and adding the new one.
At this point I started getting the Dalvik error. Cleaning the build environment didn't help.
So I remove the old jar from the libs directory and voilá, it worked.
Project -> Turn off Build Automatically. Then Build project manually and clean. Then export signed project. Problem has been gone.

Categories

Resources