Error in Building PhoneGap App

Error in Building PhoneGap App

by Gaurav Bothra -
Number of replies: 10

I am getting an error in building a PhoneGap app. I am customizing this moodle app and rebuilding this app. I am getting the error below. I am following this post for customization.


Build Date: 2018-06-11 15:45:50 +0000
--------------------------------------------------------------------------------
PLUGIN OUTPUT
--------------------------------------------------------------------------------
Fetching plugin "cordova-plugin-file@4.3.3" via npm
Installing "cordova-plugin-file" at "4.3.3" for android
Fetching plugin "cordova-plugin-compat@^1.0.0" via npm
Installing "cordova-plugin-compat" at "1.2.0" for android

The Android Persistent storage location now defaults to "Internal". Please check this plugin's README to see if your application needs any changes in its config.xml.

If this is a new application no changes are required.

If this is an update to an existing application that did not specify an "AndroidPersistentFileLocation" you may need to add:

      "<preference name="AndroidPersistentFileLocation" value="Compatibility" />"

to config.xml in order for the application to find previously stored files.
Fetching plugin "cordova-plugin-file-transfer@1.6.3" via npm
Installing "cordova-plugin-file-transfer" at "1.6.3" for android
Plugin dependency "cordova-plugin-file@4.3.3" already fetched, using that version.
Dependent plugin "cordova-plugin-file" already installed on android.
Fetching plugin "cordova-plugin-console@~1.0.0" via npm
Installing "cordova-plugin-console" at "1.0.7" for android
Fetching plugin "cordova-plugin-camera@2.4.1" via npm
Installing "cordova-plugin-camera" at "2.4.1" for android
Plugin dependency "cordova-plugin-compat@1.2.0" already fetched, using that version.
Dependent plugin "cordova-plugin-compat" already installed on android.
Subproject Path: CordovaLib
Fetching plugin "cordova-plugin-media-capture@1.4.3" via npm
Installing "cordova-plugin-media-capture" at "1.4.3" for android
Plugin dependency "cordova-plugin-file@4.3.3" already fetched, using that version.
Dependent plugin "cordova-plugin-file" already installed on android.
Plugin dependency "cordova-plugin-compat@1.2.0" already fetched, using that version.
Dependent plugin "cordova-plugin-compat" already installed on android.
Fetching plugin "cordova-plugin-device@1.1.6" via npm
Installing "cordova-plugin-device" at "1.1.6" for android
Fetching plugin "cordova-plugin-globalization@1.0.7" via npm
Installing "cordova-plugin-globalization" at "1.0.7" for android
Fetching plugin "cordova-plugin-inappbrowser@1.7.1" via npm
Installing "cordova-plugin-inappbrowser" at "1.7.1" for android
Fetching plugin "cordova-plugin-network-information@1.3.3" via npm
Installing "cordova-plugin-network-information" at "1.3.3" for android
Fetching plugin "cordova-plugin-statusbar@2.2.3" via npm
Installing "cordova-plugin-statusbar" at "2.2.3" for android
Fetching plugin "cordova-plugin-whitelist@1.3.2" via npm
Installing "cordova-plugin-whitelist" at "1.3.2" for android

               This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.
