Gradle throwing API warning while trying to integrate Sentry - android

I'm trying to integrate Sentry into my app for crash monitoring. I have followed the Sentry docs step by step but now I'm getting the following warning:
WARNING: API 'variantOutput.getProcessManifest()' is obsolete and has been replaced with 'variantOutput.getProcessManifestProvider()'.
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 variantOutput.getProcessManifest(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
Affected Modules: app
It is due to the changes that I've made to my gradle files. I couldn't find anything on SO or the Sentry docs regarding warnings of this nature. It points directly to apply plugin but even that is the most recent version according to their website:
build.gradle(Module):
apply plugin: 'com.android.application'
apply plugin: 'io.sentry.android.gradle'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.ozbek.onur.memegenerator"
minSdkVersion 26
targetSdkVersion 28
versionCode 6
versionName "6.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
multiDexEnabled true
}
}
}
dependencies {
...
implementation 'io.sentry:sentry-android:1.7.16'
implementation 'org.slf4j:slf4j-nop:1.7.25'
}
build.gradle(Project):
// 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:3.4.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
buildscript {
dependencies {
classpath 'io.sentry:sentry-android-gradle-plugin:1.7.16'
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

There's an issue on GitHub regarding this warning:
And here's a comment to why it wasn't dropped yet:
OK so it looks like the new API was only added in Gradle 4.8
I need our Plugin to work for people on 4.4 still, so I think we'll have to ignore this warning for now as people are slowly forced to use a newer Gradle by Play Store requirements.
There's also a second issue where someone posted a fix on his fork. As it was pointed out there, it requires now newer version of Gradle which means it'll break people using the older ones.

Related

DSL method not found: implementation()

I tried to add the Fresco library by to my project by adding this to my app-level gradle file
implementation 'com.facebook.fresco:fresco:1.8.0'
Then I get the follwing error message:
Gradle DSL method not found: 'implementation()' Possible causes:
The project may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0). Upgrade plugin to version 3.0.1 and sync project
The project may be using a version of Gradle that does not contain the method. Open Gradle wrapper file
The build file may be missing a Gradle plugin. Apply Gradle plugin
When I run gradle --version it tells me that I am using gradle 4.5.
This is my top-level gradle file.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:3.1.0'
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "http://dl.bintray.com/populov/maven"}
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my app-level gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
defaultConfig {
applicationId "com.example.project1.3"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "state1.0"
renderscriptTargetApi 24
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// lots of other dependencies
implementation 'com.facebook.fresco:fresco:1.8.0'
}
I also have this in my gradle-wrapper.properties file.
distributionUrl= https\://services.gradle.org/distributions/gradle-4.1-all.zip
I have basically tried everything from here https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html but the problem persists.
Any help would be greatly appreciated. Thank you!
My guess is that probably one of your other dependencies is causing the issue,
I run the exact same app & project gradle files you provided in a new project and synced with no problem.
You can try the following:
1) substitute implementation 'com.facebook.fresco:fresco:1.8.0' with compile'com.facebook.fresco:fresco:1.8.0' (deprecated but it will help with the troubleshooting) and see if it will sync properly.
2) start a new project and use the same gradle file and see if the problem still exists.
If nothing works please post the complete app level gradle file to check again.

IllegalStateException:buildToolsVersion is not specified

