Troubleshoot

Some common errors you might face in development when using Ionic 5 Full App

Error in Android Studio

Caused by: org.gradle.api.resources.MissingResourceException: Could not read script 'ION-FULL-CPTR-FB/android/capacitor-cordova-android-plugins/cordova.variables.gradle' as it does not exist.

Solution : Ionic capacitor update

Error while running capacitor update

[!] GoogleAppMeasurement requires CocoaPods version >= 1.10.2, which is not satisfied by your current version, 1.10.1.

Solution : sudo gem install cocoapods

Twitter plugin error in Android Studio

import com.getcapacitor.Config; Solution - // comment this line when highlighted in android studio

1. Cannot read property 'then' of undefined agm-circle in circle-manager.ts ( For V2.0.0 with Angular 11.x )

Only for users of < V2.0.0

This issue is caused due to agm-circle property of @agm/core library. Although, at the time of writing of this troubleshooting step, the error is identified and fixed, but it is not published to npm.

To resolve, do one of the following

  • It is very much possible that in next version of @agm/core, this issue will be fixed automatically. So try and install if there is a newer version available than 3.0.0-beta.0

If not, then

  • In src/app/pages/layout/uber-map-flow , comment out the agm-circle tag

  • If you want to use the agm-circle functionality, you'll have to make changes in node_modules . Please follow this thread for possible solutions. If you make changes in node_modules, make sure you restart the app using ionic serve

2. Google plus plugin - GooglePlus.java:151: error: cannot access AbstractSafeParcelable.addApi(Auth.GOOGLE_SIGN_IN_API, gso.build())

This error can appear because of a mismatch in versions of Google libraries. E.g. You might have a build.gradle file that looks like this

compile "com.google.android.gms:play-services-ads:16.0.0"
compile "com.android.support:support-v4:27.1.1"
compile "com.soundcloud.android:android-crop:1.0.0@aar"
compile "com.facebook.android:facebook-android-sdk:4.25.0"
compile "com.google.android.gms:play-services-auth:11.8.0"
compile "com.google.android.gms:play-services-identity:11.8.0"
compile "com.android.support:support-annotations:27+"

Here, play-services-ads , play-services-auth and play-services-identity do not have a common version, which can cause troubles in APK builds. Changes the versions of the libraries to a common version, and preferably to latest version.

To make this change, sometime changing versions in build.gradle or config.xml alone is not sufficient. You might have to change the dependency of all plugins which are using Google services to use the latest version. To do this,

  • Remove the platform e.g. Android.

  • Search for PLAY_SERVICES_VERSION in plugins folder of the app, and change all versions to a common latest one (in our case 16.0.0)

  • Re-build platform

If you are successful in changing all version of Google dependencies, you build.gradle should look like this

compile "com.google.android.gms:play-services-ads:16.0.0"
compile "com.android.support:support-v4:27.1.1"
compile "com.soundcloud.android:android-crop:1.0.0@aar"
compile "com.facebook.android:facebook-android-sdk:4.25.0"
compile "com.google.android.gms:play-services-auth:16.0.0"
compile "com.google.android.gms:play-services-identity:16.0.0"
compile "com.android.support:support-v4:27+"

Also, make sure platforms/android/project.properties has the same versions

3. Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'

This error is primarily caused by non-mergeable library versions of android support libraries.

  • In some cases , setting multidexenabled = true in build.gradle can fix the problem

  • In a severe case, you might need to change all support dependencies to same version, and a definite one E.g. In above build.gradle -- support-v4:27.1.1 and support-v4:27+ might look compatible, but they can resolve to different versions. You can check better if you open the gradle files in Android Studio. It will give you warnings related to different versions. To resolve this, look for ANDROID_SUPPORT_V4_VERSION in your plugins, config.xml and package.json and change that to a common, definite version like 27.0.1 After changing these versions, remove the platform and re-build.

4. class file for com.google.android.gms.internal.zzbfm not found

Solution same as #1

5. com.android.dex.DexException: Multiple dex files define Lcom/google/zxing/BarcodeFormat;

If this error exists (in addition or without #2), then this is likely caused by a conflict between Facebook Plugin and Barcode Scanner plugin, because both plugins provide scannig libraries.

In this case, changing Facebook plugin version to 4.25.0 resolves the issue at the time of writing.

As an alternative, you can also add the following at the end of build.gradle to fix the issues

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == "com.facebook.android") {
          details.useVersion "4.25.0"
        }
    }
}

A detailed discussion can be found here

>> error: cannot find symbol AppEventsLogger.augmentWebView((WebView) this.webView.getView(), appContext);

This error happens in Facebook version 4.25.0 due to a clash with Barcode Scanner plugin

Make sure you have the following config

$ cordova -v
8.0.0
<plugin name="phonegap-plugin-barcodescanner" spec="^7.0.0">
    <variable name="CAMERA_USAGE_DESCRIPTION" value=".." />
    <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="..." />
</plugin>

<plugin name="cordova-plugin-facebook4" spec="^4.0.0">
    <variable name="APP_ID" value="..." />
    <variable name="APP_NAME" value="..." />
    <variable name="FACEBOOK_ANDROID_SDK_VERSION" value="4.25.0" />
</plugin>

Use cordova platform add android@6.4.0 --save.

Remove any cordova-*-gradle plugins if you have them installed (cordova-android-support-gradle-release).

An alternative is to comment out

AppEventsLogger.augmentWebView((WebView) this.webView.getView(), appContext);

at platforms/android/app/src/main/java/org/apache/cordova/facebook/ConnectPlugin.java:717

This will not affect the Facebook login process. The commented out line is relevant to Hybrid Mobile App Events

6. UnhandledPromiseRejectionWarning: Error: /Users/abhijeetrathore/Ionic5FullApp/platforms/android/gradlew: Command failed with exit code EACCES

This error can occur when you sync Gradle using android studio and a newer version is installed. In that case, the Gradle folder in not write accessible for ionic/cordova

Running following commands should resolve it

$ sudo chmod 777 /Applications/Android\ Studio.app/Contents/gradle/gradle-4.1/bin/gradle
sudo 

$ chmod 777 /Users/abhijeetrathore/Ionic4FullApp/platforms/android/gradlew

7. Adding a platform fails with error - "Source path does not exist : resources/android/icon/drawable-hdpi-icon.png"

This can happen because the config.xml contains the path to app's icon, while sometimes in the source code, the icons can be missing. To fix this, generate all icons and splash screens using command

$ ionic cordova resources

This will generate all icon and splash resources. After running this, remove any previously added platform which resulted in error, and then add the platform again.

Last updated