Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70432

Ionic 4 + Capacitor google-services.json searched under android/capacitor-cordova-android-plugins instead of android/app

$
0
0

@vitonimal wrote:

I am trying to compile a ionic 4 + capacitor app on Android.

In order to get the build working, I had to install:
cordova plugin add cordova-plugin-firebase
Since one of the plugin I am using requires firebase.

I also downloaded the google-services.json file from the Firebase Console.

I did copy the google-services.json file to android/app

However, when I try to build the app, I get the following issue:

 C:\Users\Vittorio\Documents\AccuV\AccuV\AccuV\Source\UI\AccuVFoundation\ionic4_app\AccuVMobile\android\capacitor-cordova-android-plugins\src\nullnull\google-services.json
  C:\Users\Vittorio\Documents\AccuV\AccuV\AccuV\Source\UI\AccuVFoundation\ionic4_app\AccuVMobile\android\capacitor-cordova-android-plugins\src\debug\google-services.json
  C:\Users\Vittorio\Documents\AccuV\AccuV\AccuV\Source\UI\AccuVFoundation\ionic4_app\AccuVMobile\android\capacitor-cordova-android-plugins\src\nullnullDebug\google-services.json
  C:\Users\Vittorio\Documents\AccuV\AccuV\AccuV\Source\UI\AccuVFoundation\ionic4_app\AccuVMobile\android\capacitor-cordova-android-plugins\src\nullnull\debug\google-services.json
  C:\Users\Vittorio\Documents\AccuV\AccuV\AccuV\Source\UI\AccuVFoundation\ionic4_app\AccuVMobile\android\capacitor-cordova-android-plugins\src\debug\nullnull\google-services.json
  C:\Users\Vittorio\Documents\AccuV\AccuV\AccuV\Source\UI\AccuVFoundation\ionic4_app\AccuVMobile\android\capacitor-cordova-android-plugins\google-services.json

This is weird, since the google-services.json file should be located under android/app according to the documentation.

I was wondering what was wrong with my setup…

Note: I also had an issue with the io.fabric plugin, so I had to modify my gradle files.

Here are my gradle files:
Project:

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

buildscript {
    
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.2'
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'io.fabric.tools:gradle:1.+'

        // 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()
    }
}

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

app:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    defaultConfig {
        applicationId "com.dev.accuvcappoc.app"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    maven { url 'https://maven.fabric.io/public' }
    flatDir{
        dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
    implementation project(':capacitor-android')
    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.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
        transitive = true;
    }
}

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")
}

I had to add the lines suggested in this article to fix the fabric plugin issue: https://stackoverflow.com/questions/46422782/error18-0-plugin-with-id-io-fabric-not-found

Thanks!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70432

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>