My project is comprised of two modules, one is the application module and the other is a library module. My build processes works fine until I added two gradle plugins :
This is the root build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is a library module build.gradle:
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
resourcePrefix "looping_banner_res_"
defaultConfig {
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:support-v4:24.1.0'
}
I don't think there are something wrong with the build files, but I got a error when I run gradle clean :
Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence.
java.lang.IllegalStateException: buildToolsVersion is not specified.
at com.google.common.base.Preconditions.checkState(Preconditions.java:176)
at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.java:606)
at com.android.build.gradle.BasePlugin$10$1.call(BasePlugin.java:572)
at com.android.build.gradle.BasePlugin$10$1.call(BasePlugin.java:569)
at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:55)
at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:47)
at com.android.build.gradle.BasePlugin$10.execute(BasePlugin.java:568)
at com.android.build.gradle.BasePlugin$10.execute(BasePlugin.java:565)
* Where:
Build file '/home/lic/code/private/github/looping-banner/banner/build.gradle' line: 3
Why did this issue happen and how to solve this ?
I have searched some answer, but not work for me, are there something wrong in the two plugins which I import ?
OK, after a lot searchings about this issue, I finally worked it out.
I'm using Gradle 2.14, so I need to change
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
to
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
There are a lot of differences, and here we can see more details.
I had that error until I shorten the version code length from "2017041201" to 8 characters number:
android-versionCode="20170412"
This question is old, but I found it because I was having this problem -
For some reason I got this error from Cordova/Ionic when installing a plugin.
It was fixed when I typed the command
ionic plugin add foo
instead of (leading space)
ionic plugin add foo
i have a same issue, and the problem was that have dot in android-versionCode,
like: android-versionCode="10001.1"
You are missing mavencentral() in repository dependency. Maybe that is causing the issue
repositories {
mavenCentral()
}
I get this error coz of the ANDROID_HOME getting set to /usr/local/Caskroom/android-platform-tools/latest.
I do not know why it's getting set to the above mentioned value.
But after correcting this and setting it to /Users/<user_name>/Library/Android/sdk/, the error goes away.
This worked for me
Remove android / Add android:
cordova platform rm android
cordova platform add android

How to enable Firebase Crash Reporting - Android

