can´t create an apk with an ionic project - android

Hi im new in ionic and im trying to create an apk to in order to test my qr scanner project, but when I run the command ionic cordova build android --release
i got the following error output:
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
:processReleaseManifest FAILED
BUILD FAILED
Total time: 13.446 secs
C:\Users\delacrga\Ionic projects\myApp\platforms\android\AndroidManifest.xml:19:5-65 Error:
Element uses-permission#android.permission.CAMERA at AndroidManifest.xml:19:5-65 duplicated with element
declared at AndroidManifest.xml:16:5-90
C:\Users\delacrga\Ionic projects\myApp\platforms\android\AndroidManifest.xml:21:5-84 Error:
Element uses-feature#android.hardware.camera at AndroidManifest.xml:21:5-84 duplicated with element declared at
AndroidManifest.xml:17:5-85
C:\Users\delacrga\Ionic projects\myApp\platforms\android\AndroidManifest.xml Error:
Validation failed, exiting
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processReleaseManifest'.
> Manifest merger failed with multiple errors, see logs
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Error: cmd: Command failed with exit code 1 Error output:
C:\Users\delacrga\Ionic projects\myApp\platforms\android\AndroidManifest.xml:19:5-65 Error:
Element uses-permission#android.permission.CAMERA at AndroidManifest.xml:19:5-65 duplicated with element
declared at AndroidManifest.xml:16:5-90
C:\Users\delacrga\Ionic projects\myApp\platforms\android\AndroidManifest.xml:21:5-84 Error:
Element uses-feature#android.hardware.camera at AndroidManifest.xml:21:5-84 duplicated with element declared at
AndroidManifest.xml:17:5-85
C:\Users\delacrga\Ionic projects\myApp\platforms\android\AndroidManifest.xml Error:
Validation failed, exiting
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processReleaseManifest'.
> Manifest merger failed with multiple errors, see logs
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Could someone helpme with this?
output:
C:\Users\delacrga\Ionic projects\myApp>ionic cordova build android --prod --release -- -- --keystore=filename.keystore --alias=myalias
Running app-scripts build: --prod --iscordovaserve --externalIpRequired --nobrowser
[08:52:04] build prod started ...
[08:52:04] clean started ...
[08:52:04] clean finished in 10 ms
[08:52:04] copy started ...
[08:52:04] ngc started ...
[08:52:15] ngc finished in 11.48 s
[08:52:15] preprocess started ...
[08:52:16] deeplinks started ...
[08:52:16] deeplinks finished in 63 ms
[08:52:16] optimization started ...
[08:52:16] copy finished in 11.85 s
[08:52:26] optimization finished in 10.47 s
[08:52:26] preprocess finished in 10.54 s
[08:52:26] webpack started ...
[08:52:32] webpack finished in 5.46 s
[08:52:32] sass started ...
[08:52:32] uglifyjs started ...
[08:52:33] sass finished in 1.22 s
[08:52:33] cleancss started ...
[08:52:35] cleancss finished in 1.93 s
[08:52:42] uglifyjs finished in 10.23 s
[08:52:42] postprocess started ...
[08:52:42] postprocess finished in 15 ms
[08:52:42] lint started ...
[08:52:42] build prod finished in 37.83 s
> cordova build android --release -- --keystore=filename.keystore --alias=myalias
× 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 --release -- --keystore=filename.keystore --alias=myalias
(exit code 1):
ANDROID_HOME=C:\Users\delacrga\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\java\jdk1.8.0_131
Subproject Path: CordovaLib
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use
Task.doLast(Action) instead.
at build_amlj4yw9chmdse17z8bfqqws2.run(C:\Users\delacrga\Ionic
projects\myApp\platforms\android\build.gradle:139)
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\delacrga\Ionic projects\myApp\platforms\android\build.gradle' line: 289
* What went wrong:
A problem occurred evaluating root project 'android'.
> Keystore file does not exist: C:\Users\delacrga\Ionic projects\myApp\platforms\android\..\..\filename.keystore
* 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.175 secs
Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\delacrga\Ionic projects\myApp\platforms\android\build.gradle' line: 289
* What went wrong:
A problem occurred evaluating root project 'android'.
> Keystore file does not exist: C:\Users\delacrga\Ionic projects\myApp\platforms\android\..\..\filename.keystore
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

