Taracque / cordova-plugin-braintree

:credit_card: A Cordova plugin for the Braintree mobile payment processing SDK.
MIT License
27 stars 42 forks source link

Android Build Failed #43

Closed keshavkhatri closed 7 years ago

keshavkhatri commented 7 years ago

Running "Ionic cordova run android" give me this output

ionic cordova prepare ✔ cordova prepare - done! Running command: /var/www/html/udestroyedApp/hooks/after_prepare/010_add_platform_class.js /var/www/html/udestroyedApp add to body class: platform-android cordova run android Running command: /var/www/html/udestroyedApp/hooks/after_prepare/010_add_platform_class.js /var/www/html/udestroyedApp

add to body class: platform-android ANDROID_HOME=/var/www/html/android-sdk-linux 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_b43f0xkpuv3nkck97zsklhth5.run(/var/www/html/udestroyedApp/platforms/android/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.

FAILURE: Build failed with an exception.

BUILD FAILED

Total time: 13.423 secs Error: /var/www/html/udestroyedApp/platforms/android/gradlew: Command failed with exit code 1 Error output: FAILURE: Build failed with an exception.

[ERROR] An error occurred while running cordova run android (exit code 1).

Taracque commented 7 years ago

Can you please post the output of the ionic info command?

keshavkhatri commented 7 years ago

cli packages: (/var/www/html/udestroyedApp/node_modules)

@ionic/cli-utils  : 1.8.1
ionic (Ionic CLI) : 3.8.1

global packages:

Cordova CLI : 7.0.1 
Gulp CLI    : not installed globally

local packages:

Cordova Platforms : android 6.2.3
Ionic Framework   : ionic1 1.3.3

System:

Android SDK Tools : 25.2.5
Node              : v6.11.2
npm               : 3.10.10 
OS                : Linux 4.4
keshavkhatri commented 7 years ago

I resolved that issue by adding maven repository in my gradle.build file but now a new error comes up which is as below

ionic cordova prepare ✔ cordova prepare - done! Running command: /var/www/html/udestroyedApp/hooks/after_prepare/010_add_platform_class.js /var/www/html/udestroyedApp add to body class: platform-android ✖ cordova build android - failed! [ERROR] An error occurred while running cordova build android (exit code 1):

    (truncated) ... P-TO-DATE
    :CordovaLib:generateReleaseResValues UP-TO-DATE
    :CordovaLib:generateReleaseResources UP-TO-DATE
    :CordovaLib:packageReleaseResources UP-TO-DATE
    :CordovaLib:processReleaseManifest UP-TO-DATE
    :CordovaLib:generateReleaseBuildConfig UP-TO-DATE
    :CordovaLib:processReleaseResources UP-TO-DATE
    :CordovaLib:generateReleaseSources UP-TO-DATE
    :CordovaLib:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
    :CordovaLib:compileReleaseJavaWithJavac UP-TO-DATE
    :CordovaLib:processReleaseJavaRes UP-TO-DATE
    :CordovaLib:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
    :CordovaLib:transformClassesAndResourcesWithSyncLibJarsForRelease 
    UP-TO-DATE
    :CordovaLib:mergeReleaseJniLibFolders UP-TO-DATE
    :CordovaLib:transformNative_libsWithMergeJniLibsForRelease UP-TO-DATE
    :CordovaLib:transformNative_libsWithSyncJniLibsForRelease UP-TO-DATE
    :CordovaLib:bundleRelease UP-TO-DATE
    :prepareComAndroidSupportAnimatedVectorDrawable2600Library UP-TO-DATE
    :prepareComAndroidSupportAppcompatV72600Library UP-TO-DATE
    :prepareComAndroidSupportCardviewV72600Library UP-TO-DATE
    :prepareComAndroidSupportDesign2600Library UP-TO-DATE
    :prepareComAndroidSupportMultidex101Library UP-TO-DATE
    :prepareComAndroidSupportRecyclerviewV72600Library UP-TO-DATE
    :prepareComAndroidSupportSupportCompat2600Library UP-TO-DATE
    :prepareComAndroidSupportSupportCoreUi2600Library UP-TO-DATE
    :prepareComAndroidSupportSupportCoreUtils2600Library UP-TO-DATE
    :prepareComAndroidSupportSupportFragment2600Library UP-TO-DATE
    :prepareComAndroidSupportSupportMediaCompat2600Library UP-TO-DATE
    :prepareComAndroidSupportSupportV42600Library UP-TO-DATE
    :prepareComAndroidSupportSupportVectorDrawable2600Library UP-TO-DATE
    :prepareComAndroidSupportTransition2600Library UP-TO-DATE
    :prepareComBraintreepaymentsApiBraintree262Library UP-TO-DATE
    :prepareComBraintreepaymentsApiCore262Library UP-TO-DATE
    :prepareComBraintreepaymentsApiDropIn310Library UP-TO-DATE
    :prepareComBraintreepaymentsBrowserSwitch014Library UP-TO-DATE
    :prepareComBraintreepaymentsCardForm310Library UP-TO-DATE
    :prepareComPaypalAndroidSdkPaypalOneTouch262Library UP-TO-DATE
    :prepareIoCardAndroidSdk551Library UP-TO-DATE
    :prepareOrgApacheCordovaCordovaLib623DebugLibrary UP-TO-DATE
    :prepareDebugDependencies
    :compileDebugAidl UP-TO-DATE
    :compileDebugRenderscript UP-TO-DATE
    :generateDebugBuildConfig UP-TO-DATE
    :generateDebugResValues UP-TO-DATE
    :generateDebugResources UP-TO-DATE
    :mergeDebugResources UP-TO-DATE
    :processDebugManifest UP-TO-DATE
    :processDebugResources/var/www/html/udestroyedApp/platforms/android/build/intermediates/res/merged/debug/values-v26/values-v26.xml:15:21-54: 
    AAPT: No resource found that matches the given name: attr 
    'android:keyboardNavigationCluster'.

    /var/www/html/udestroyedApp/platforms/android/build/intermediates/res/merged/debug/values-v26/values-v26.xml:18:21-54: 
    AAPT: No resource found that matches the given name: attr 
    'android:keyboardNavigationCluster'.

    /var/www/html/udestroyedApp/platforms/android/build/intermediates/res/merged/debug/values-v26/values-v26.xml:15: 
    error: Error: No resource found that matches the given name: attr 
    'android:keyboardNavigationCluster'.

    /var/www/html/udestroyedApp/platforms/android/build/intermediates/res/merged/debug/values-v26/values-v26.xml:18: 
    error: Error: No resource found that matches the given name: attr 
    'android:keyboardNavigationCluster'.

      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: 2.501 secs
    Error: /var/www/html/udestroyedApp/platforms/android/gradlew: Command 
    failed with exit code 1 Error output:
    /var/www/html/udestroyedApp/platforms/android/build/intermediates/res/merged/debug/values-v26/values-v26.xml:15:21-54: 
    AAPT: No resource found that matches the given name: attr 
    'android:keyboardNavigationCluster'.

    /var/www/html/udestroyedApp/platforms/android/build/intermediates/res/merged/debug/values-v26/values-v26.xml:18:21-54: 
    AAPT: No resource found that matches the given name: attr 
    'android:keyboardNavigationCluster'.

    /var/www/html/udestroyedApp/platforms/android/build/intermediates/res/merged/debug/values-v26/values-v26.xml:15: 
    error: Error: No resource found that matches the given name: attr 
    'android:keyboardNavigationCluster'.

    /var/www/html/udestroyedApp/platforms/android/build/intermediates/res/merged/debug/values-v26/values-v26.xml:18: 
    error: Error: No resource found that matches the given name: attr 
    'android:keyboardNavigationCluster'.

    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.
keshavkhatri commented 7 years ago

Finally i resolved the second issue as well and the build is successful now. It was due to mismatch of support library version and the android version.

ghost commented 7 years ago

@keshavkhatri I am stuck too on the second issue you had. Can you tell me how did you fix it please? I am struggling since this morning 😢

Taracque commented 7 years ago

You need to install android support library v26. You can try this: cordova plugin add cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION=26.+

ghost commented 7 years ago

@Taracque thanks for answering ! But now I'm getting the following error, after installing the plugin:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformClassesWithDexForArmv7Debug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lorg/apache/cordova/BuildHelper;

Could be some conflict with another plugin? But how can I find that tho?

Currently installed plugins:

cordova-android-support-gradle-release 1.1.1 "cordova-android-support-gradle-release"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-apprate 1.3.0 "AppRate"
cordova-plugin-badge 0.8.1 "Badges"
cordova-plugin-braintree 0.5.2 "Braintree Plugin"
cordova-plugin-camera 2.4.0 "Camera"
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-crosswalk-webview 2.3.0 "Crosswalk WebView Engine"
cordova-plugin-customurlscheme 4.2.0 "Custom URL scheme"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-dialogs 1.3.3 "Notification"
cordova-plugin-facebook4 1.7.4 "Facebook Connect"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-file-transfer 1.6.2 "File Transfer"
cordova-plugin-geolocation 2.4.2 "Geolocation"
cordova-plugin-globalization 1.0.6 "Globalization"
cordova-plugin-google-analytics 1.8.2 "Google Universal Analytics Plugin"
cordova-plugin-googleplus 5.1.1 "Google SignIn"
cordova-plugin-hockeyapp 2.2.3 "HockeyApp"
cordova-plugin-inappbrowser 1.6.1 "InAppBrowser"
cordova-plugin-ionic-webview 1.1.11 "Ionic's WKWebView Engine"
cordova-plugin-network-information 1.3.3 "Network Information"
cordova-plugin-splashscreen 4.0.1 "Splashscreen"
cordova-plugin-statusbar 2.2.2 "StatusBar"
cordova-plugin-whitelist 1.3.2 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"
phonegap-plugin-push 1.10.5 "PushPlugin"
Taracque commented 7 years ago

Do you have cordova-plugin-compat plugin installed? If yes, please try to remove it.

ghost commented 7 years ago

Yes but it's required by cordova-plugin-camera, cordova-plugin-file-transfer and cordova-plugin-geolocation.

Can't uninstall it 😢

Taracque commented 7 years ago

Which version of cordova are you using? It shouldn't needed with cordova-android >= 6.3.0

ghost commented 7 years ago

Cordova 6.5.0

I've downgraded android platform from 6.3.0 to 6.1.2 and it throws another error.

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.
/Users/ionut/Code/k/app/platforms/android/build/intermediates/res/merged/armv7/debug/values-v26/values-v26.xml:15:21-54: AAPT: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.

/Users/ionut/Code/k/app/platforms/android/build/intermediates/res/merged/armv7/debug/values-v26/values-v26.xml:18:21-54: AAPT: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.

/Users/ionut/Code/k/app/platforms/android/build/intermediates/res/merged/armv7/debug/values-v26/values-v26.xml:15: error: Error: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.

/Users/ionut/Code/k/app/platforms/android/build/intermediates/res/merged/armv7/debug/values-v26/values-v26.xml:18: error: Error: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processArmv7DebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

That's the same error as @keshavkhatri error

Even if I installed the plugin you suggested.

If I use cordova-android@6.3.0 again the multidex error re-appears

ghost commented 7 years ago

Well I removed the compat plugin and upgraded to cordova-android@6.3 and now I'm getting the following:

* What went wrong:
Execution failed for task ':transformClassesWithDexForArmv7Debug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: Cannot merge new index 65571 into a non-jumbo instruction!

What that even means?

Dunno what else to do...

We'll keep googling. Thanks for your help !!

LE:

Got it working by enabling jumboMode in build.gradle file

android {
   dexOptions {
        jumboMode true
    }
}