Flutter build for plugin fails, class file not found

160

Are you using implementation for adding any dependency?

If yes, try replacing it with api. Not sure but it worked for me.

Example:

Replace

implementation 'com.github.niraj-prajapati:UPIPayments:1.1.4'

with

api 'com.github.niraj-prajapati:UPIPayments:1.1.4'
Share:
160
Jacob Brasil
Author by

Jacob Brasil

Updated on December 30, 2022

Comments

  • Jacob Brasil
    Jacob Brasil over 1 year

    I'm developing a plugin using Snapchat's SDK, it runs fine on iOS, however when compiling and running on Android I keep getting an error:

    /Users/jnbra/Projects/snapkit/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java:17: error: cannot access LoginStateController
        flutterEngine.getPlugins().add(new com.jacobbrasil.snapkit.SnapkitPlugin());
                              ^
    class file for com.snapchat.kit.sdk.core.controller.LoginStateController not found
    1 error
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.
    > Compilation failed; see the compiler error output for details.
    

    The class is accessible and downloaded and I can view the source code for it in Android Studio. I've tried changing SDK versions, clearing my Gradle cache, and a few others but any help would be greatly appreciated, thanks!

    • Zaid Zakir
      Zaid Zakir almost 3 years
      Hi,Have you tried to file ->Invalidate/cache and restart and then rebuild project,in android studio? Sometimes this error occurs when project has not detected the new resource.
    • BlackPearl
      BlackPearl over 2 years
      Were you able to get any solution?
    • AGHA
      AGHA over 2 years
      Any update about this?
  • a7md0
    a7md0 about 2 years
    Does this apply to local AAR files too? I have it as implementation(name:'package_name', ext:'aar') but facing the same issue in the question
  • Niraj
    Niraj about 2 years
    @a7md0 , not sure about .aar file. but .jar can be used same way api files('libs/jarFileName.jar'). You can try replacing implementation with api and let me know if it helps. Till the time i'll also be checking when i get some time.
  • a7md0
    a7md0 about 2 years
    It's working perfectly, thank you. For reference it's api(name:'package_name', ext:'aar') now