By any chance if you have two different plugins installed which asks permission for the camera i.e. cordova-plugin-qrscanner and phonegap-plugin-barcodescanner together, it will cause this issue.
Remove either of the plugin by
ionic cordova plugin remove phonegap-plugin-barcodescanner
or
ionic cordova plugin remove cordova-plugin-qrscanner

Yes.#Jay is right. Because my ionic project have two different plugins installed which asks permission for the camera. cordova-plugin-qrscanner and cordova-plugin-cszbar,Remove either of the plugin then working.

Related

flutter build apk giving error "Execution failed for task ':app:mergeReleaseResources'." on jenkins

I am getting below exception when i build my flutter project on jenkins
C:\ProgramData\Jenkins\.jenkins\workspace\automated test app>flutter build apk
Building with sound null safety
Running Gradle task 'assembleRelease'...
Parameter format not correct -
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> Multiple task action failures occurred:
> A failure occurred while executing
com.android.build.gradle.internal.res.Aapt2CompileRunnable
> Android resource compilation failed
ERROR:C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-3\846e5094a0f0114af067375a609d094e\transformed\core-1.6.0\res\drawable-mdpi-v4\notification_bg_normal.9.png: AAPT: error: file not found.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> Android resource compilation failed
ERROR:C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-3\846e5094a0f0114af067375a609d094e\transformed\core-1.6.0\res\drawable-mdpi-v4\notification_bg_low_normal.9.png: AAPT: error: file not found.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> Android resource compilation failed
ERROR:C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-3\846e5094a0f0114af067375a609d094e\transformed\core-1.6.0\res\drawable-mdpi-v4\notification_bg_low_pressed.9.png: AAPT: error: file not found.
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 25s
Running Gradle task 'assembleRelease'... 86.2s
Gradle task assembleRelease failed with exit code 1
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
I am faced with this problem with Gitlab ci/Runner on Windows 10 and i stucked with all day.
The problem is that I have not installed Gitlab-Runner with privileges windows with my user account before :
cd C:\GitLab-Runner
.\gitlab-runner.exe install
.\gitlab-runner.exe start
But after, I installed Gitlab-Runner using my user account. The problems no longer occurs.
cd C:\GitLab-Runner
.\gitlab-runner.exe install --user ".\USERR" --password "MYPASSWORD"
.\gitlab-runner.exe start
So, I think maybe your problem is that you are not running the script with a privileges.
The fact that I saw this because when I tried to access the image file.
For example : C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-3\846e5094a0f0114af067375a609d094e\transformed\core-1.6.0\res\drawable-mdpi-v4\notification_bg_normal.9.png
I'm not able to reach the "C:\Windows\System32" without accepting the privileges administrator windows.
But if I accept as administrator, I can find the image file.

Getting buid error in node.js for Android

i am getting build error after i add android:requestLegacyExternalStorage="true" in Androidmanifest.xml file, without android:requestLegacyExternalStorage="true" can build . In android ver 10 devices cant create directory so i added android:requestLegacyExternalStorage="true".
I am build with node.js cmd prompt. Error as follow
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
* 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.908 secs
cmd: Command failed with exit code 1 Error output:
F:\Mobile Projects\1652019\FingerTips\OAMobile\platforms\android\build\intermediates\manifests\full\debug\AndroidManifest.xml:39: AAPT: No resource identifier found for attribute 'requestLegacyExternalStorage' in package 'android'
F:\Mobile Projects\1652019\FingerTips\OAMobile\platforms\android\build\intermediates\manifests\full\debug\AndroidManifest.xml:39: error: No resource identifier found for attribute 'requestLegacyExternalStorage' in package 'android'
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processDebugResources'.
What i tried, i remove android platform and add again, still getting error, i install this plugin also cordova plugin add cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION=27.+
when i trace with this command gradle compileDebug --scan , i get below 2 error
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
Where:
Script 'F:\Mobile Projects\1652019\FingerTips\OAMobile\platforms\android\CordovaLib\cordova.gradle' line: 64
What went wrong:
A problem occurred evaluating root project 'android'.
No installed build tools found. Install the Android build tools version 19.1.0 or higher.
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.
2: Task failed with an exception.
What went wrong:
A problem occurred configuring root project 'android'.
buildToolsVersion is not specified.
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.
Regards and Thanks
Aravind
AAPT: No resource identifier found for attribute 'requestLegacyExternalStorage' in package 'android'
This is generally caused by using an incompatible build tools version. For requestLegacyExternalStorage, you need version 29.x build tools.
Open up Android Studio's SDK Manager and install the latest version of build tools available. Then make sure the build tools directory is in your PATH environment variable. Don't forget to restart your terminal session after changing your environment variables.

