transistorsoft / cordova-background-geolocation-firebase

Firebase Adapter for Cordova Background Geolocation
MIT License
7 stars 5 forks source link

Capacitor + Firebase Plugin Error: Could not find com.transistorsoft.tsfirebaseproxy:+: #17

Closed vincentdsf closed 2 years ago

vincentdsf commented 3 years ago

I cant build an App on Android with cordova-background-geolocation-firebase in a Capacitor App, which uses the capacitor version of the background plugin. Apparently the com.transistorsoft.tsfirebaseproxy.0.1.1.aar cant be found even though I added libs folder as dependency


Your Environment

Expected Behavior

Should build / Import the .aar dependency

Actual Behavior

Error when trying to build: Execution failed for task ':app:checkDebugAarMetadata'. Could not resolve all files for configuration ':app:debugRuntimeClasspath'. Could not find com.transistorsoft.tsfirebaseproxy:+:.

Steps to Reproduce

Trying to build an app with the following gradle files doesnt work: android/build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

  repositories {
    google()
    jcenter()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:4.2.2'
    classpath 'com.google.gms:google-services:4.3.8'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  }
}

apply from: "variables.gradle"

allprojects {
  repositories {
    google()
    jcenter()
    maven {
      url("${project(':transistorsoft-capacitor-background-geolocation').projectDir}/libs")
    }
    maven {
      // capacitor-background-fetch
      url("${project(':transistorsoft-capacitor-background-fetch').projectDir}/libs")
    }
    maven {
      // [required] background_geolocation_firebase
      url "${project(':background_geolocation_firebase').projectDir}/libs"
    }
     maven {
          // [required] background_geolocation_firebase
          url "capacitor-cordova-android-plugins/libs"
        }
  }
}

task clean(type: Delete) {
  delete rootProject.buildDir
}

app/build.gradle:

apply plugin: 'com.android.application'

Project background_geolocation = project(':transistorsoft-capacitor-background-geolocation')
apply from: "${background_geolocation.projectDir}/app.gradle"

android {
  signingConfigs {
    release {
      storeFile file xxx
      storePassword xxx
      keyPassword xxx
    }
  }
  compileSdkVersion rootProject.ext.compileSdkVersion
  defaultConfig {
    applicationId "xxx.android"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  }
  buildTypes {
    debug {
      applicationIdSuffix ".testing"
    }
    release {
      minifyEnabled true
      debuggable false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      proguardFiles "${background_geolocation.projectDir}/proguard-rules.pro"
      signingConfig signingConfigs.release
    }
  }
}

repositories {
  flatDir {
    dirs '../capacitor-cordova-android-plugins/libs', 'libs'
  }
      maven {
            // [required] background_geolocation_firebase
            url "capacitor-cordova-android-plugins/libs/com/transistorsoft/tsfirebaseproxy/maven-metadata.xml"
          }
}

dependencies {
implementation fileTree(dir: "../libs", include: ["*.jar", "*.aar"])
  implementation "androidx.appcompat:appcompat:1.3.0"
  implementation project(':capacitor-android')
  implementation files('/Users/xxxx..../android/libs/tsfirebaseproxy-0.1.1.aar')
  implementation files('../libs/tsfirebaseproxy-0.1.1.aar')
  testImplementation "junit:junit:$junitVersion"
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
  androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
  implementation project(':capacitor-cordova-android-plugins')
  implementation 'com.transistorsoft.tsfirebaseproxy:+'

}

apply from: 'capacitor.build.gradle'

try {
  def servicesJSON = file('google-services.json')
  if (servicesJSON.text) {
    apply plugin: 'com.google.gms.google-services'
  }
} catch (Exception e) {
  logger.warn("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
}

Context

Build an Capacitor Android App with capacitor-background-geolocation plugin and cordova-background-geolocation-firebase.

Debug logs

Execution failed for task ':app:checkDebugAarMetadata'. > Could not resolve all files for configuration ':app:debugRuntimeClasspath'. > Could not find com.transistorsoft.tsfirebaseproxy:+:. Possible solution: - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html ``` PASTE_YOUR_LOGS_HERE ```
vincentdsf commented 3 years ago

I hope I didnt miss any important information, otherwise please let me know and I´ll provide all required information. As a note: I think it should work if used with the cordova-background-plugin (not the capacitor version), but maybe I just messed something up when switching to the Capacitor-Version.

christocracy commented 3 years ago

The Firebase adapter hasn't yet been ported to Capacitor.

vfsunny commented 3 years ago

Ok got it, so all I need to do is switch back to the Cordova version - thanks for clearification! Is a future release planned for this plug-in to support capacitor plugin?

christocracy commented 3 years ago

Yes, it will take a day to port once I get around to it.

vincentdsf commented 3 years ago

Ah great to hear, thanks - looking forward to it :) For now I´ll switch back since that doesnt change too much, but I´ll switch to capacitor plugins once this one is available. Thanks for your great work

