librashlitics does not exists in build - google-fabric

I'm trying to integrate Fabric Crashlitics with native code. I had crashes in native code but there are no any records about them in fabric. probably I have not integrated fabric correctly. I do not see libcrashlitics.so in apk.
in my gradle there are
apply plugin: 'io.fabric'
crashlytics {
enableNdk true
manifestPath 'src/main/AndroidManifest.xml'
}
I found good article but version is 2.0.0
https://paramsen.github.io/crashlytics-ndk-and-cmake/?readNext=true

Mike from Fabric here. Here's how to setup Crashlytics NDK in your app.
Add these lines to your build.gradle:
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
// The Fabric Gradle plugin uses an open ended version to react
// quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'
}
}
2) Also in your app's build.gradle apply the Fabric plugin:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
3) Add the Fabric repo:
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
4) Enable NDK as you mentioned:
crashlytics {
enableNdk true
}
5) Add Crashlytics and Crashlytics NDK AARs:
dependencies {
// Crashlytics Kit
compile 'com.crashlytics.sdk.android:crashlytics:2.9.3'
// NDK Kit
compile 'com.crashlytics.sdk.android:crashlytics-ndk:2.0.4'
}
6) In your Java code, add these imports:
import io.fabric.sdk.android.Fabric;
import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.ndk.CrashlyticsNdk;
7) Init Fabric as follows:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics(), new CrashlyticsNdk());
setContentView(R.layout.activity_sample);
}
and you're done. Don't forget to upload symbols as well:
~ username$ ./gradlew crashlyticsUploadSymbolsRelease

Related

Google Service download failure in gradle

Followed the instructions specified in firebase cloud platform. Getting this issue while running the gradle build.
Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.android.gms:google-services:4.3.3.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/gms/google-services/4.3.3/google-services-4.3.3.pom
- https://jcenter.bintray.com/com/android/gms/google-services/4.3.3/google-services-4.3.3.pom
Required by:
project :
build.gradle , with the artifact added.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.3")
classpath("com.android.gms:google-services:4.3.3")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
Any inputs to the issue will help, checked firewall and proxy issues already.
There are two build.gradle files in an Android Project. One is for app-level and another one is for your project root-level.
In order to setup Firebase correctly, You have to write like following in your root-level (project-level) Gradle file (build.gradle):
buildscript {
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
// ...
// Add the following line:
classpath 'com.google.gms:google-services:4.3.3' // Google Services plugin
}
}
allprojects {
// ...
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
// ...
}
}
In your module (app-level) Gradle file (usually app/build.gradle), apply the Google Services Gradle plugin like below snippet:
apply plugin: 'com.android.application'
// Add the following line:
apply plugin: 'com.google.gms.google-services' // Google Services plugin
android {
// ...
}
You are doing everything but in the app-level file. Try Fixing it and tell whether it worked or not.

WARNING: API 'variant.getPackageLibrary()' is obsolete and has been replaced with 'variant.getPackageLibraryProvider()'