PhoneGap Build - Could not get unknown property 'GMS_VERSION' for object of type org.gradle

From one day to another my build is now failing and these are the logs I have got from phonegap build:
Total time: 2.61 secs
Subproject Path: CordovaLib
"plugman-151 install --platform android --project /project --plugin cordova-plugin-splashscreen --nohooks=.": Fetching plugin "cordova-plugin-splashscreen" via npm
Installing "cordova-plugin-splashscreen" at "5.0.2" for android
Subproject Path: CordovaLib
null
FAILURE: Build failed with an exception.
* Where:
Build file '/project/build.gradle' line: 253
* What went wrong:
A problem occurred evaluating root project 'project'.
> Could not get unknown property 'GMS_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* 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: 0.853 secs
Failed to install 'cordova-plugin-splashscreen': Error: /project/gradlew: Command failed with exit code 1
at ChildProcess.whenDone (/project/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
/project/gradlew: Command failed with exit code 1
I thought there was a problem with the splashscreen plugin so I downgrade it and then removed it but then the builds keeps failing complaining about another plugin with basically the same error.
I don't know much about the Gradle file and from my understanding PhoneGap Build takes care of it or at least it should handle it.
I am using Phonegap-cli 6.4 and the build is for Android.
Please guys let me know if you need further info to help and THANKS a lot :)
UPDATE: The only way to get a successful build is removing all the plugins from the config.xml :'( :'( :'(...and now? Still trying to figure out another way to add the plugins then.
UPDATE 2: These are the logs if I use Phonegap-Cli 7.0.1
--------------------------------------------------------------------------------
COMPILE OUTPUT
--------------------------------------------------------------------------------
:wrapper
BUILD SUCCESSFUL in 2s
1 actionable task: 1 executed
Subproject Path: CordovaLib
null
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
at build_3165fehnqtadtl3m714hg3us5.run(/build.gradle:138)
FAILURE: Build failed with an exception.
* Where:
Build file '/build.gradle' line: 253
* What went wrong:
A problem occurred evaluating root project 'www_android'.
> Could not get unknown property 'GMS_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* 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: 1.08 secs
Error: /gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* Where:
Build file '/build.gradle' line: 253
* What went wrong:
A problem occurred evaluating root project 'www_android'.
> Could not get unknown property 'GMS_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
at ChildProcess.whenDone (/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
Similar error - no clue whats going on
I got a a successful build deleting this line in my config.xml
<plugin name="cordova-plugin-google-analytics" source="npm" />
Maybe there is a problem with this plugin...
good luck!

ionic build cordova android gives error " UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 "

I am trying to build and ionic project as an apk. When I do ionic cordova build android it gives the following error
Running app-scripts build: --platform android --target cordova
[23:35:31] build dev started ...
[23:35:31] clean started ...
[23:35:31] clean finished in 20 ms
[23:35:31] copy started ...
[23:35:31] deeplinks started ...
[23:35:31] deeplinks finished in 75 ms
[23:35:31] transpile started ...
[23:35:35] transpile finished in 3.87 s
[23:35:35] preprocess started ...
[23:35:35] preprocess finished in 33 ms
[23:35:35] webpack started ...
[23:35:35] copy finished in 4.25 s
[23:35:40] webpack finished in 4.78 s
[23:35:40] sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[23:35:41] sass finished in 1.02 s
[23:35:41] postprocess started ...
[23:35:41] postprocess finished in 77 ms
[23:35:41] lint started ...
[23:35:41] build dev finished in 10.20 s
> cordova build android --debug
You have been opted out of telemetry. To change this, run: cordova telemetry on.
Android Studio project detected
ANDROID_HOME=C:\Users\makarov\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_144
studio
Subproject Path: CordovaLib
Subproject Path: app
[23:35:44] lint finished in 3.65 s
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\My_Files\Projects\MyNoteApp\platforms\android\CordovaLib\build.gradle' line: 84
* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> build_ihrdqe7fln9qjqpg3xt8ghgr$_run_closure3$_closure11$_closure12$_closure13$_closure14
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
(node:11172) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\My_Files\Projects\MyNoteApp\platforms\android\CordovaLib\build.gradle' line: 84
* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> build_ihrdqe7fln9qjqpg3xt8ghgr$_run_closure3$_closure11$_closure12$_closure13$_closure14
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
at ChildProcess.whenDone (C:\My_Files\Projects\MyNoteApp\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
at ChildProcess.emit (events.js:159:13)
at maybeClose (internal/child_process.js:943:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
(node:11172) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:11172) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
When I do cordova platform ls I get this output
Installed platforms:
android 7.0.0
Available platforms:
browser ~5.0.1
ios ~4.5.4
osx ~4.0.1
windows ~5.0.0
www ^3.12.0
My Ionic version is 3 and I have Android SDK Platform-Tools 27 installed.
I also tried to build this app using PhoneGap too. When testing by hosting the app using PhoneGap desktop and using PhoneGap app on my phone, the app works fine including any native API that I am using (i.e. Toasts). When I go to PhoneGap build website and build my app into APK and run it on my phone I only get a white screen and nothing comes up.

An issue occurred configuring root project 'android'

I've read all posts having same issue, none resolved this. I am totally new to Ionic (I have some knowledge about Crodova and intelXdk but not Ionic).
I followed some tutorials to get my first app running. Firstly, it was running fine (of course, it had only texts :D ) then I started trying to make facebook login in the App.
I wasn't able to test this in Chrome as the facebook and storage are both Native dependencies, and could be not tested in a computer. Thus , I started trying to build the android app in order to test this in my phone and everytime I launch "ionic run android" I get this :
ionic run android --stacktrace
> ionic-app-base#0.0.0 ionic:build /home/chaibi/Bureau/foody
> ionic-app-scripts build "--stacktrace"
[16:14:53] ionic-app-scripts 1.3.7
[16:14:53] build dev started ...
[16:14:53] clean started ...
[16:14:53] clean finished in 4 ms
[16:14:53] copy started ...
[16:14:53] transpile started ...
[16:14:55] transpile finished in 2.34 s
[16:14:55] preprocess started ...
[16:14:55] deeplinks started ...
[16:14:55] deeplinks finished in 19 ms
[16:14:55] preprocess finished in 21 ms
[16:14:55] webpack started ...
[16:14:55] copy finished in 2.64 s
[16:15:04] webpack finished in 8.52 s
[16:15:04] sass started ...
[16:15:05] sass finished in 1.10 s
[16:15:05] postprocess started ...
[16:15:05] postprocess finished in 6 ms
[16:15:05] lint started ...
[16:15:05] build dev finished in 12.07 s
[16:15:07] lint finished in 2.37 s
ANDROID_HOME=/home/chaibi/Android/Sdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle
Subproject Path: CordovaLib
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
at build_2h23ogq2gf6aqvti7pywfv5r2.run(/home/chaibi/Bureau/foody/platforms/android/build.gradle:137)
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> java.lang.NullPointerException (no error message)
* 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: 1.822 secs
Error: /home/chaibi/Bureau/foody/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> java.lang.NullPointerException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I am using Ionic 2.2, openjdk-8 and developping using WebStorm

Categories

Resources