vincentdsf commented 3 years ago

I tried switching back to the cordova-background version, but now I am getting a similar error: "E/EventBus: Could not dispatch event: class com.transistorsoft.locationmanager.event.PersistEvent to subscribing class class com.transistorsoft.tsfirebaseproxy.TSFirebaseProxy java.lang.RuntimeException: No properties to serialize found on class org.json.JSONObject$1 at com.google.firebase.firestore.util.CustomClassMapper$BeanMapper.(CustomClassMapper.java:714) at com.google.firebase.firestore.util.CustomClassMapper.loadOrCreateBeanMapperForClass(CustomClassMapper.java:377) at com.google.firebase.firestore.util.CustomClassMapper.serialize(CustomClassMapper.java:177) at com.google.firebase.firestore.util.CustomClassMapper.serialize(CustomClassMapper.java:140) at com.google.firebase.firestore.util.CustomClassMapper.serialize(CustomClassMapper.java:104) at com.google.firebase.firestore.util.CustomClassMapper.convertToPlainJavaTypes(CustomClassMapper.java:78) at com.google.firebase.firestore.UserDataReader.convertAndParseDocumentData(UserDataReader.java:231) at com.google.firebase.firestore.UserDataReader.parseSetData(UserDataReader.java:75) at com.google.firebase.firestore.DocumentReference.set(DocumentReference.java:166) at com.google.firebase.firestore.DocumentReference.set(DocumentReference.java:146) at com.google.firebase.firestore.CollectionReference.add(CollectionReference.java:121) at com.transistorsoft.tsfirebaseproxy.TSFirebaseProxy.onPersist(TSFirebaseProxy.java:146) at java.lang.reflect.Method.invoke(Native Method) at org.greenrobot.eventbus.EventBus.invokeSubscriber(EventBus.java:485) at org.greenrobot.eventbus.EventBus.postToSubscription(EventBus.java:429) at org.greenrobot.eventbus.EventBus.postSingleEventForEventType(EventBus.java:397) at org.greenrobot.eventbus.EventBus.postSingleEvent(EventBus.java:370) at org.greenrobot.eventbus.EventBus.post(EventBus.java:251) at com.transistorsoft.locationmanager.location.TSLocationManager$e.a(Unknown Source:39) at com.transistorsoft.locationmanager.location.TSLocationManager$e.run(Unknown Source:54) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:923)"

Is this related to this Plugin not yet being able to work with Capacitor or do I miss something?

vincentdsf commented 3 years ago

Is there a quick fix I could implement to make it work for a release? Our App completely relies on this plugin for storing the GPS positions from the Background Plugin and this error is currently preventing a new release after switching to capacitor. Both the Background Plugin and the Firebase-Background Plugin are installed as their Cordova-Versions (not the Capacitor-Background-Plugin), but the error still persis

christocracy commented 3 years ago

I don't know what the issue is. I suggest you remove / re-add both plugins.

vincentdsf commented 3 years ago

Alright I tried that today, uninstalled all cordova plugins, re-installed and configured them from scratch but no luck - whenever a location is supposed to be stored the error appears and the Firebase store is not successful. I see logs about the Plugin being registered and the Background Plugin works perfectly, just the Firestore storage seems to create a problem

vincentdsf commented 3 years ago

Update to latest capacitor (which fixed a JSON bug, I was already hoping that might fix it) didnt work, it seems the following plugin configuration just doesnt work: [info] Found 12 Capacitor plugins for android: @capacitor-community/fcm@2.0.0 @capacitor-community/firebase-analytics@1.0.0 @capacitor/app@1.0.2 @capacitor/browser@1.0.2 @capacitor/camera@1.0.3 @capacitor/device@1.0.2 @capacitor/geolocation@1.0.2 @capacitor/haptics@1.0.2 @capacitor/keyboard@1.0.2 @capacitor/push-notifications@1.0.3 @capacitor/splash-screen@1.1.0 @capacitor/status-bar@1.0.2 ⠧ update android [info] Found 5 Cordova plugins for android: cordova-background-geolocation-firebase@0.3.0 cordova-background-geolocation-lt@4.1.3 cordova-plugin-androidx-adapter@1.1.3 cordova-plugin-background-fetch@7.0.3 cordova.plugins.diagnostic@6.0.3 ✔ update android in 563.52ms

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.

stale[bot] commented 2 years ago

Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.