Search code examples
androidcordovacordova-plugins

cordova-plugin-admob-free producing error during build process?


While building the android app using cordova, i encountered following error log:-

BUILD FAILED in 1m 21s
C:\Users\gagan\Projects\hybrid\framework\error\framework7\quotes\cordova\platforms\android\gradlew: Command failed with exit code 1 Error output:
C:\Users\gagan\Projects\hybrid\framework\error\framework7\quotes\cordova\platforms\android\app\src\main\java\name\ratson\cordova\admob\AdMob.java:5: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
                              ^
C:\Users\gagan\Projects\hybrid\framework\error\framework7\quotes\cordova\platforms\android\app\src\main\java\name\ratson\cordova\admob\AdMob.java:243: error: cannot find symbol
@NonNull
 ^
symbol:   class NonNull
 location: class AdMob
 2 errors

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

As specified in question, it's occuring due to cordova-plugin-admob-free.How can i remove the error?


Solution

  • If anyone is encountering the same issue, I managed to solve it even if the fix is "dirty" but sometimes you just need to be able to build at any costs...

    You need to modify platforms/android/app/src/main/java/name/ratson/cordova/admob/AdMob.java file.

    Replace line 5 of file:

    import android.support.annotation.NonNull;
    

    by

    import androidx.annotation.NonNull;
    

    You'll also need cordova-plugin-androidx plugin to be installed.