Updating OneSignal dependency getting Dependency failing error - android

I am getting this Error while updating one signal Dependency.
how can I rectify this??
Dependency failing: com.onesignal:OneSignal:3.12.6 -> com.google.android.gms:play-services-base#[10.2.1, 16.1.99], but play-services-base version was 17.1.0.

In your app/build.gradle where you applied the plugin
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
make sure its is before
apply plugin: "com.android.application"
Android studio also gives a warning if the order of the above statements is not correct.

I was missed out updating the classpath in dependencies
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]
}

Related

FirebaseApp not initialized error on changing classpath 'com.google.gms:google-services:4.3.8' to 4.3.9 in build gradle

I updated my Android project to 7.0.2 and this changed the
classpath 'com.google.gms:google-services:4.3.8' to
classpath 'com.google.gms:google-services:4.3.9'.
After the update I started getting an error that FirebaseApp is not initialized or build Gradle does not include gms: google services.
I tried to add
FirebaseApp.initializeApp(mycontext);
method also in my Firebase token Async Task where the error is triggering, but this does not help.
Can someone suggest how to fix it?
In your app-level Gradle file add the 'apply plugin' line at the bottom of the file to enable the Gradle plugin:
apply plugin: 'com.android.application'
dependencies {
// ...
implementation 'com.google.firebase:firebase-bom'
// If getting a "Could not find" error? Make sure you have the latest Google
// Repository in the Android SDK manager
}
//ADD THIS LINE AT BOTTOM
apply plugin: 'com.google.gms.google-services'
or you can add plugin like this:
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
Now, sync both the gradle files

Running AspectJ and Firebase Performance Monitoring in Gradle builds

