urbanairship / urbanairship-cordova

Urban Airship integration with Apache Cordova
https://docs.airship.com/platform/mobile/setup/sdk/cordova/
Other
142 stars 149 forks source link

Getting Error on Android #197

Closed newuser44 closed 6 years ago

newuser44 commented 6 years ago

I keep having problems figuring what is the basics I need to setup a Cordova Android app. The documents seem to take me in circles.

I went to Firebase and set up a new project. I see the Server Key and Legacy Server key and Sender Id but not sure how those are used?

I went to Urban AirShip and created a test app. I put in the some of those values from FireBase. (The confusing part is it wants me to setup cordova, but I need values from the settings page first right?)

An existing Cordova App.

Requirements check results for android: Java JDK: installed 1.8.0 Android SDK: installed true Android target: installed android-26,android-25,android-24,android-23,android-22,android-21 Gradle: installed /home/files/programs/gradle-4.0.1/bin/gradle

Looks like I'm good with requirements.

I add urbanairship-cordova plugin.
Everything looks fine with the add.

I add the following to my Config.xml.

<preference name="com.urbanairship.production_app_secret" value="elEz473JTESTc65QAQ0g" />
<preference name="com.urbanairship.development_app_key" value="TEST???" />
<preference name="com.urbanairship.development_app_secret" value="??????" />
<preference name="com.urbanairship.gcm_sender" value="TEST" />
<preference name="com.urbanairship.in_production" value="false" />
<preference name="com.urbanairship.enable_push_onlaunch" value="true" />
<preference name="com.urbanairship.enable_analytics" value="true" />
<preference name="com.urbanairship.development_log_level" value="warn" />
<preference name="com.urbanairship.production_log_level" value="warn" />
<preference name="com.urbanairship.notification_accent_color" value="#0000ff" />

I assume the production app key is the Urban AirShip App key and Secret. I don't know where I find the development app key and secret at?

I try to build the cordova app. I get errors. Full Build --