I followed all the steps on the docs to use Firebase Crash Reporting in my Android app (I use Android Studio and everything is up-to-date).
I used their own code to throw an exception to see if it works:
try {
throw new NullPointerException();
} catch (NullPointerException ex) {
FirebaseCrash.logcat(Log.ERROR, TAG, "NPE caught");
FirebaseCrash.report(ex);
}
And the console gives me this log:
E/MainActivity: NPE caught
V/FirebaseCrash: Firebase Crash Reporting is disabled.
Here is one build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// Firebase - Google Services 3.0.0
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is the other build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-N'
buildToolsVersion '24.0.0-rc2'
defaultConfig {
applicationId "com.app.test"
minSdkVersion 19
targetSdkVersion 'N'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
useProguard true
}
}
}
dependencies {
compile 'com.android.support:support-v4:24.0.0-alpha1'
compile 'com.android.support:appcompat-v7:24.0.0-alpha1'
compile 'com.android.support:design:24.0.0-alpha1'
compile 'com.google.firebase:firebase-core:9.0.0'
compile 'com.google.firebase:firebase-analytics:9.0.0'
compile 'com.google.firebase:firebase-crash:9.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'com.google.firebase:firebase-config:9.0.0'
compile 'com.google.firebase:firebase-invites:9.0.0'
compile 'com.google.android.gms:play-services-appindexing:9.0.0'
}
apply plugin: 'com.google.gms.google-services'
I also use:
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
FirebaseMessaging.getInstance().subscribeToTopic("news");
Log.d(TAG, "Subscribed to news topic");
I added all dependencies that I'll need, but I'm adding one by one and testing one by one, and Notifications works, Analytics: no idea, it takes about 24 hours to update, so until it does, I don't know if is working...
So, the thing is how can I enable it?
NOTE: I have all of the dependencies added including the crash and core ones, also the plugin and the classpath
Thank you in advanced.
Please note the following:
After adding the SDK you can try using:
FirebaseCrash.report(new Exception("My first Android non-fatal error"));
Errors take up to 20 minutes to show up in the Crash Reporting console. Check back to see your report there.
(It may seem obvious but) make sure you have:INTERNET and ACCESS_NETWORK_STATE permission.
Crash reporting was not working for me too after correctly setting it up in my App. To fix this I visited my developer console, API Manager, and enabled the "Mobile Crash and Performance Reporting API". To find out exactly where you need to do this follow the steps on this page.
If you follow the steps in the link above, the logcat that has the text "E/FirebaseCrashSenderServiceImpl: Error sending crash report" gives you a URL to where you must go in the console to enable crash reporting.
The FirebaseCrash is deprecated. The FirebaseCrashlytics.getInstance() should be used instead:
FirebaseCrashlytics.getInstance().log(message)
FirebaseCrashlytics.getInstance().recordException(throwable)
Source: https://firebase.google.com/docs/crashlytics/customize-crash-reports?platform=android#add-logs
Add following code:
In Project-level build.gradle (/build.gradle):
buildscript {
dependencies {
// Add this line
classpath 'com.google.gms:google-services:3.0.0'
}
}
In App-level build.gradle (//build.gradle):
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
//Add following in In App-level build.gradle
compile 'com.google.firebase:firebase-crash:9.0.0'
Now sync your project,
Use following code in your activity to throw exception:
FirebaseCrash.report(new Exception("App Name : My first Android non-fatal error"));
check android crash reporting tutorial using firebase for complete guidance.
I had the same issue. Turns out I was missing dependency in my project gradle file. Try adding this. It should help.
buildscript {
repositories {
jcenter()
// ...
}
dependencies {
// ...
classpath 'com.google.firebase:firebase-plugins:1.0.5'
}
}
You should allow some time to show up. Even though the documentation says the errors will show up within 5 minutes, it can take up to 15-20 minutes. Also, you have to change your old modules to AndroidX by migrating it if you use native development. Finally, make sure that all the tools and plugins are added in the appropriate Gradle files.

google analytics v4 integration to my android app

I have followed everything according to document provided by google, but am facing some issues, I have added google-services.json in root directory i.e in app.
Error:
Execution failed for task ':app:processDebugGoogleServices'.
No matching client found for package name 'com.google.samples.quickstart.analytics'
am getting this error. do help am working on android studio.
Try resolving the issue by adding the following line in the dependencies of the project-level build.gradle:
classpath 'com.google.gms:google-services:1.5.0'
Now Use like this in build.gradle:
com.google.android.gms:play-services-analytics:8.4.0
And follow this instructions:
Add Analytics to Your Android App
You can also generate configuration file from there
Follow the title: Add the configuration file to your project
Hope it will helpful for you.
EDIT:
Also please check if your build.gradle contains this line then remove it:
apply plugin: 'com.google.gms.google-services'
Seriously, Google should really make GA easier for all of us!!
Here's how I manage to get it work on buildToolsVersion '23.0.3' with com.google.android.gms:play-services:8.4.0
app build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId 'com.xxx.xxx'
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName '1.0'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
res.srcDirs =
[
'src/main/res/layouts/account',
'src/main/res/layouts/drawer',
'src/main/res/layouts/ntd',
'src/main/res/layouts/main',
'src/main/res/layouts',
'src/main/res'
]
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.google.android.gms:play-services:8.4.0'
}
I actually remove this line compile 'com.google.android.gms:play-services-analytics:8.4.0' and it still works.
top-level build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.google.gms:google-services:2.0.0-alpha6'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
GAV4 is really a pain in the axx, so I would also like to remind you somethings.
google-services.json
Official GAV4 Document tells you to generate google-services.json and put it under your project/app/ folder. However, it never says anything about this message.
AnalyticsService not registered in the app manifest. Hits might not be
delivered reliably. See google short url for instructions.
And I end up find the solution here analyticsservice-not-registered-in-the-app-manifest-error
json with flavor
If you are building a complex project, you might also want to use flavor for different json files. See the flavor config here google-services-json-for-different-productflavors?lq=1
xml app tracker
Yet, you would still have a hard time using xml to configure the tracker, so I also advice you to see this thread google-analytics-v4-string-xml-configuration-name-not-recognized-ga-trackingi
google_app_id
Finally, you would still see this message
GoogleService failed to initialize, status: 10, Missing an expected
resource: 'R.string.google_app_id' for initializing Google services.
Possible causes are missing google-services.json or
com.google.gms.google-services gradle plugin.
which you could find some discussion here googleservice-failed-to-initialize
In strings.xml, I do add R.string.google_app_id which is your project id in google api console, but I think it would still work even without it. I just want to get rid of that message from the log.
Wish you all good luck!

Android Studio Gradle DSL method not found: 'android()' -- Error(17,0)

