Ionic trouble: can't build to android - windows

I've got an Ionic 3.4 project and trying to build it to Android for testing purposes.
I installed Android Studio and the Android SDK, aswell Java 8. Then did:
ionic cordova platform add android
Then, when I write...
ionic build android
... I get the following error:
cordova build android ✖ Running command - failed!
[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.
[ERROR] An error occurred while running cordova build android (exit
code 1):
ANDROID_HOME=C:\Users\Zerok\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\java\jdk1.8.0_121
Error: Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio
What's going on? I also installed Gradle 4.0 into the Java folder, and pointed towards it in the GRADLE_HOME environment variable:
Var name: GRADLE_HOME
Value: C:\Program Files\Java\gradle-4.0
Also added the following to the path:
GRADLE_HOME\bin
But it still throws the same error... I don't think it's a problem with plugins, but with the Ionic/Cordova build system. What I don't understand, is why it needs Gradle when it's perfectly working in Android Studio, maybe it's because it's not in C:/, but a different disk? Any ideas?

(Assuming Windows 10)
open Start Menu, type path and hit Enter
System Properties will open. On the bottom click Environment Variables...
In the window that opens, on the bottom section named System Variables, double click Path
Click New and copy paste the path to your gradle installation
Make sure the path environment variable points to the bin folder of gradle like so: export PATH="$PATH:/home/jeffbl/android-studio/gradle/gradle-3.2/bi‌​n".
If that doesn't work try:
$ cordova platform rm android && cordova platform add https://github.com/apache/cordova-android && cordova build
If that doesn't work then use the SDK manager to downgrade to an earlier version of your SDK. It might be that there is no graddle wrapper out yet for the latest.
In any case you will find the answer to your problem in this github issue.

Ok, I already fixed it. And the fix is weird as hell, but well, at least it works.
Solution: uninstall Android Studio and install it in the main drive (C in my case). Everything began to work perfectly after this clean install.

Related

when I try to run my existing flutter project in windows version, I am getting this error

I have an flutter project which I created long back when Flutter windows became stable version I want to use same project for windows version but it says this error.
You should be able to fix this error by downloading the Nuget.exe and adding it to your Windows' path manually.
The root problem may be related to your installation of Visual Studio as described here

NDK version is UNKNOWN message after updating to Android Studio 3.5 [duplicate]

After updating Android Studio and Gradle to 3.5,
I now get this error:
NDK Resolution Outcome: Project settings: Gradle model version=5.4.1, NDK version is UNKNOWN
I changed the Gradle version in build-gradle back to 3.4.2 but it didn't help.
I had similar problem and solved it by opening project using Import project (Gradle, Eclipse, etc.) instead of Open existing Android Studio project.
You can download NDK from File>Project Structur>Choosing SDK location from left panel and pressing Download from NDK location part.
I was having the same issue after upgrading my android studio. You just need to open local.properties & change ndk.dir path to your NDK path.
Code:
ndk.dir=D\:\\Android\\SDK\\ndk-bundle
sdk.dir=D\:\\Android\\SDK
I don't use NDK in my project, but I had the same problem. The problem disappeared after I updated the SDK version to the newest
compileSdkVersion 29
I had a previous answer (since deleted by moderators) where I detailed that there are workarounds (as listed here) that work for some but that there is an underlying bug in gradle because the workarounds don't work for everyone (specifically: none of them work for me)
The related google issue is here: https://issuetracker.google.com/issues/140403764
Update: As of today (20190920) they indicate that they have fixed the underlying issue, so I would expect a future release of gradle after today (20190920) will contain the fix.
Update2: Today (20190926) I received a response from a googler that the problematic code was in Android Studio and it is contained on the 3.6-release branch but is not available on any publicly available build at the moment (Android Studio 3.6 Canary 12 was released just before this fix was made). That lets you know which component to update and which versions to pay attention to, anyway. Looks like Android Studio 3.6 Canary 13 and later should have it https://issuetracker.google.com/issues/140403764#comment13
Until then you can try the workarounds but when there's a vendor bug and workarounds don't work you just have to wait for a vendor patch.
You need to install NDK using the SDK manager
I first got this issue after upgrading from Android Studio 3.5.0 to 3.5.1 today.
I simply did a rebuild from the top menu Build --> Rebuild Project.
This might not work for everyone depending on what caused the issue but it worked for mine. Give it a shot.
(Also, I do not use the NDK and never have downloaded it before. Still don't have it downloaded)
If you are not using NDK, ignore the error.
I have installed NDK to see if this makes any difference. There is no difference (except for an unused NDK folder of more than 2 GB :). So I removed it (i.e. delete the ndk folder and remove NDK environnent variable you have set previously).
After my recent Android Studio upgrade I had the same error message. I tried the other answers here and none worked. But #Zahra's answer pointed me to something that did work:
Go to File->Project Structure...
Under "Android NDK Location", click the dropdown and select the "DEFAULT NDK Recommended" option.
There was a slightly different path in there before I selected the default. Somewhere upgrading using the SDK manager, the path seems to have changed.
And now in the local.properties file sdk.dir is set to the same directory as the "DEFAULT NDK Recommended" option.
i fix it by going to file > Invalidate Caches\Restart
the IDE will restart and the problem will fix
I had same problem. My environment is:
Android Studio 3.5.1
Gradle 4.4
Android-Gradle-Plugin 3.1.2
CMake 3.10 and 3.6
I uninstalled CMake 3.10 by SDKManager. (installed CMake is 3.6 only)
Gradle sync and build succeeded.
(1)
android-gradle-plugin 3.1.2 used CMake 3.10.
In android-gradle-plugin 3.1.2 (or 3.1.+), feature of support for CMake 3.7 and higher is a preview feature.
(from output message of gradle assembleDebug or gradle sync.)
(2)
https://developer.android.com/studio/projects/add-native-code.html#use_a_custom_cmake_version
The SDK Manager includes the 3.6.0 forked version of CMake and version 3.10.2. Projects that don't set a specific CMake version in build.gradle are built with CMake 3.6.0.
Perhaps this behavior is android-gradle-plugin 3.3 or higher.
(it is from android-studio 3.3 that can be downloaded CMake 3.10)
android-gradle-plugin 3.1.2 used latest version from installed CMake.
I had the same issue on a mac as well.
Suggestion: Force the .gradle folder to rebuild itself..
This still shows the 'NDK Version is UNKNOWN' in the Event Log yet it builds successfully and doesn't give me any issues. (I don't have NDK downloaded)
Open your /Users/macuser/ folder
Press CMD + SHIFT + . (dot/period) to view hidden folders
DELETE .gradle folder
Restart Android Studio
This will cause Android Studio to rebuild and re-download your .gradle folder fixing your conflicting files in the process.
The problem is solved when I updated the Android Gradle Plugin Version from 3.1.4 to 3.4.0 and the Gradle Version from 4.4 to 5.1.1 at the same time. Of course, I downloaded the newest NDK(Side by Side) with SDK manager.
In my case, Android Studio was installed on a new mac. Just needed to download Android 9 (my target/compile SDK was 28) and build tools. The problem was solved after this.
In my case i fix it by upgrade to SdkVersion 29 and migrate to AndroidX.
After upgrading I've got the very same problem in one of my projects.
I solved it just deleting the line ndk.dir=D:\Android\SDK\ndk-bundle from the local.properties file.
I had the same error after adding a couple of libraries in the app-level build.gradle file.
The solution was just to clean the project.
In the menu bar choose: Build >> Clean Project
After that, the error was gone for me. I didn't do anything else.
I got this error (and several others) after importing a project from version control via Bitbucket hyperlink.
Once imported, close the project and re-import it using File > New > Import Project. After that everything built correctly.
(The NDK path was already specified properly, and only importing as new worked)
Meta:
Android Studio 3.5
Build #AI-191.8026.42.35.5791312, built on August 8, 2019
JRE: 1.8.0_202-release-1483-b49-5587405 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.6
Gradle 3.4.0
Problem solved for me after checking Suggestions in Project structure and updated the two suggested updates. Sorry I can't remember the module names as they disappeared as soon as I pressed update for each of them and graddle sync. started automatically and after this problem disappeared
downgrading ndk version from 20 to r17c and cmake version from 3.10 to 3.6.411459 solved the problem for me
I had the same problem after updating Android Studio.
My problem is solved by after updating Android SDK Build-Tools.
[Tools->SDK Manager->SDK Tools->Android SDK Build-Tools].
Then try to Clean the project
[Build->Clean Project].
Finally restart the Android Studio IDE......
I just closed project, closed android studio, restarted my PC, tracked my project and deleted the .Idea folder in "B:/PROJECTNAME/.idea" and voila.
Problem solved. It resyncs. N/B: my gradle is androidx. goodluck to someone.
Change the claaspath to 'com.android.tools.build:gradle:3.5.2' in build.gradle script
Ok. I recently downloaded the latest version of Android studio and got similar error. So eventually I created a new project.
Selected Kotlin Language then Jelly Bean (talking 'bout the options to pick from).
Then the whole synching began but the 1st sync failed and eventually it auto-synced again and everything began to work.
Did modify the default codes (text) since I'm a beginner but got no error messages.
The preview was OK and I continued my learning.
Sorry I couldn't explain it better. I'm just a beginner.
Oh! You need to be connected to the Internet for it to work.
If this problem occurred after an Android Studio upgrade and you initiated a plugin update from right bottom notification: Open File > Project structure, then change the Android Gradle version to your Android Studio version and downgrade the Gradle version to the previous one.
In my case, I downgraded the Android Gradle plugin from 3.5.3 to 3.2.1 and the Gradle version from 5.4.1 to 4.6.
I modified the gradle version of the gradle-wrapper.properties file from 4.1 to 4.6.
I had this problem and none of the solutions worked for me. Problem is, this error or warning might appear for very broad reasons. You can follow these steps to find out what is wrong:
NDK is missing
When Gradle starts to compile native dependencies it creates ".cxx" folder in your "app" folder. inside that folder you can find "ndk_locator_record.json" file, which is very strange type of log file. It is basically all the paths Gradle checks to find NDK folder. If there is any error or mismatch on NDK version numbers you can see in this file.
NDK build fails
for some unknown reasons (maybe bug in Gradle) ndk build does not show actual error on event log window, instead it shows a failure, like Gradle sync failed: executing external native build for ndkBuild .... following by NDK Resolution Outcome: Project settings: Gradle model version=5.4.1, NDK version is UNKNOWN.
In this case go back to .cxx > ndkBuild > debug > x86(x64 or any other cpu arch)
Here in this folder you can find "json_generation_record.json" file, it is same type of log, usually last entry has the actual error. For example, for me was
../../sdk/native/jni/OpenCV.mk: No such file or directory
make: *** No rule to make target '../../sdk/native/jni/OpenCV.mk'. Stop.
From here you have a starting point to find out what is going wrong under hood.
If the NDK is not install, and the Android Project requires it then first install the NDK.
On windows OS add the NDK path to PATH environment variable. This will fix the version issue.
In my case the NDK path is
C:\Users\\AppData\Local\Android\Sdk\ndk\21.0.6113669
I faced this issue before and I fixed it by making sure to have the right permissions to the app directory.
I am using macOS, so I did:
chmod -R 777 your_android_project
and the issue was gone.
i have this problem too when I updated the Android Gradle Plugin Version from 3.1.2 to 3.5.1
Here is how to solve this issue :
Go to gradle.properties file in root folder of your project and add android.useDeprecatedNdk=true

Appcelerator on Windows 10, module build issues [duplicate]

I have create a new Mobile Module Project, but when i try to build it, i have this error:
BUILD FAILED
C:\ProgramData\Titanium\mobilesdk\win32\5.2.2.GA\module\android\build.xml:165:
no executable specified
Did something wrong? I did the following step:
-Installed Appcelerator Studio
-It automatically installed Titanium SDK and i selected to install Android SDK
-Installed JAVA JDK
-Createed new module and tryed to build it
To fix this, edit the file:
C:\ProgramData\Titanium\mobilesdk\win32\5.2.2.GA\module\android\build.xml
Or for any newer SDK versions, just use e.g. 5.3.1 instead of 5.2.2
On line 159, add ".exe" to aidl, like so:
TO
To develop android module you will have to install some additional component and configure some path variables. There is a nice quick start guide where you will find everything. Thinks that need to install:
Android NDK
Ant
Eclipse Java Development Tools plugin
Android Development Tools plugin
gperf
Python
Documentation Link

Nativescript 1.3.0 intsllation issue

I will try my best to explain what I did and where I am right now. I am using window7
What I did for installation.
Installed jdk and updated the environment path variable and created new one JAVA_HOME
Downloaded Gradle and updated the environment path pointing to bin directory of gradle
Installed android sdk with all the specified version, sdk tool, and platform tools.
Created ANDROID_HOME variable.
Remove and Reinstalled Nativescript
Ran tns doctor command and result can be found here
Launched the app via tns run android --emulator and tried on device as well error received was "Unfortunately mysir has stopped" and log can be found here.
Now Can anyone please tell me what I am missing?
Check out if <your app>\platforms\android\src\main\assets\internal\prepareExtend.js file exists. This file is supposed to be created when you execute tns platform add android command. If the file does not exist then it may be better to create a new project.
well the whole problem was I was not running command npm install tns-core-modules --save after creating new project.

Cordova Windows Project Setup

I have created a new cordova windows application (not WP8) using CLI.
I followed the following procedure,
cordova create xyz com.compname.wxyz XYZ<br>
cd xyz<br>
cordova platform add windows<br>
cordova plugin add blah! blah! blah!<br>
cordova build windows<br>
cordova run windows<br>
When i run the above codes in command promp everything runs fine until "cordova build windows", but when i run "cordova run windows" it shows a lot of errors,
Error: Could not install the package.<br>
Starting application...<br>
Get-AppxPackage : The package repository is corrupted.<br>
The package repository is corrupted.<br>
when i try to run the project it says error log as,
Error 1 Error : DEP0600 : The following unexpected error occurred during deployment: <br>
The package repository is corrupted.<br>
The package repository is corrupted. CordovaApp.Windows80<br>
Does anyone have any idea what is going on or can someone tell me how to successfully create a new cordova windows project using CLI or manually.
Thank you.
I'm assuming you have Microsoft Visual Studio installed and you're running on a Windows 8 system?
What happens when you open the solution in Visual Studio?
I guess this is because your deployment environment you targeting is not being recognized by the deploying platform you are using.
in short your device in which you want to deploy the appxBundle is not being identified by your computer.
I hope this helps...
Tell me you want to deploy it on windows which OS version.
1) windows 10 [ARM/x86]
2) windows 8.1 [ARM/x86]
Let me know if it helps.

Resources