Loading environment named: dev Environment dev loaded successfully! ANDROID_HOME=/home/aron/Android/Sdk JAVA_HOME=/home/aron/programs/java/jdk8 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_726605nsafyzcwl1ehoofan3k.run(/home/dev/project/src/main/mobileapp/PayTestNotify/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. :preBuild UP-TO-DATE :preDebugBuild UP-TO-DATE :checkDebugManifest :preReleaseBuild UP-TO-DATE :CordovaLib:preBuild UP-TO-DATE :CordovaLib:preDebugBuild UP-TO-DATE :CordovaLib:checkDebugManifest :CordovaLib:prepareDebugDependencies :CordovaLib:compileDebugAidl :CordovaLib:compileDebugNdk UP-TO-DATE :CordovaLib:compileLint :CordovaLib:copyDebugLint UP-TO-DATE :CordovaLib:mergeDebugShaders :CordovaLib:compileDebugShaders :CordovaLib:generateDebugAssets :CordovaLib:mergeDebugAssets :CordovaLib:mergeDebugProguardFiles UP-TO-DATE :CordovaLib:packageDebugRenderscript UP-TO-DATE :CordovaLib:compileDebugRenderscript :CordovaLib:generateDebugResValues :CordovaLib:generateDebugResources :CordovaLib:packageDebugResources :CordovaLib:processDebugManifest :CordovaLib:generateDebugBuildConfig :CordovaLib:processDebugResources :CordovaLib:generateDebugSources :CordovaLib:incrementalDebugJavaCompilationSafeguard :CordovaLib:compileDebugJavaWithJavac :CordovaLib:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. :CordovaLib:processDebugJavaRes UP-TO-DATE :CordovaLib:transformResourcesWithMergeJavaResForDebug :CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug :CordovaLib:mergeDebugJniLibFolders :CordovaLib:transformNative_libsWithMergeJniLibsForDebug :CordovaLib:transformNative_libsWithSyncJniLibsForDebug :CordovaLib:bundleDebug :CordovaLib:preReleaseBuild UP-TO-DATE :CordovaLib:checkReleaseManifest :CordovaLib:prepareReleaseDependencies :CordovaLib:compileReleaseAidl :CordovaLib:compileReleaseNdk UP-TO-DATE :CordovaLib:copyReleaseLint UP-TO-DATE :CordovaLib:mergeReleaseShaders :CordovaLib:compileReleaseShaders :CordovaLib:generateReleaseAssets :CordovaLib:mergeReleaseAssets :CordovaLib:mergeReleaseProguardFiles UP-TO-DATE :CordovaLib:packageReleaseRenderscript UP-TO-DATE :CordovaLib:compileReleaseRenderscript :CordovaLib:generateReleaseResValues :CordovaLib:generateReleaseResources :CordovaLib:packageReleaseResources :CordovaLib:processReleaseManifest :CordovaLib:generateReleaseBuildConfig :CordovaLib:processReleaseResources :CordovaLib:generateReleaseSources :CordovaLib:incrementalReleaseJavaCompilationSafeguard :CordovaLib:compileReleaseJavaWithJavac :CordovaLib:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. :CordovaLib:processReleaseJavaRes UP-TO-DATE :CordovaLib:transformResourcesWithMergeJavaResForRelease :CordovaLib:transformClassesAndResourcesWithSyncLibJarsForRelease :CordovaLib:mergeReleaseJniLibFolders :CordovaLib:transformNative_libsWithMergeJniLibsForRelease :CordovaLib:transformNative_libsWithSyncJniLibsForRelease :CordovaLib:bundleRelease :prepareAndroidArchLifecycleRuntime100Library :prepareComAndroidSupportAnimatedVectorDrawable2531Library :prepareComAndroidSupportAppcompatV72531Library :prepareComAndroidSupportCardviewV72531Library :prepareComAndroidSupportSupportCompat2701Library :prepareComAndroidSupportSupportCoreUi2701Library :prepareComAndroidSupportSupportCoreUtils2701Library :prepareComAndroidSupportSupportFragment2701Library :prepareComAndroidSupportSupportMediaCompat2701Library :prepareComAndroidSupportSupportV42701Library :prepareComAndroidSupportSupportVectorDrawable2531Library :prepareComGoogleAndroidGmsPlayServicesBase1160Library :prepareComGoogleAndroidGmsPlayServicesBaseLicense1160Library :prepareComGoogleAndroidGmsPlayServicesBasement1160Library :prepareComGoogleAndroidGmsPlayServicesBasementLicense1160Library :prepareComGoogleAndroidGmsPlayServicesGcm1160Library :prepareComGoogleAndroidGmsPlayServicesGcmLicense1160Library :prepareComGoogleAndroidGmsPlayServicesIid1160Library :prepareComGoogleAndroidGmsPlayServicesIidLicense1160Library :prepareComGoogleAndroidGmsPlayServicesLocation1160Library :prepareComGoogleAndroidGmsPlayServicesLocationLicense1160Library :prepareComGoogleAndroidGmsPlayServicesTasks1160Library :prepareComGoogleAndroidGmsPlayServicesTasksLicense1160Library :prepareComUrbanairshipAndroidUrbanairshipSdk882Library :prepareOrgApacheCordovaCordovaLib623DebugLibrary :prepareDebugDependencies :compileDebugAidl :compileDebugRenderscript :generateDebugBuildConfig :generateDebugResValues :generateDebugResources :mergeDebugResources :processDebugManifest /home/dev/project/src/main/mobileapp/mobileapp/PayTestNotify/platforms/android/AndroidManifest.xml:41:9-51:20 Warning: activity#com.urbanairship.cordova.CustomLandingPageActivity was tagged at AndroidManifest.xml:41 to replace another declaration but no other declaration present :processDebugResourcesERROR: In FontFamilyFont, unable to find attribute android:font ERROR: In FontFamilyFont, unable to find attribute android:fontStyle ERROR: In FontFamilyFont, unable to find attribute android:fontWeight

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: 14.535 secs Error: /home/dev/project/src/main/mobileapp/PayTestNotify/platforms/android/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 FontFamilyFont, unable to find attribute android:font ERROR: In FontFamilyFont, unable to find attribute android:fontStyle ERROR: In FontFamilyFont, unable to find attribute android:fontWeight

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.

If I uninstall the Urban Airship plugin I can build just fine.

Any idea what I'm doing wrong?

rlepinski commented 6 years ago

I dont think you are doing anything wrong. Looks like we are using a feature wrong in the AndoridManifst.xml, but for whatever reason was not being flagged until the newer version of android plugin. We will have a patch to fix it today.

newuser44 commented 6 years ago

That is good to know I wasn't going insane. I have android 6.2.3 installed, is there an older version that I should try? I did try a newer version 6.3.0 that also seemed to have the problem. Now that I think about it makes sense. Thanks for the quick response.

rlepinski commented 6 years ago

I am unable to reproduce it, but I think I know what needs to be fixed. In platform/urbanairship-cordova/plugin.xml you can remove the tools:node="replace" on the CustomLandingPage entry. Or you can try out my branch release-6.9.2. Trying to verify it builds and will hopefully to a release today.

rlepinski commented 6 years ago

Should be fixed in 6.9.2

newuser44 commented 6 years ago

I did re-install the urbanairship-cordova plugin. I see that I am getting 6.9.2.

Now I am getting a different error.

FAILED

FAILURE: Build failed with an exception.

BUILD FAILED

Total time: 21.046 secs Error: /home/dev/project/src/main/mobileapp/mobileapp/PayTestNotify/platforms/android/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. /home/dev/project/src/main/mobileapp/mobileapp/PayTestNotify/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'.

/home/dev/project/src/main/mobileapp/mobileapp/PayTestNotify/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'.

FAILURE: Build failed with an exception.

rlepinski commented 6 years ago

@newuser44 Those errors are not coming from our SDK but from one of the support libraries. What android cordova plugin version are you using?

newuser44 commented 6 years ago

@rlepinski Installed platforms: android 6.2.3

newuser44 commented 6 years ago

And on Cordova version 7.0.1

newuser44 commented 6 years ago

The only help the internet is giving is that something with 26.0.1 file needs to be used? I tried what I could doing something in the config.xml with 26.0.1 for the buildToolsVersion that doesn't seem to do anything.

I let android studio do an update and it update some more gradle files. (Now I have 26.0.2). I don't even know why its using that, in config.xml

The only thing left is to update Cordova, I fear that might cause problems with other plugins we are using.

rlepinski commented 6 years ago

Looking through cordovas docs, you need to have Android 6.3.0 for 26.0.2. Could you try updating the android plugin?

arafath commented 6 years ago

Hello,

I am having the same problem , with my app, it's not Cordova, but using normal android app .. my app level gradle has following :

compile 'com.urbanairship.android:urbanairship-fcm:9.3.0'
compile 'com.google.firebase:firebase-messaging:17.1.0'
compile 'com.google.firebase:firebase-core:16.0.1'

If I complile without urban airship-fcm , it just compiles fine, but if I enable as above, it gives below error :

../../.gradle/caches/transforms-1/files-1.1/appcompat-v7-23.3.0.aar/cc0a267ad9cb286b17c52eefed79159f/res/values/values.xml  
error: resource android:attr/fontStyle not found.  
error: resource android:attr/font not found.  
error: resource android:attr/fontWeight not found.  

Could you please help.