Fetching plugin "cordova-plugin-splashscreen@4.0.3" via npm
Installing "cordova-plugin-splashscreen" at "4.0.3" for android
Fetching plugin "cordova-universal-clipboard@0.1.0" via npm
Installing "cordova-universal-clipboard" at "0.1.0" for android
Fetching plugin "nl.kingsquare.cordova.background-audio@1.0.1" via npm
Installing "nl.kingsquare.cordova.background-audio" at "1.0.1" for android
Fetching plugin "phonegap-plugin-push@1.9.2" via npm
Installing "phonegap-plugin-push" at "1.9.2" for android
Subproject Path: CordovaLib
Fetching plugin "cordova-plugin-customurlscheme@4.3.0" via npm
Installing "cordova-plugin-customurlscheme" at "4.3.0" for android
Fetching plugin "ionic-plugin-keyboard@2.2.1" via npm
Installing "ionic-plugin-keyboard" at "2.2.1" for android
Fetching plugin "cordova-plugin-zip@3.1.0" via npm
Installing "cordova-plugin-zip" at "3.1.0" for android
Plugin dependency "cordova-plugin-file@4.3.3" already fetched, using that version.
Dependent plugin "cordova-plugin-file" already installed on android.
Fetching plugin "cordova-plugin-local-notifications-mm" via npm
Installing "cordova-plugin-local-notifications-mm" at "1.0.10" for android
Plugin dependency "cordova-plugin-device@1.1.6" already fetched, using that version.
Dependent plugin "cordova-plugin-device" already installed on android.
Fetching plugin "cordova-plugin-app-event" via npm
Installing "cordova-plugin-app-event" at "1.2.1" for android
Subproject Path: CordovaLib

        Your support is needed. If you use the local-notification plugin please support us in order to ensure further development.
        https://github.com/katzer/cordova-plugin-local-notifications#supporting

        Thank you!
Fetching plugin "https://github.com/Tunts/WebIntent.git" via git clone
Using shallow clone
Repository "https://github.com/Tunts/WebIntent.git" checked out to git ref "master" at "15fcb4e".
Installing "net.tunts.webintent" at "0.2.1" for android
Fetching plugin "https://github.com/ti8m/DocumentHandler.git" via git clone
Using shallow clone
Repository "https://github.com/ti8m/DocumentHandler.git" checked out to git ref "master" at "f501154".
Installing "ch.ti8m.documenthandler" at "0.2.2" for android
--------------------------------------------------------------------------------
PROJECT PROPERTIES
--------------------------------------------------------------------------------
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-25
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:support-v4:24.1.1+
cordova.gradle.include.1=phonegap-plugin-push/moodle-push.gradle
cordova.system.library.2=com.android.support:support-v13:23+
cordova.system.library.3=com.google.android.gms:play-services-gcm:9.8+
cordova.system.library.4=me.leolin:ShortcutBadger:1.1.11@aar
cordova.system.library.5=com.android.support:support-v4:27.1.0
--------------------------------------------------------------------------------
COMPILE OUTPUT
--------------------------------------------------------------------------------
Subproject Path: CordovaLib
Running command: /project/gradlew cdvBuildDebug -b /project/build.gradle -Dorg.gradle.daemon=true -Dorg.gradle.jvmargs=-Xmx2048m -Pandroid.useDeprecatedNdk=true
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_4vswg8l01ivt4x0mvr9cvmwol.run(/project/build.gradle:138)
The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
Incremental java compilation is an incubating feature.
The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead.
The ProjectDependency.getProjectConfiguration() method has been deprecated and is scheduled to be removed in Gradle 4.0.
ModuleDependency.getConfiguration() has been deprecated and is scheduled to be removed in Gradle 4.0. Use ModuleDependency.getTargetConfiguration() instead.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'project'.
> Could not resolve all dependencies for configuration ':_debugApkCopy'.
   > Could not find com.android.support:support-v4:27.1.0.
     Required by:
         project :
   > Could not find com.android.support:support-v4:27.1.0.
     Required by:
         project :
   > Could not find com.android.support:support-v4:27.1.0.
     Required by:
         project : > com.android.support:support-v13:23.4.0
   > Could not find com.android.support:support-v4:27.1.0.
     Required by:
         project : > com.google.android.gms:play-services-gcm:9.8.0 > com.google.android.gms:play-services-basement:9.8.0