I am attempting to run my project in Android Studio but the error appears below:
I have followed many sources just to get this to run and have wound up here, but do not know what else to do.
How can I configure this project to run?
build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
android {
compileSdkVersion 19
buildToolsVersion "19.1"
}
settings.gradle:
include ':app'
local.properties:
sdk.dir=C\:\\Users\\KJA\\AppData\\Local\\Android\\sdk
gradle.propertes:
# IDE (e.g. Android Studio) users:
# Settings specified in this file will override any Gradle settings
# configured through the IDE.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
I went ahead and downloaded the project from the link you provided: http://javapapers.com/android/android-chat-bubble/
Since this is an old tutorial, you simply need to upgrade the software, gradle, the android build tools and plugin.
Make sure you have the latest Gradle and Android Studio:
https://www.gradle.org/
http://tools.android.com/tech-docs/new-build-system/version-compatibility
build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
repositories {
jcenter()
}
}
app/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName '1.0'
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.2.1'
}
Then run gradle:
gradle installDebug
In your top level build.gradle you seem to have the code
android {
compileSdkVersion 19
buildToolsVersion "19.1"
}
You can't have this code at the top level build.gradle because the android build plugin isn't loaded just yet. You can define the compile version and build tools version in the app level build.gradle.
For some unknown reason, Android Studio incorrectly adds the android()
method in the top-level build.gradle file.
Just delete the method and it works for me.
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
}
I have tried to manage this issue via below steps :
Delete android { ... } block in top level root gradle file
Look into
compileSdkVersion 22
buildToolsVersion "22.0.0"
lines of code in app/gradle file here only one of the version persent in below dropdown should be present else it would give provide option to downloaad the same.
I got this same error when I was trying to import an Eclipse NDK project into Android Studio. It turns out, for NDK support in Android Studio, you need to use a new gradle and android plugin (and gradle version 2.5+ for that matter). This plugin, requires changes in the module's build.gradle file. Specifically the "android{...}" object should be inside "model{...}" object like this:
apply plugin: 'com.android.model.application'
model {
android {
....
}
}
So if you have updated your gradle configuration to use the new gradle plugin, and the new android plugin, but didn't change the module's build.gradle syntax, you could get "Gradle DSL method not found: 'android()'" error.
I prepared a patch file here that has some further explanations in the comments:
https://gist.github.com/shumoapp/91d815de6e01f5921d1f
These are the changes I had to do after importing the native-audio ndk project into Android Studio.
Correcting gradle settings is quite difficult. If you don't know much about Gradle it requires you to learn alot. Instead you can do the following:
1) Start a new project in a new folder. Choose the same settings with your project with gradle problem but keep it simple: Choose an empty main activity.
2) Delete all the files in ...\NewProjectName\app\src\main folder
3) Copy all the files in ...\ProjectWithGradleProblem\app\src\main folder to ...\NewProjectName\app\src\main folder.
4) If you are using the Test project (\ProjectWithGradleProblem\app\src\AndroidTest) you can do the same for that too.
this method works fine if your Gradle installation is healthy. If you just installed Android studio and did not modify it, the Gradle installation should be fine.
Actually i tried many combinations nothing worked
but when i modified my application gradle file with following
buildTypes {
release {
minifyEnabled false
}
}
By removing the Line
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
it worked Normally :)) cheers
Another solution if you have installed android-studio-bundle-143.2915827-windows
and gradle2.14
You can verify in
C:\Program Files\Android\Android Studio\gradle if you have gradle-2.14.
Then you must go to
C:\Users\\AndroidStudioProjects\android_app\
And in this build.gradle you put this code:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Then, go to C:\Users\Raul\AndroidStudioProjects\android_app\Desnutricion_infantil\app
And in this build.gradle you put:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '24.0.0'
defaultConfig {
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.3.0'
}
You must check your sdk version and the buildTools.
compileSdkVersion 23
buildToolsVersion '24.0.0'
Save all changes and restart AndroidStudio and all should be fine !
Just delete these lines from the root build.gradle
android {
compileSdkVersion 19
buildToolsVersion '19.1' }
Now trying and compile again. It should work.
Change to root build.gradle file
to
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
What worked for me was to import the project with "File -> New -> Project from Version Control" then choose your online source (GitHub for example). This way all the .gradle files were created in the import.
I also meet that problems,and just delete bottom code:
DELETE THESE LINES:
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
}
it worked。
This error has occurred when i was importing a project from Github. This happens as the project was of older version. Just try to delete these methods below from your root gradle.
android {
compileSdkVersion 19
buildToolsVersion "19.1"
}
then try again.
I hope it works.

Categories

Resources