Problem statement
I want to use AspectJ in an Android build with Gradle whilst instrumenting the built app with Firebase Performance Monitoring.
Unfortunately the build fails in the DEX merge step with Type android.support.v4.app.INotificationSideChannel$Default is defined multiple times: ...
Findings
In app/build/ajc-transform.log I found:
Wed Jul 22 07:55:14 CEST 2020
ABORT
Exception thrown from AspectJ 1.9.4
This might be logged as a bug already -- find current bugs at
http://bugs.eclipse.org/bugs/buglist.cgi?product=AspectJ&component=Compiler
Bugs for exceptions thrown have titles File:line from the top stack,
e.g., "SomeFile.java:243"
If you don't find the exception below in a bug, please add a new bug
at http://bugs.eclipse.org/bugs/enter_bug.cgi?product=AspectJ
To make the bug a priority, please include a test program
that can reproduce this exception.
Expecting .,<, or ;, but found firebaseperf while unpacking <MessageType:Lcom/google/android/gms/internal/firebase-perf/zzdz<TMessageType;TBuilderType;>;BuilderType:Lcom/google/android/gms/internal/firebase-perf/zzdy<TMessageType;TBuilderType;>;>Ljava/lang/Object;Lcom/google/android/gms/internal/firebase-perf/zzgr;
In the project root there is a ajcore.log:
java.lang.IllegalStateException: Expecting .,<, or ;, but found firebaseperf while unpacking <MessageType:Lcom/google/android/gms/internal/firebase-perf/zzdz<TMessageType;TBuilderType;>;BuilderType:Lcom/google/android/gms/internal/firebase-perf/zzdy<TMessageType;TBuilderType;>;>Ljava/lang/Object;Lcom/google/android/gms/internal/firebase-perf/zzgr;
at org.aspectj.util.GenericSignatureParser.parseClassTypeSignature(GenericSignatureParser.java:204)
at org.aspectj.util.GenericSignatureParser.parseFieldTypeSignature(GenericSignatureParser.java:155)
at org.aspectj.util.GenericSignatureParser.parseFormalTypeParameter(GenericSignatureParser.java:130)
at org.aspectj.util.GenericSignatureParser.parseAsClassSignature(GenericSignatureParser.java:51)
at org.aspectj.weaver.UnresolvedType.forGenericTypeSignature(UnresolvedType.java:275)
at org.aspectj.weaver.bcel.BcelWorld.addSourceObjectType(BcelWorld.java:479)
at org.aspectj.weaver.bcel.BcelWorld.addSourceObjectType(BcelWorld.java:453)
at org.aspectj.weaver.bcel.BcelWeaver.addClassFile(BcelWeaver.java:456)
at org.aspectj.weaver.bcel.BcelWeaver.addClassFile(BcelWeaver.java:480)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.initBcelWorld(AjBuildManager.java:908)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:253)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:189)
at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:114)
at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60)
at org.aspectj.tools.ajc.Main.run(Main.java:371)
at com.archinamon.api.AspectJWeaver$doWeave$2.invoke(AspectJWeaver.kt:128)
at com.archinamon.api.AspectJWeaver$doWeave$2.invoke(AspectJWeaver.kt:14)
at com.archinamon.api.AspectJWeaver$Companion.runBlocking(AspectJWeaver.kt:182)
at com.archinamon.api.AspectJWeaver.doWeave$android_gradle_aspectj(AspectJWeaver.kt:126)
at com.archinamon.api.transform.AspectJTransform.transform(AspectJTransform.kt:182)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:284)
[...]
Used Gradle configuration
Here's a reduced version of my build.gradle files:
project level:
buildscript {
[...]
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
[...]
classpath "com.archinamon:android-gradle-aspectj:4.2.1"
classpath "com.google.gms:google-services:4.3.3"
classpath "com.google.firebase:firebase-crashlytics-gradle:2.2.0"
classpath "com.google.firebase:perf-plugin:1.3.1"
}
}
[...]
app level:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.firebase.firebase-perf'
[...]
apply plugin: 'com.archinamon.aspectj'
[...]
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
[...]
implementation "com.google.firebase:firebase-analytics:17.4.4"
implementation "com.google.firebase:firebase-analytics-ktx:17.4.4"
implementation ("com.google.firebase:firebase-crashlytics:17.1.1"
implementation ("com.google.firebase:firebase-perf:19.0.7"
[...]
}
Investigation
Firebase-perf conflicting with let plugin
https://github.com/firebase/quickstart-android/issues/770
I've tried the approaches mentioned there, but they did not solve my problem.
I found out that the order of the plugins matters. Applying the AspectJ plugin before the Firebase plugins in the app level build.gradle solved my issue:
apply plugin: 'com.android.application'
apply plugin: 'com.archinamon.aspectj'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.firebase.firebase-perf'
[...]

Expected #AndroidEntryPoint to have a value. Did you forget to apply the Gradle Plugin?

When I am using Hilt in android with Room I got this kinda error.
The full log is here:
home/someone/Desktop/Calculator/app/build/tmp/kapt3/stubs/debug/com/hamidjonhamidov/calculator/MyApplication.java:7: error: [Hilt]
public class MyApplication extends android.app.Application {
^
Expected #HiltAndroidApp to have a value. Did you forget to apply the Gradle Plugin?
[Hilt] Processing did not complete. See error above for details./home/someone/Desktop/Calculator/app/build/tmp/kapt3/stubs/debug/com/hamidjonhamidov/calculator/ui/main/MainActivity.java:7: error: [Hilt]
Anyone knows solution for this?
I had this issue after upgrading Kotlin to 1.5.20.
Adding kapt.use.worker.api=false in gradle.properties worked for me the problem
Checkout dagger issue Support for Kotlin 1.5.20
Fortunately, there is simple solution.
In build.gradle in database scheme, we should use arguments += instead of arguments = .
defaultConfig{
javaCompileOptions {
annotationProcessorOptions {
arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
Or/And in buld.gradle
You should apply plugin like:
apply plugin 'dagger.hilt.android.plugin'
This solved the problem)
UPDATE
Upgrade Hilt to v28.1.0 and Kotlin to v1.5.21 should fix this issue
OLD ANSWER
If you are on kotlin 1.5.20, answer of Mr-wil will decrease build speed as said in official doc:
To improve the speed of builds that use kapt, you can enable the
Gradle worker API for kapt tasks. Using the worker API lets Gradle run
independent annotation processing tasks from a single project in
parallel, which in some cases significantly decreases the execution
time.
Instead, set:
kapt {
javacOptions {
// These options are normally set automatically via the Hilt Gradle plugin, but we
// set them manually to workaround a bug in the Kotlin 1.5.20
option("-Adagger.fastInit=ENABLED")
option("-Adagger.hilt.android.internal.disableAndroidSuperclassValidation=true")
}
}
source
This generic error message can also appear in many circumstances. As a more generic check, ensure that your module's build.gradle file, ensure that you has:
apply plugin: 'dagger.hilt.android.plugin'
at the top.
This was due to a bug in Kotlin 1.5.20. It is fixed in Kotlin 1.5.21.
So all you need to do is to upgrade to the latest version of Kotlin.
I had the same problem and it seems like there is a problem in kotlin-kapt plugin. If you guys have tried out all the above answers and didn't get resolved, please try the below code in your build.gradle(module-level) outside the dependencies{} block
kapt {
javacOptions {
option("-Adagger.hilt.android.internal.disableAndroidSuperclassValidation=true")
}
}
in the build.gradle of your Android Gradle modules apply the plugin:
apply plugin: 'com.android.application'
apply plugin: 'dagger.hilt.android.plugin'
android {
// ...
}
see detail here
I'm still facing the same issue in 2022
I have solved the problem by adding
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.38.1'
to build.gradle project and adding
id 'dagger.hilt.android.plugin'
to plugins in build.gradle app
In my case it solved by declaring plugin:
plugins {
id("dagger.hilt.android.plugin")
}
Check if all these are added.In my case I had missed adding one of the below line.
In project level build.gradle
buildscript {
dependencies {
classpath "com.google.dagger:hilt-android-gradle-plugin:2.44"
}
}
In app level build.gradle
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}
dependencies {
implementation "com.google.dagger:hilt-android:2.44"
implementation "androidx.hilt:hilt-common:1.0.0"
kapt "com.google.dagger:hilt-android-compiler:2.44"
}
-In app level build.gradle---add the following in newer versions
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}
In project level build.gradle
buildscript {
ext.kotlin_version = "1.7.21"
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.42'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

Kotlin-allopen for android

Is it possible to use kotlin-allopen gradle plugin for android testing with mockito?
I've tried to add kotlin-allopen plugin to my build.gradle and define the annotation.
buildscript {
ext.kotlin_version = '1.0.6'
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-allopen'
apply plugin: 'kotlin-android'
allOpen {
annotation("com.mycompany.OpenForTest")
}
And these for annotation itself
annotation class OpenForTest
It's not working for me. Maybe I miss something?
Yes you can.
Because it's a compiler plugin, you'll get all-open code after compilation.
So it should work with tests.
Don't worry.
Edit: according to the comment area, updating the kotlin plugin version seems work. Currently the newest version is 1.2.41.
First add the dependency in your build.gradle (project) file:
dependencies {
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
}
After that apply the plugin in your build.gradle (app mobdule) file:
apply plugin: 'kotlin-allopen'
Then specify the list of annotations that will make classes open:
allOpen {
annotation('com.example.myproject.OpenForTesting')
}
And use this annotation for every class which you want to be open
#OpenForTesting
Here is the Kotlin official documentation about All-open: https://kotlinlang.org/docs/reference/compiler-plugins.html
Hope this help

issue with gradle 2.0.0 and DataBinding

Recently i have updated Android studio from 1.5.1 to 2.0, after updation it asked me to use latest gradle i.e. com.android.tools.build:gradle:2.0.0
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath "com.android.databinding:dataBinder:1.0-rc1"
}
But after updating it is showing error with DataBinding plugin.
apply plugin: 'com.android.databinding' //error on this line
Error message :
Error:(2, 0) Cause: org/apache/commons/lang3/StringUtils
Open File
I have not used any apache library or any deprected apache classes.
UPDATE :
Harshad's answer helped me, so final conclusion is we don't need to add those plugins with gradle 2.0.+
classpath "com.android.databinding:dataBinder:1.0-rc1" remove
apply plugin: 'com.android.databinding' remove
This may be help you.
You can just remove these two lines of code:
apply plugin: 'com.android.databinding'
And this one in buildscript's dependencies:
classpath 'com.android.databinding:dataBinder:1.0-rc1'
Then add the dataBinding section to your build.gradle like this.
buildscript {
...
}
android {
...
dataBinding {
enabled = true
}
...
}
dependencies {
...
}

Categories

Resources