* 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.363 secs
Command finished with error code 1: /project/gradlew cdvBuildDebug,-b,/project/build.gradle,-Dorg.gradle.daemon=true,-Dorg.gradle.jvmargs=-Xmx2048m,-Pandroid.useDeprecatedNdk=true
Error: /project/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'project'.
> Could not resolve all dependencies for configuration ':_debugApkCopy'.
   > Could not find com.android.support:support-v4:27.1.0.
     Required by:
         project :
   > Could not find com.android.support:support-v4:27.1.0.
     Required by:
         project :
   > Could not find com.android.support:support-v4:27.1.0.
     Required by:
         project : > com.android.support:support-v13:23.4.0
   > Could not find com.android.support:support-v4:27.1.0.
     Required by:
         project : > com.google.android.gms:play-services-gcm:9.8.0 > com.google.android.gms:play-services-basement:9.8.0

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    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)

Average of ratings: -
In reply to Gaurav Bothra

Re: Error in Building PhoneGap App

by Tair Imanov -

Same problem. Please write here if you find solution)

In reply to Gaurav Bothra

Re: Error in Building PhoneGap App

by behnaz ranjbar -

same problemmixed

does anyone know the solution?

In reply to behnaz ranjbar

Re: Error in Building PhoneGap App

by Grayson Bartlet -

I've been having this problem as well. My understanding is that it's caused by plugins wanting different versions of the Android support library. That issue can be resolved with the cordova-android-support-gradle-release plugin. I resolved that issue by adding the following to my config.xml:

    <gap:plugin name="cordova-android-support-gradle-release" source="npm" >
        <variable name = "ANDROID_SUPPORT_VERSION" value = "27.1.0" /> <!--forces plugins to use same version of android support library-->
    </gap:plugin>

...unfortunately that gives me a new error in phonegap:

Error: /project/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:font
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontStyle
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontWeight
I think the FontFamily stuff is required by the newer android versions.
In reply to Grayson Bartlet

Re: Error in Building PhoneGap App

by Grayson Bartlet -

OK, I don't get that error and am able to successfully compile if I also set the android-targetSdkVersion to 27.

However, the app now crashes when I launch it with this exception:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/util/zzw;

I think this is because I've got a conflict between the phonegap-plugin-push plugin and the cordova-plugin-google-analytics plugin, where they want different versions of some library. If you're not using the analytics plugin, tell me if this works for you.

In reply to Grayson Bartlet

Re: Error in Building PhoneGap App

by behnaz ranjbar -

I also got such a error :Error - Malformed config.xml

really it would be very nice if we could see a complete and step by step document for building an app in moodle site sad

In reply to Grayson Bartlet

Re: Error in Building PhoneGap App

by Dani Ureña -

Hello Grayson,
I had the same problem with the fonts I take these steps to find the solution:

I run my Android SDK Manager and see what exactly is my version of "Android SDK Build-Tools" and I specify this at the end of the file platforms/android/build.gradle :

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
}

After finding the solution I have reported it and it is already in the Wiki:

https://docs.moodle.org/dev/Setting_up_your_development_environment_for_Moodle_Mobile_2#ERROR:_In_.3Cdeclare-styleable.3E_FontFamilyFont.2C_unable_to_find_attribute_android:font

Regards.


In reply to Grayson Bartlet

Re: Error in Building PhoneGap App

by Dennie Walker -

Did you find a solution to this?
I have the same issue trying to build this app.

I am really pulling my hair out over this since none of the suggestions below work.

In reply to Gaurav Bothra

Re: Error in Building PhoneGap App

by Francis Mashalla -

I had the same error,  

Try this one

what you can do regarding this error is to modify your config.xml by adding this line of code

 

    <gap:plugin name="cordova-android-support-gradle-release" spec="https://github.com/dpa99c/cordova-android-support-gradle-             release">

        <variable name="ANDROID_SUPPORT_VERSION" value="27.+" />

    </gap:plugin>

 

and on the targetSDKVersion improve it to 27, it will looks like

<preference name="android-targetSdkVersion" value="27" />

 

Hope this will serve your day.

 

Lyca Till