Appcompat version used in app is v7, androidx is used for integration with gradle.properties for firebase connection
Please help
You are using the wrong build.gradle file
You have to move the implementation from the top-level file to the app/build.gradle file in the dependencies block (not the dependencies in the buildscript block)::
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
//...
}
dependencies {
//...
implementation 'androidx.xxxxx'
}
Related
I will keep it simple. I am using both kotlin and java in my Android project. I can provide my gradle files if necessary.
I need the following java plugins in my project: id 'java-library'
id "org.web3j". They work on an older version of Android gradle ('com.android.tools.build:gradle:3.6.3' ; distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip) but not on the newest one ("com.android.tools.build:gradle:4.1.1" ; distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip) from which I need other functionality. When I try to add them I get the following error.
Error:The 'java' plugin has been applied, but it is not compatible with the Android plugins
Old gradle version has plugins:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android-extensions'
New gradle version has plugins:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.google.gms.google-services'
// id "org.web3j" version "4.8.1"
// id 'java-library'
}
I found others with the same problem but with no real answer. One workaround I found here is to configure them for a subproject or something, but I don't really understand how. Can somebody help? Ideally tell me what and where to put it in which gradle file and how it works (from my understanding I have only 1 project not many in my Android app).
This is the code that I found:
configure(allprojects) {
println "applying java plugin to $project"
apply plugin: 'java-library'
//...
}
You cannot add org.web3j as a plugin because it contains 'java' plugins that are not compatible with 'java' plugins of android. So, you can either add 'com.android.application' plugin or 'org.web3j'. Add web3j as a dependency -
implementation ('org.web3j:core:4.8.7'). It will work fine.
DaggerApplicationComponent is not generated in my code, I am learning Dagger for android and facing this issue. Below my project files.
https://github.com/SK010101/AdvanceAndroidTutorial
// component = DaggerApplicationComponent.builder()
// .applicationModule(new ApplicationModule(this))
// .build();
this thing not generated.
I have tried all clean and rebuild project.
Also tried Invalidate Caches/Restart.
Please help anyone))
inside dependencies block, add these lines:
api 'com.google.dagger:dagger:2.24'
api 'com.google.dagger:dagger-android:2.24'
api 'com.google.dagger:dagger-android-support:2.24'
annotationProcessor 'com.google.dagger:dagger-compiler:2.24'
kapt 'com.google.dagger:dagger-compiler:2.24'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.24'
kapt 'com.google.dagger:dagger-android-processor:2.24'
compileOnly 'javax.annotation:jsr250-api:1.0'
implementation 'javax.inject:javax.inject:1'
Inside android block of build.gradle,
kapt {
generateStubs = true
}
At the top of the build.gradle, Do this in exactly below order.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
Finally, You need to enable "Annotation processor" from File>Other Settings>Settings for New Projects>search"Annotation processor"
After this, do from Menu Build > Rebuild. Done!
My Bug solved after Build run on emulator))
Here is my project build.gradle:
buildscript {
...
dependencies {
...
classpath 'com.google.gms:google-services:3.1.0'
}
}
In one of the module's build.gradle I have this:
apply plugin: 'com.google.gms.google-services'
which results into the following error:
Could not get unknown property 'LibraryVariants' for object of type com.android.build.gradle.LibraryExtension.
Fun fact, if I set google-services version to 3.0.0, this specific error disappears, but Gradle asks me to downgrade versions of other google libraries, but I really do not want to do that.
How do I deal with these LibraryVariants?
You only set apply plugin: 'com.google.gms.google-services' in the app module, and in no other modules.
You must add one dependencies in your build.gradle(Project:project_name)
classpath 'com.google.gms:google-services:3.1.0'
And add in your build.gradle(build.gradle:Module app)
apply plugin: 'com.google.gms.google-services'
dependencies {
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
}
apply plugin: 'com.google.gms.google-services'
i am working on an android using GCM application and adding support libraries,i added the following to my gradle
i added a plugin
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
and dependencies: i added:
compile 'com.google.android.gms:play-services:8.3.0'
classpath 'com.google.gms:google-services:3.0.0'
but it brings an error
Error:(3, 0) Plugin with id 'com.google.gms.google-services' not found.
and yet i see the plugin added. how to i correct it thank you
In your project level build.gradle add like following:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
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
}
}
While your App level build.gradle should look like this:
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.google.android.gms:play-services-gcm:8.3.0"
}
apply plugin: 'com.google.gms.google-services'
Make sure to add apply plugin: 'com.google.gms.google-services' as last line in your app level gradle file.
You should only apply the com.android.application plugin.
Applying the java plugin as well will result in a build error.
Reference : http://tools.android.com/tech-docs/new-build-system/user-guide
The dependencies you have added are fine. You can remove the "apply plugin: 'com.google.gms.google-services'" entry.
I am developing an Android project. I have a plain java subproject. I would like to activate the apt process for this java subproject. My gradle file:
project(':subproject') {
apply plugin: 'java'
apply plugin: 'android-apt'
dependencies {
compile files('../app/libs/sqliteannotations-api-0.1-SNAPSHOT.jar')
apt files('../app/libs_annotations/sqliteannotations-0.1-SNAPSHOT-jar-with-dependencies.jar')
}
}
but I get this error:
The android or android-library plugin must be applied to the project
Add apply plugin: 'com.android.application' if you are working on an app.
Add apply plugin: 'com.android.library' if you are working on a library.