I just upadated kotlin to 1.3.30 and I now get this error when syncing gradle:
WARNING: API 'variant.getPackageLibrary()' is obsolete and has been
replaced with 'variant.getPackageLibraryProvider()'. It will be
removed at the end of 2019. For more information, see
https://d.android.com/r/tools/task-configuration-avoidance. To
determine what is calling variant.getPackageLibrary(), use
-Pandroid.debug.obsoleteApi=true on the command line to display a stack trace. Affected Modules: hydatabase
Here is my build.gradle:
apply plugin: 'com.squareup.sqldelight'
apply plugin: 'kotlin-multiplatform'
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 19
}
lintOptions {
abortOnError false
}
}
sqldelight {
Database {
packageName = "com.company.hydatabase"
}
}
kotlin {
targets {
fromPreset(presets.jvm, 'jvm')
fromPreset(presets.android, 'android')
}
sourceSets {
commonMain.dependencies {
api 'org.jetbrains.kotlin:kotlin-stdlib-common'
}
jvmMain.dependencies {
api 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
// ICU4J: Use DecimalFormat
// Get rid of this when minSDKLevel = API 24 - Nougat (7.0)
// https://developer.android.com/guide/topics/resources/internationalization.html
api 'com.ibm.icu:icu4j:60.2'
}
androidMain.dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib'
api "com.squareup.sqldelight:android-driver:1.1.1"
}
androidMain.dependsOn jvmMain
}
}
task copyDatabase(type: Copy) {
from "${rootProject.file('hyappcommon/Databases/').path}"
into "${rootProject.file('hydatabase/src/main/assets/databases/').path}"
include '**/*.sqlite'
}
preBuild.dependsOn(copyDatabase)
// workaround for https://youtrack.jetbrains.com/issue/KT-27170
configurations {
compileClasspath
}
If you debug, it shows
REASON: The Kotlin plugin is currently calling this API. We are working to solve this.
To see this error please run
./gradlew -Pandroid.debug.obsoleteApi=true --stacktrace
As tommyboy said, the Kotlin plugin is calling this deprecated API.
If you don't want to get this warning while Kotlin is working on this, you can just use the previous version of Kotlin plugin like:
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21"
}
It's probably a bug and fixed soon
You can revert back to the previous version or add this line to gradle.properties
android.debug.obsoleteApi=true
In my project gradle file I had
buildscript {
ext.kotlin_version = '1.3.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Simple changing
ext.kotlin_version = '1.3.31' to ext.kotlin_version = '1.3.41' solved the problem
when using version 1.3.31 i had tried gradlew -Pandroid.debug.obsoleteApi=true
It mentioned
WARNING: API 'variant.getPackageLibrary()' is obsolete and has been
replaced with 'variant.getPackageLibraryProvider()'. It will be
removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
REASON: The Kotlin plugin is currently calling this API. We are working to solve this.
WARNING: Debugging obsolete API calls can take time during
configuration. It's recommended to not keep it on at all times.
Looks like it is solved in 1.3.41
It's an issue with the Kotlin plugin, as mentioned here. It'll get fixed in a later version.
After I updated Kotlin to 1.3.30, the following dependencies cause the error:
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
// ... other dependencies
}
I have reported the issue here:
https://github.com/bintray/gradle-bintray-plugin/issues/284
https://github.com/dcendents/android-maven-gradle-plugin/issues/81
By the way, you can ignore that error message.
The issue is tracked here and it is fixed.
Just use the Kotlin Gradle plugin v 1.3.40 or higher.
WARNING: API 'variant.getPackageLibrary()' is obsolete and has been replaced with 'variant.getPackageLibraryProvider()'.
It will be removed at the end of 2019.
Just updated to "v1.3.40-release-Studio3.4-1" plugin.
as you can see in https://youtrack.jetbrains.com/issue/KT-30784
I met this problem when I use kotlin plugin with library plugin. I found that if you use kotlin plugin with application plugin, it works well. But if you use kotlin plugin with library plugin, it will cause this problem. So that means:
// work well:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
// error:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
As the error diplayed that, you can use ./gradlew -Pandroid.debug.obsoleteApi=true --stacktrace to find out with module caused this problem.
Then I found that one of my module used the wrong plugin combination above. And that seems to be a bug of kotlin plugin. So finally, I upgraded the kotlin plugin, and then it worked well. Below is the kotlin plugin that I finally used:
buildscript {
ext.kotlin_version = '1.3.40'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
You can run this command in the root project
gradlew -Pandroid.debug.obsoleteApi=true
and the warning will be disappeared.

How to fix missing ReactContextBaseJavaModule symbol?

I wan't to create a custom native module for my app only - so no lib. Following the docs it gives me an error:
import com.facebook.react.bridge.ReactContextBaseJavaModule;
Cannot resolve symbol 'ReactContextBaseJavaModule'
My app's android/app/build.gradle includes this line, which is included in all react-native modules I have used so far as well.
"com.facebook.react:react-native:+" // From node_modules
My android/build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://maven.google.com' }
}
}
Below are the steps I encountered and used to solve importing all the libraries related to React Native Libraries in the Android Studio:
First when I created a brand new react native library project using react-native-create-library command, the command generated iOS and Android files.
I opened the android folder using Android Studio.
The gradle build reported some errors and fixed the gradle issue by updating some values in build.gradle and gradle-wrapper.properties.
build.gradle
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "27.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
}
repositories {
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
compile 'com.facebook.react:react-native:+'
}
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
After adding the above 2 changes, Click Sync Now or Try again. In this step if it asks to install the build version, please install.
Now Clean and Rebuild the project, On top status bar of the Android Studio:
Click Build --> Clean Project then
Click Build --> Rebuild Project
After step #5, React Native import errors should disappear and the libraries related to React Native must be imported.
Thanks.

Cannot initialize Crashlytics NDK

