Ionic build android not working on package-resource - android

My ionic build task isn't working properly.
First, I follow these commands:
ionic start secondApp blank
cd secondApp
ionic platform add android
ionic build android
When ant build prepare to package the project resources, the task throws this error:
-package-resources:
[aapt] Creating full resource package...
BUILD FAILED
E:\usr\bin\android-sdk\tools\ant\build.xml:932: The following error occurred while executing this line:
E:\usr\bin\android-sdk\tools\ant\build.xml:950: null returned: -1073741819
Total time: 32 seconds
E:\dev\projects\ionic\secondApp\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,E:\dev\projects\ionic\secondApp\platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: E:\dev\projects\ionic\secondApp\platforms\android\cordova\build.bat: Command failed with exit code 8
at ChildProcess.whenDone (C:\Users\Ricardo\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Process.ChildProcess._handle.onexit (child_process.js:802:5)
I already try to clean my project and delete .cordova and .ionic but the problem still persist.
What's wrong?
ANT_HOME, ANDROID_HOME, JAVA_HOME are OK

I encountered the same error. See the following for more information:
https://code.google.com/p/android/issues/detail?id=77629
Downgrading to the Android SDK Build-Tools 20 should allow the build to complete again. That resolved the problem for me.

I just retested it with the example ionic project, and it works with SDK Build Tools 21.0.2.
Failing aapt has been fixed for windows/x64 with this version.
So actually upgrading might be an option for you as well.

Related

Apache Cordova Execution failed for task ':compileDebugJavaWithJavac'

After some updates to Android Studio and Apache Cordova my Apache Cordova project is not building.
I am new to Apache Cordova, OS X and Android Studio.
In Android Studio when I Rebuild Project I get the following error in the Gradle console.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> 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
In the terminal when I run the command cordova --version it prints out 4.0.0 and which javac prints out /usr/bin/javac but echo $JAVA_HOME prints nothing (an empty line).
UPDATE: I am setting the path of JAVA_HOME and ANDROID_HOME in the terminal even though I get the same errors as shown below and after closing the terminal the JAVA_HOME and ANDROID_HOME environment variables are lost, I set them as export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home and export ANDROID_HOME=/Users/apple/Library/Android/sdk
When I try to build the project from Cordova CLI also it is not working.
I get the following errors, where as if I create a new project after changing the distributionUrl in gradle-wrapper.properties and changing the buildToolsVersion from "19.0.0" to "19.1.0" the new project worked fine.
Please help.
cordova compile command
Sreekanth-2:19:02:16 Sreekanth$ cordova compile
Running command: "/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/cordova/build"
Buildfile: /Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/build.xml
BUILD FAILED
/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/build.xml:7: The following error occurred while executing this line:
java.io.FileNotFoundException: /Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:/usr/local/Cellar/ant/1.9.7/libexec/lib/ant.jar (No such file or directory)
at java.io.RandomAccessFile.open0(Native Method)
at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
at org.apache.tools.zip.ZipFile.<init>(ZipFile.java:212)
at org.apache.tools.zip.ZipFile.<init>(ZipFile.java:177)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:256)
at org.apache.tools.ant.helper.ProjectHelper2.parseUnknownElement(ProjectHelper2.java:131)
at org.apache.tools.ant.helper.ProjectHelper2.parseAntlibDescriptor(ProjectHelper2.java:111)
at org.apache.tools.ant.taskdefs.Antlib.createAntlib(Antlib.java:94)
at org.apache.tools.ant.taskdefs.Definer.loadAntlib(Definer.java:425)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:277)
at org.apache.tools.ant.ComponentHelper.checkNamespace(ComponentHelper.java:874)
at org.apache.tools.ant.ComponentHelper.getDefinition(ComponentHelper.java:307)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:284)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:263)
at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:430)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:164)
at org.apache.tools.ant.Task.perform(Task.java:347)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:180)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:93)
at org.apache.tools.ant.Main.runBuild(Main.java:829)
at org.apache.tools.ant.Main.startAnt(Main.java:236)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
Total time: 0 seconds
/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: ant with args: debug,-f,/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: /Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/cordova/build: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
cordova build command
Sreekanth-2:19:02:16 Sreekanth$ cordova build
Running command: "/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/cordova/build"
Buildfile: /Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/build.xml
BUILD FAILED
/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/build.xml:7: The following error occurred while executing this line:
java.io.FileNotFoundException: /Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:/usr/local/Cellar/ant/1.9.7/libexec/lib/ant.jar (No such file or directory)
at java.io.RandomAccessFile.open0(Native Method)
at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
at org.apache.tools.zip.ZipFile.<init>(ZipFile.java:212)
at org.apache.tools.zip.ZipFile.<init>(ZipFile.java:177)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:256)
at org.apache.tools.ant.helper.ProjectHelper2.parseUnknownElement(ProjectHelper2.java:131)
at org.apache.tools.ant.helper.ProjectHelper2.parseAntlibDescriptor(ProjectHelper2.java:111)
at org.apache.tools.ant.taskdefs.Antlib.createAntlib(Antlib.java:94)
at org.apache.tools.ant.taskdefs.Definer.loadAntlib(Definer.java:425)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:277)
at org.apache.tools.ant.ComponentHelper.checkNamespace(ComponentHelper.java:874)
at org.apache.tools.ant.ComponentHelper.getDefinition(ComponentHelper.java:307)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:284)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:263)
at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:430)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:164)
at org.apache.tools.ant.Task.perform(Task.java:347)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:180)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:93)
at org.apache.tools.ant.Main.runBuild(Main.java:829)
at org.apache.tools.ant.Main.startAnt(Main.java:236)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
Total time: 0 seconds
/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: ant with args: debug,-f,/Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: /Users/apple/Desktop/Sreekanth/Togetherly Daily Work/19:02:16/platforms/android/cordova/build: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
Sreekanth-2:19:02:16 Sreekanth$
Go to Project.Properties
add the following lines
cordova.system.library.1=com.google.android.gms:play-services-auth:9.8.0
cordova.system.library.2=com.google.android.gms:play-services-identity:9.8.0
run the cordova commands again, You can able to build a release and debug builds
Type the following in your terminal
echo "export JAVA_HOME=/usr/libexec/java_home"
This will print the exact export for Java_home , copy that and paste it in terminal and press enter.
Then try echo $java_home.

