Open giordy opened 7 years ago
I've had this issue too. I think it might be related to https://github.com/sarriaroman/FabricPlugin/pull/80. I haven't had a chance to verify it yet but I think this is a potential fix for the problem https://github.com/sarriaroman/FabricPlugin/pull/87.
The other work around that I was using was to uninstall and reinstall the plugin after the npm install
which helped temporarily fix the problem for me (although not the root cause).
@davidquon I see, thanks for the prompt feedback!
You will need to re-install the plugin. Latest version has the new Fabric plugin instead of Crashlytics.
@sarriaroman - I uninstalled and re-installed the plugin. I can see updated code in the gradle file but still getting same error.
@davidquon @giordy - Any luck with this, what i also observed is, release build has issues debug works fine .
This happens using Phonegap Build. Packaging locally on Cordova builds properly.
PGB currently is not supporting hooks:
<hook type="after_plugin_add" src="hooks/after_plugin_add.js" />
<hook type="before_plugin_rm" src="hooks/before_plugin_rm.js" />
any way to get rid of them somehow and keep the project working?
@sarriaroman I should mention that the first version I had ever installed in the project was the latest, 1.1.7
Sorry guys, sometimes I take vacations :). Honestly I don't have recent experience with Phonegap build but must be some kind of replacement for the hooks because are required and the problem is there.
I am also having this problem but also in development mode.
I think this has something to do with the "src/android/build-extras.gradle" file.
In the main build.gradle, if I add the steps that Fabric modifies automatically from the Android Studio Fabric Tool and comment out: apply from: "cordova-fabric-plugin/myproject-build-extras.gradle"
it works.
Can anyone else confirm this fixes it for them also?
@RobertYoung I was having the same issue and your fix worked for me. Does anyone have a more permanent solution?
Any updates on this issue ?
Unfortunately not, however I have hacked it and so it is automated for the time being. I've added a cordova hook to amend the android files after the platform has been added.
/hooks/after_platform_add/010_install_fabric_android.js
#!/usr/bin/env node
console.log("> 010_install_fabric_android.js");
const fs = require('fs');
const gradleBundlePath = `./platforms/android/build.gradle`;
const gradleBundleEncoding = `utf8`;
const mainActivityPath = `./platforms/android/src/com/iamrobertyoung/settimes/MainActivity.java`;
const mainActivityEncoding = `utf8`;
function installFabricForAndroid() {
if (!fs.existsSync(gradleBundlePath) || !fs.existsSync(mainActivityPath)) {
console.warn(`Cannot find android related files`);
return;
};
replaceGradleBundle();
replaceMainActivity();
}
function replaceGradleBundle() {
var gradleBundle = readGradleBundle();
var newGradleBundle = gradleBundle.replace(`apply plugin: 'com.android.application'`, `
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
`)
.replace(`repositories {
mavenCentral()
jcenter()
}`,
`repositories {
mavenCentral()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}`)
.replace(`dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}`,
`dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'io.fabric.tools:gradle:1.+'
}`)
writeGradleBundle(newGradleBundle);
}
function replaceMainActivity() {
var mainActivity = readMainActivity();
var newMainActivity = mainActivity.replace(`import android.os.Bundle;`,
`import android.os.Bundle;
import com.crashlytics.android.Crashlytics;
import io.fabric.sdk.android.Fabric;`)
.replace(`super.onCreate(savedInstanceState);`,
`super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());`);
writeMainActivity(newMainActivity);
}
function readGradleBundle() {
return fs.readFileSync(gradleBundlePath, gradleBundleEncoding);
}
function writeGradleBundle(bundle) {
return fs.writeFileSync(gradleBundlePath, bundle);
}
function readMainActivity() {
return fs.readFileSync(mainActivityPath, mainActivityEncoding);
}
function writeMainActivity(mainActivity) {
return fs.writeFileSync(mainActivityPath, mainActivity);
}
installFabricForAndroid();
Yes this is dirty, and will most likely break, but it's a workaround.
Just ran through this, was able to resolve by adding the assorted hook files then:
ionic cordova plugin rm cordova-fabric-plugin --save
ionic cordova platform rm android
ionic cordova platform rm ios
# Edited config.xml to add hooks:
# <hook src="hooks/after_plugin_add.js" type="after_plugin_add" />
# <hook src="hooks/before_plugin_rm.js" type="before_plugin_rm" />
ionic cordova platform add android
ionic cordova platform add ios
ionic cordova plugin add https://github.com/sarriaroman/FabricPlugin --variable FABRIC_API_KEY=XXX --variable FABRIC_API_SECRET=xxx --save
Somewhere in the middle of testing this sequence for reliability, I discovered that Android Studio couldn't find a bunch of Java classes on the Crashlytics framework - seems like maybe there was outdated code. This is what prompted me to remove the original cordova-fabric-plugin
and reinstall from Github source (master branch).
I am now able to perform all builds by CLI:
ionic cordova build android
ionic cordova build android --release
ionic cordova build ios
ionic cordova build ios --release
... as well as build the project cleanly from XCode and Android Studio.
@emcniece You rock! I have tried re-installing the plugin directly from GH but it didn't help. I think the hooks are key.
@nmartin867 good to hear! Beware though, as noted by https://github.com/sarriaroman/FabricPlugin/issues/88#issuecomment-286214951 it looks like Phonegap doesn't run these hooks.
But if you're not using Phonegap... ¯\_(ツ)_/¯
I'm using https://fastlane.tools/ - builds happen locally.
solved using version 1.1.6
ionic cordova plugin add https://github.com/sarriaroman/FabricPlugin#1.1.6 --variable FABRIC_API_KEY=XXX --variable FABRIC_API_SECRET=xxx --save
Does it still not working on Phonegap build?... Looks like i have the same issue, as in the top of this topic..
I have the same issue with version 1.1.7
@pph7 do you see your Fabric API key/secret in config.xml
?
<plugin name="cordova-fabric-plugin" spec="^1.1.9">
<variable name="FABRIC_API_KEY" value="xxxxxxxxxxxxxxxxxxxx" />
<variable name="FABRIC_API_SECRET" value=""xxxxxxxxxxxxxxxxxxxx" />
</plugin>
Yes, exactly like that.
any update on this issue.
Hello,
first of all thanks for your work :) I integrated your plugin and it worked well in the debug phase while testing the app in the emulator and the phone. The problem arised after I created the release apk and installed on the phone for testing. Then I got this exception:
The other plugins I'm using are:
Any idea why this might be happening?
Thanks in advance