I got a problem in initalizing Crashlytics for Android. The Java part works correctly but i cannot make NDK part to work because crashlytics_init() return a null value;
My project/build.gradle
buildscript {
repositories {
jcenter()
google()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'io.fabric.tools:gradle:1.24.4'
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
google()
maven {
url 'https://maven.fabric.io/public'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app/build.gradle containing
compileSdkVersion 26
android {
defaultConfig {
...
minSdkVersion 19
targetSdkVersion 22
...
}
...
}
crashlytics {
enableNdk true
manifestPath 'C:\\full\\path\\to\\manifest\\AndroidManifest.xml'
}
dependencies {
implementation 'com.google.firebase:firebase-crash:11.6.0'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.crashlytics.sdk.android:crashlytics:2.7.1#aar') {
transitive = true
}
compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.6#aar') {
transitive = true;
}
compile 'com.google.firebase:firebase-core:11.6.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:support-v4:26.1.0'
compile 'org.apache.commons:commons-compress:1.12'
compile 'org.tukaani:xz:1.5'
}
main activity code
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
jniCrashlyticsInit();
...
}
and the native content of jniCrashlyticsInit()
void Java_com_my_app_MainActivity_jniCrashlyticsInit(JNIEnv *env,
jobject thiz)
{
crashlytics = crashlytics_init();
if (crashlytics == NULL)
log("CRASHLYTICS NULL");
else
log("CRASHLYTICS NON NULL");
}
As you imagine, "CRASHLYTICS NULL" is logged and it cannot initialize all the stuff.
I've put logs also inside crashlytics.h and it happens to fail on this line (returning a null value)
__crashlytics_unspecified_t* ctx = ((__crashlytics_initialize_t) sym_ini)();
Since i got no further infos, i really don't know how to proceed.
Ideas?
Some info more:
I use Android studio 3.0.0, and the NDK libraries are compiled manually with the following command
/cygdrive/c/Android/ndk-r15c/ndk-build.cmd NDK_DEBUG=0 APP_BUILD_SCRIPT=./Android.mk NDK_PROJECT_PATH=. APP_PLATFORM=android-19
**** Update November 20th ****
As suggested by Todd Burner, I switched from "compile" to "implementation" on build.gradle from
compile('com.crashlytics.sdk.android:crashlytics:2.7.1#aar') {
transitive = true
}
compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.6#aar') {
transitive = true;
}
to
implementation('com.crashlytics.sdk.android:crashlytics:2.7.1#aar') {
transitive = true
}
implementation('com.crashlytics.sdk.android:crashlytics-ndk:1.1.6#aar') {
transitive = true;
}
then i ran
./gradlew assemble --refresh-dependencies
Unfortunally, crashlytics_init() still returns NULL
I struggled days with this same issue. In my case I would blame partly the not-so-very-thorough documentation in the Fabric website and partly the lack of my reading comprehension.
I cannot be sure if you experience just the same thing, but my problem was that I tried to load Crashlytics NDK twice.
If you do the initialization from java like this:
Fabric.with(this, new Crashlytics(), new CrashlyticsNdk());
the native Crashlytics is automatically loaded and you don't need to initialize Crashlytics from C++. If you step into the decompiled Crashlytics .class files starting from CrashlyticsNdk.class you can see that JniNativeApi.class already calls System.loadLibrary("crashlytics").
In fact, if you still try to initialize Crashlytics from native side after that, the line
__crashlytics_unspecified_t* ctx = ((__crashlytics_initialize_t) sym_ini)();
will return NULL because the library has been already loaded.
What confused me is that the Official Fabric documentation doesn't say with bright red flashing letters that if you call new CrashlyticsNdk() from Java, you shouldn't try to load native Crashlytics from C++. To be fair, the documentation does say the following: In the process of initialization via Fabric.with(), the NDK Kit uses System.loadLibrary to load libcrashlytics. But it's a single line right before the Native API explanation starts and is easily overlooked.

Gradle DSL method not found: 'compileOnly()'

I'm trying to add new module to my application. I successfully added movie-api module (you can see in picture below), but when I try to add another module (client-app), I'm getting error as shown in picture.
I tried with different solutions including Gradle DSL method not found: 'compile()', but didn't work for me.
Appreciate your help!
Build.gradle file:
buildscript {
ext {
springBootVersion = '1.4.3.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'client-app'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter')
compileOnly('org.projectlombok:lombok')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
compileOnly was introduced in Gradle 2.12. Make sure you are using a new enough version, with both the command-line and the IDE.