Phonegap build error (phonegap build android command)

I want to install phonegap and I have some errors in build. (I have already installed jdk, git, node.js , apache-ant, android studion, sdk and sdk manager and set environment variables)
:processDebugManifest
C:\my_first_app\platforms\android\AndroidManifest.xml:15:5 Error:
uses-sdk:minSdkVersion 7 cannot be smaller than version 10 declared in l
ibrary C:\my_first_app\platforms\android\build\intermediates\exploded-aar\androi
d\CordovaLib\unspecified\debug\AndroidManifest.xml
Suggestion: use tools:overrideLibrary="org.apache.cordova" to force usag
e
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processDebugManifest'.
>
Manifest merger failed : uses-sdk:minSdkVersion 7 cannot be smaller than version
10 declared in library C:\my_first_app\platforms\android\build\intermediates\ex
ploded-aar\android\CordovaLib\unspecified\debug\AndroidManifest.xml
Suggestion: use tools:overrideLibrary="org.apache.cordova" to force usag
e
* Try:
Run with
--stacktrace option to get the stack trace. Run with --info
or --debug
option to get more log output.
BUILD FAILED
Total time: 47.884 secs
C:\my_first_app\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "C:\my_first_app\platforms\androi
d\gradlew cdvBuildDebug -b C:\my_first_app\platforms\android\build.gradle -Dorg.
gradle.daemon=true"
ERROR building one of the platforms: Error: cmd: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: cmd: Command failed with exit code 1
at ChildProcess.whenDone (C:\Users\Cebit\AppData\Roaming\npm\node_modules\ph
onegap\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:1
34:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
In System properties -> Environment variables:
path variable is:
C:\Program Files (x86)\Silverfrost\FTN95;C:\Program Files (x86)\ActiveState Komodo IDE 8\;%systemroot%\system32\windowspowershell\v1.0\;%systemroot%\system32\wbem;%systemroot%\system32;c:\progra~2\egcs\bin;c:\program files (x86)\microsoft sql server\100\tools\binn\;c:\program files\microsoft sql server\100\tools\binn\;c:\program files\microsoft sql server\100\dts\binn\;%systemroot%;%QUARTUS_ROOTDIR%\bin;C:\Program Files (x86)\MATLAB\R2010a\runtime\win32;C:\Program Files (x86)\MATLAB\R2010a\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\Git\cmd;%JAVA_HOME%\bin;%ANT_HOME%\bin;%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
Finally I found the answer.
First of all, there is a problem in new version of phonegap that is mentioned here. (Check accepted answer)
Then in www\config.xml file, replace this:
<preference name="android-minSdkVersion" value="7" />
With this:
<preference name="android-minSdkVersion" value="10" />
Your error log says you are using uses-sdk:minSdkVersion=7
Change to 10 or better, I recommend 14
uses-sdk:minSdkVersion=10
It will set your Android SDK level to 10 (Gingerbread).
What is use-sdk:minSdkVersion? Follow this link.

Cordova Android Build Failure

I am trying to get the basic Cordova v5.0 Android v4.0 project to build on Mac OS X Yosemite, but keep getting this error. Note: The same process builds fine on Cordova v4. I have uninstalled and reinstalled the Android SDK, Cordova, and even Gradle (but I don't think I need it). I've checked that my Path variable contains the correct paths to /tools and /platform_tools. But when I do the 'cordova build' or 'cordova build android' I always get the same error:
Could not create an instance of type
org.gradle.invocation.DefaultGradle_Decorated.
Further down it says:
You may not have the required environment or OS to build this project
What am I missing?
Here's the full text of what I'm doing:
my_acct$cordova create build_test com.example.build_test "BuildTest"
Creating a new cordova project.
my_acct$cd build_test
my_acct$cordova platform add android
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.example.build_test
Name: BuildTest
Activity: MainActivity
Android target: android-22
Copying template files...
Android project created with cordova-android#4.0.0
Discovered plugin "cordova-plugin-whitelist" in config.xml. Installing to the project
Fetching plugin "cordova-plugin-whitelist#1" via npm
npm http GET https://registry.npmjs.org/cordova-plugin-whitelist
npm http GET https://registry.npmjs.org/cordova-plugin-whitelist
npm http 304 https://registry.npmjs.org/cordova-plugin-whitelist
Installing "cordova-plugin-whitelist" for android
my_acct$cordova build
Running command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build
ANDROID_HOME=/Users/my_acct/Documents/Development/android-sdk-macosx/sdk
JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Running: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew cdvBuildDebug -b /Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle -Dorg.gradle.daemon=true
FAILURE: Build failed with an exception.
* What went wrong:
Could not create an instance of type org.gradle.invocation.DefaultGradle_Decorated.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
/Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
at ChildProcess.whenDone (/Users/my_acct/.node/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5)
If I change to use java 1.7 or 1.8, the error changes to:
A problem occurred configuring root project 'android'.
Could not resolve all dependencies for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:1.0.0+.
Required by:
:android:unspecified
org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
Here's the full results for using java 1.7 or 1.8:
my_acct$cordova build
Running command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build
ANDROID_HOME=/Users/my_acct/Documents/Development/android-sdk-macosx/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
Running: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew cdvBuildDebug -b /Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle -Dorg.gradle.daemon=true
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:1.0.0+.
Required by:
:android:unspecified
> org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.859 secs
/Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
at ChildProcess.whenDone (/Users/my_acct/.node/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5)
I figured it out. I found old, conflicting .jar files in ~/Library/Java/Extensions. Blew away the entire ~/Library/Java directory. Cordova (and Android Studio) runs great now.
The other way how this problem can be resolved is by changing the repository from
mavenCentral()
to
maven{
url 'https://repo1.maven.org/maven2'
}
in both platforms/android/build.gradle and platforms/android/CordovaLib/build.gradle

An error occurred building visual studio cordova app using multi-device-hybrid-apps only in Release and Distribution configuration

I am developing a mobile app using Cordova by multi-device-hybrid-apps in Visual Studio 2013,
Everything is fine on Debug configuration, the app will compile correctly and is installed on the device. But when I try to compile and deploy via Release or Distribution configuration it will give me this error
Error code 1 for command: cmd with args: /s,/c,ant,release,-f,d:\PhoneGap\projects\MyWeddingCard\MyWeddingCard\bld\Distribution\platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
1> Command finished with error code 2: d:\phonegap\projects\MyWeddingCard\MyWeddingCard\bld\Distribution\platforms\android\cordova\build.bat --release,
1>
1> C:\Users\RezaRa\AppData\Roaming\npm\node_modules\vs-mda\node_modules\q\q.js:126
1> throw e;
1> ^
1>EXEC : error : d:\phonegap\projects\MyWeddingCard\MyWeddingCard\bld\Distribution\platforms\android\cordova\build.bat: Command failed with exit code 2
1> at ChildProcess.whenDone (C:\Users\RezaRa\AppData\Roaming\npm\node_modules\vs-mda\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23)
1> at ChildProcess.emit (events.js:98:17)
1> at maybeClose (child_process.js:756:16)
1> at Process.ChildProcess._handle.onexit (child_process.js:823:5)
I know this a general error but is there any way to undrestand what is the problem.
p.s I have created Keystore file and added to ant.properties file.
I found the problem I changed keystore file path in ant properties from
key.store=D:\PhoneGap\projects\MyWeddingCard\Key\MyWeddingCardKeystore.keystore
to
key.store=D:\\PhoneGap\\projects\\MyWeddingCard\\Key\\MyWeddingCardKeystore.keystore

Cordova building android issue

i'm building an android app with about 4Gig of local files ( most of them are songs ).
When i build my application for android using "cordova build android" command, i get the following error:
Compiling app on platform "android" via command
/Users/yveswebit/Desktop/APP/platforms/android/cordova/build
/usr/local/lib/node_modules/cordova/node_modules/q/q.js:126
throw e;
^
Error: An error occurred while building the android project.Error executing "ant debug -f "/Users/yveswebit/Desktop/APP/platforms/android/build.xml"":
BUILD FAILED
/Development/adt-bundle/sdk/tools/ant/build.xml:932: The following error occurred while executing this line:
/Development/adt-bundle/sdk/tools/ant/build.xml:950: null returned: 1
Total time: 23 seconds
at ChildProcess.<anonymous> (/usr/local/lib/node_modules/cordova/src/compile.js:65:22)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Process.ChildProcess._handle.onexit (child_process.js:802:5)
When i'm builing my application with less songs, the build is succesfully.
Thanks for help

Categories

Resources