I have a problem with testing a Room database:
when I run the test, I get this exception:
java.lang.RuntimeException: cannot find implementation for database.TicketDatabase. TicketDatabase_Impl does not exist
at android.arch.persistence.room.Room.getGeneratedImplementation(Room.java:92)
at android.arch.persistence.room.RoomDatabase$Builder.build(RoomDatabase.java:454)
at com.sw.ing.gestionescontrini.DatabaseTest.setDatabase(DatabaseTest.java:36)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:59)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:262)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1886)
Class DatabaseTest:
public class DatabaseTest {
TicketDatabase database;
DAO ticketDAO;
#Before
public void setDatabase() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Context context = InstrumentationRegistry.getTargetContext();
database = Room.inMemoryDatabaseBuilder(context, TicketDatabase.class).build();
Method method = TicketDatabase.class.getDeclaredMethod("ticketDao()");
method.setAccessible(true);
ticketDAO = (DAO) method.invoke(database, null);
}
}
gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.sw.ing.gestionescontrini"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
defaultConfig {
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
annotationProcessor 'android.arch.lifecycle:compiler:1.0.0'
compile 'android.arch.persistence.room:rxjava2:1.0.0-rc1'
testCompile'android.arch.persistence.room:testing:1.0.0-rc1'
}
I don't really know what this implementation should be, I searched for a solution but all I found doesn't work for me. For instance, many found a solution adding kapt "android.arch.persistence.room..." but gradle doesn't recognize "kapt".
kapt is for Kotlin.
First, add:
annotationProcessor "android.arch.persistence.room:compiler:1.0.0"
to your dependencies closure.
Then, upgrade android.arch.persistence.room:rxjava2 and android.arch.persistence.room:testing to 1.0.0 instead of 1.0.0-rc1.
ref: https://developer.android.com/jetpack/androidx/releases/room
for Kotlin change the 'annotationProcessor' keyword to 'kapt' in gradle file.
kapt "android.arch.persistence.room:compiler:1.1.1"
and also add on top of the dependency file
apply plugin: 'kotlin-kapt'
ref: https://developer.android.com/jetpack/androidx/releases/room
java.lang.RuntimeException: cannot find implementation for
com.example.kermovie.data.repository.local.MoviesDatabase.
MoviesDatabase_Impl does not exist
You have to add the following code to your build.gradle:
apply plugin: 'kotlin-kapt'
dependencies {
def room_version = '2.3.0'
implementation 'androidx.room:room-runtime:$room_version'
implementation "androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-compiler:$room_version"
}
You may have to change room_version variable when a newer version is available.
You can check for a newer version on the following web mvnrepository.com
If You Use Kotlin sure exists this code in your in grade file.
apply plugin: "kotlin-kapt"
// Room
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
Documentation: https://developer.android.com/jetpack/androidx/releases/room
I see some people around here (Vishu Bhardwaj and others on similar StackOverflow questions) complains the accepted answer does not work for them. I think it deserve mentioning I had a similar problem in a MULTI modules project that needed a trick around the accepted answer.
In my multi modules project the room database dependencies where included mostly in one basic module and exported using proper api notation but room code was split along 2 different modules. Project compiled with no warning but java.lang.RuntimeException: cannot find implementation for database... was raised on run-time.
This was fixed by adding
annotationProcessor "android.arch.persistence.room:compiler:$room_version"
in ALL modules that included Room related code.
Add this in your app module's buld.gradle file
//The Room persistence library provides an abstraction layer over SQLite
def room_version = "2.3.0"
implementation("androidx.room:room-runtime:$room_version")
annotationProcessor "androidx.room:room-compiler:$room_version"
In your data access object file add the follwoing annotation
#Database(entities = [EntityClassName::class], version = 1)
Replace entity class name and database version code as per your project need.
If you are using kotlin, apply kapt plugin to the annotation processor as following line:
apply plugin: 'kotlin-kapt'
Then Replace annotationProcessor "androidx.room:room-compiler:$room_version" with the following line:
kapt "androidx.room:room-compiler:$room_version"
This gradle works nicely. Notice the plugin kotlin-kapt at the beggining. It's crucial.
apply plugin: 'kotlin-kapt'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "????"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'android.arch.persistence.room:runtime:1.1.1'
kapt 'android.arch.persistence.room:compiler:1.1.1'
}
I did as everybody said in above answer still no luck.
The issue on my end was that, I was doing insertion on main thread.
roomDatabase = Room.databaseBuilder(DexApplication.getInstance(),MyRoomDatabase.class,"db_name")
.fallbackToDestructiveMigration() // this is only for testing,
//migration will be added for release
.allowMainThreadQueries() // this solved the issue but remember that its For testing purpose only
.build();
Explanation:
.allowMainThreadQueries()
allows you run queries on the main thread. But keep in mind to remove it and implement, RxJava, Live Data or any other background process mechanism for querying database.
Hope that would help.
Add below plugin and dependency
apply plugin: 'kotlin-kapt'
kapt "android.arch.persistence.room:compiler:1.1.1"
I will add complete answer that solved my problem
First add all the room dependency of android x
second add apply plugin: 'kotlin-kapt' and replace annotationProcessor of room compiler with kept
I'm coming a little bit late but I had the same issue but none of the answers helped me. So I hope my experience will help others.
Room couldn't find the implementation while executing my instrumentation tests so adding below line to my gradle file fixed the problem
kaptAndroidTest "androidx.room:room-compiler:$room_version"
If you use annotation processors for your androidTest or test sources, the respective kapt configurations are named kaptAndroidTest and kaptTest
In my case, adding the following annotation above the database class solves the problem.
#Database(entities = {Entities.class}, version = 1, exportSchema = false)
public abstract class TheDatabase extends RoomDatabase {...}
Thanks to #nicklocicero.
I had the same problem. This happens when you forget to add the compiler dependency.
Add these dependencies
def room = "2.3.0"
implementation "androidx.room:room-runtime:$room"
implementation "androidx.room:room-ktx:$room"
kapt "androidx.room:room-compiler:$room"
it means your room runtime dependency is missing .. please add below dependency in your build.gradle(module) file. This will resolve your issue :)
dependencies{
def room_version = "2.2.6"
implementation "androidx.room:room-ktx:$room_version"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
}
In my case, I was doing a complete rewrite alongside old code and put the new code in a temporary package called new without thinking it might conflict with the Java keyword. Evidently the Room compiler just ignores packages with that name without giving warnings. Android Studio doesn't warn when creating a new package, but it does say "not a valid package name" when entered in the rename dialog even though it still allows renaming to that. I renamed the package to redesign and no longer had the issue.
add this
#Database(entities = [Entity::class], version = 1) to your db class
Related
I have been having for a long time this problem: I cannot upgraded the gradle version and kotlin gradle plugin in my app in Android Studio, the only solution that I can think of is to start a project from scratch and move one by one every class.
My app uses Room and therefore kapt as annotation process. With this version of kotlin and gradle everything works perfectly:
classpath 'com.android.tools.build:gradle:4.0.2'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50'
my app gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
//Kapt is the annotation processor of kotlin, all the generated code Ex. #Room depends of it
apply plugin: 'kotlin-kapt'
kapt {
generateStubs = true
correctErrorTypes = true
mapDiagnosticLocations = true
javacOptions {
// Increase the max count of errors from annotation processors.
// Default is 100.
option("-Xmaxerrs", 700)
}
}
android {
signingConfigs {
Default {
...
}
}
compileSdkVersion 29
defaultConfig {
applicationId "com.android.expenses"
minSdkVersion 24
targetSdkVersion 29
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.Default
javaCompileOptions {
annotationProcessorOptions {
arguments += ["room.schemaLocation":
"$projectDir/schemas".toString()]
}
}
}
sourceSets {
// Adds exported schema location as test app assets.
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
}
buildTypes {
debug {
....
}
release {
....
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
//To avoid duplicate class clash
exclude group: 'com.google.guava', module: 'listenablefuture'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
//Para parcelize y autobinding in kotlin
androidExtensions {
experimental = true
}
kotlinOptions {
jvmTarget = '1.8'
}
//De databinding, y kotlinx
/*dataBinding {
enabled = true
}*/
//Substitule to 3 line above with this
android.buildFeatures.dataBinding true
}
dependencies {
//version definition
def room_version = "2.2.5"
implementation fileTree(include: ['*.jar'], dir: 'libs')
//androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
// exclude group: 'com.android.support', module: 'support-annotations'
//})
testImplementation 'junit:junit:4.12'
// Required for instrumented tests
androidTestImplementation 'com.android.support:support-annotations:28.0.0'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
//Architecture
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.core:core:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'joda-time:joda-time:2.7'
implementation 'org.joda:joda-money:0.10.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.neovisionaries:nv-i18n:1.15'
implementation 'de.hdodenhof:circleimageview:2.2.0'
//ColorPicker
implementation 'com.jaredrummler:colorpicker:1.1.0'
//Image Cropper
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
// Google Sheet API y Google Drive
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'pub.devrel:easypermissions:3.0.0'
implementation('com.google.api-client:google-api-client-android:1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
// Google Sheet API
implementation('com.google.apis:google-api-services-sheets:v4-rev504-1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
// Google Drive Rest
implementation('com.google.apis:google-api-services-drive:v3-rev102-1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
//Google Drive Android
implementation "com.google.android.gms:play-services-drive:$rootProject.playServices_version"
//Google Maps
implementation "com.google.android.gms:play-services-location:$rootProject.playServices_version"
implementation 'com.google.android.gms:play-services-maps:16.1.0'
//Google Maps Utils
implementation 'com.google.maps.android:android-maps-utils:0.5'
//Google Places
implementation "com.google.android.gms:play-services-places:$rootProject.playServices_version"
//MultiViewAdapter para mejores recyclerviews
implementation 'com.github.devahamed:multi-view-adapter:1.2.6'
implementation 'com.github.devahamed:multi-view-adapter-databinding:1.2.6'
//CardView
implementation 'androidx.cardview:cardview:1.0.0'
//PagerSlidingTabStrip
implementation 'com.jpardogo.materialtabstrip:library:1.1.1'
//Room
implementation "androidx.room:room-runtime:$room_version"
//annotationProcessor "androidx.room:room-compiler:$room_version"
// optional - Kotlin Extensions and Coroutines support for Room
//implementation "androidx.room:room-ktx:$room_version"
// Test helpers
androidTestImplementation "androidx.room:room-testing:$room_version"
kapt "androidx.room:room-compiler:$room_version"
// Lifecycle components
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
annotationProcessor 'androidx.lifecycle:lifecycle-compiler:2.3.1'
kapt 'androidx.lifecycle:lifecycle-compiler:2.3.1'
//Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// Coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9")
// RxJava support for Room
implementation 'androidx.room:room-rxjava2:2.0.0'
//Android Palette API
implementation 'androidx.palette:palette:1.0.0'
//Welcome Activity
implementation 'com.github.AppIntro:AppIntro:6.1.0'
//Charts
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
//TableView
implementation 'com.evrencoskun.library:tableview:0.8.8'
//Anko Commons Library for easier development
implementation "org.jetbrains.anko:anko-commons:$anko_version"
//Search Dialog
implementation 'com.github.mirrajabi:search-dialog:1.2.4'
//FAB Button Speed Dial
implementation 'com.leinardi.android:speed-dial:3.2.0'
//WorkManager
implementation('androidx.work:work-runtime-ktx:2.0.1') {
exclude group: 'com.google.guava', module: 'listenablefuture'
}
//PagingList
implementation 'androidx.paging:paging-runtime:2.1.0'
//Calendar
implementation 'com.github.prolificinteractive:material-calendarview:2.0.1'
//Image Compressing
implementation 'id.zelory:compressor:3.0.1'
//New Places: Old one is deprecated
implementation 'com.google.android.libraries.places:places:2.4.0'
// Koin for Android
implementation 'org.koin:koin-android:2.0.0-rc-2'
implementation 'org.koin:koin-android-viewmodel:2.0.0-rc-2'
// KTX
implementation 'androidx.core:core-ktx:1.3.2'
// Rx
implementation 'io.reactivex.rxjava2:rxjava:2.2.4'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
// Moshi
implementation 'com.squareup.moshi:moshi:1.8.0'
kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.8.0'
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.retrofit2:converter-moshi:2.5.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.14.1'
// Picasso
implementation 'com.squareup.picasso:picasso:2.71828'
//SQLCipher
implementation "net.zetetic:android-database-sqlcipher:4.4.0#aar"
....
}
repositories {
mavenCentral()
}
// For Firebase
apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin
I tried to update to the current newest version of each, although this problem exists in not so new versions
classpath 'com.android.tools.build:gradle:7.0.2'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20'
In order to make this change I did the following:
Update Java jdk to 11
Replace kotlin-android-extensions with 'kotlin-parcelize' and viewBinding = true
Remove androidExtensions: experimental=true
Replace the parcelize import with kotlinx.parcelize.Parcelize
Even all this, I still have this error
Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction
> java.lang.reflect.InvocationTargetException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
There are messages below app:kaptDebugKotlin but they are warnings of multiple constructors of non #Entity classes which shouldn't provoke the crash
This is really frustrating cause I don't know what else to do or how to get more information (I also did a run with --info and I only get the same output from kapt)
Thank you in advance for your time and help
UPDATE
Here is my top gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
//ext.kotlin_version = '1.4.10'
//Working version
ext.kotlin_version = '1.3.50'
//Latest version
//ext.kotlin_version = '1.5.20'
//ext.kotlin_version = '1.3.41'
repositories {
mavenCentral()
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
//jcenter()
}
dependencies {
// working version, if change modify distributionUrl in gradle-wrapper.properties
classpath 'com.android.tools.build:gradle:4.0.2'
// to upgrade
//classpath 'com.android.tools.build:gradle:7.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
//De MaterialChipsInput y Search Dialog
maven {
url "https://jitpack.io"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext{
archLifecycleVersion = '1.1.1'
anko_version='0.10.5'
support_version = '28.0.0'
playServices_version = '16.0.0'
}
Quick update, when I try to upgrade only the room version to 2.3.0 the error occurs:
[kapt] An exception occurred: java.lang.NoSuchMethodError: kotlin.jvm.internal.FunctionReferenceImpl.<init>(ILjava/lang/Object;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
at androidx.room.log.RLog$CollectingMessager$writeTo$printMessage$1.<init>(RLog.kt)
at androidx.room.log.RLog$CollectingMessager.writeTo(RLog.kt:92)
at androidx.room.solver.TypeAdapterStore.findRowAdapter(TypeAdapterStore.kt:520)
at androidx.room.solver.TypeAdapterStore.findQueryResultAdapter(TypeAdapterStore.kt:459)
at androidx.room.solver.binderprovider.InstantQueryResultBinderProvider.provide(InstantQueryResultBinderProvider.kt:29)
at androidx.room.solver.TypeAdapterStore.findQueryResultBinder(TypeAdapterStore.kt:391)
at androidx.room.processor.DefaultMethodProcessorDelegate.findResultBinder(MethodProcessorDelegate.kt:140)
at androidx.room.processor.InternalQueryProcessor.getQueryMethod(QueryMethodProcessor.kt:204)
at androidx.room.processor.InternalQueryProcessor.processQuery(QueryMethodProcessor.kt:135)
at androidx.room.processor.QueryMethodProcessor$process$1.invoke(QueryMethodProcessor.kt:67)
at androidx.room.processor.QueryMethodProcessor$process$1.invoke(QueryMethodProcessor.kt:37)
at androidx.room.processor.Context.collectLogs(Context.kt:133)
at androidx.room.processor.QueryMethodProcessor.process(QueryMethodProcessor.kt:61)
at androidx.room.processor.DaoProcessor.process(DaoProcessor.kt:99)
at androidx.room.processor.DatabaseProcessor.doProcess(DatabaseProcessor.kt:100)
at androidx.room.processor.DatabaseProcessor.process(DatabaseProcessor.kt:51)
at androidx.room.DatabaseProcessingStep.process(DatabaseProcessingStep.kt:47)
at androidx.room.compiler.processing.JavacProcessingStepDelegate.process(XProcessingStep.kt:111)
at com.google.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:330)
at com.google.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:181)
at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt)
at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:147)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1068)
at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:79)
at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:35)
at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.runAnnotationProcessing(Kapt3Extension.kt:230)
at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:188)
at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:99)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:96)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:106)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:81)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:555)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:82)
at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:107)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:546)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:177)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:164)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:54)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:84)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:42)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:104)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1558)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$256(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Any idea why and is it related?
SOLUTION:
In case anyone is searching for something similar, I finally redid the project and the problem was related with moshi kapt. I update the library to 1.12.0 and everything works
In my case, I have faced the same issue while I have upgraded "kotlin-gradle-plugin: from 1.5.31 to 1.6.10".
I have solved this issue by Upgrading Gradle Version to the latest version by following official docs.
In android studio got to File>Project Structure>Project>Gradle Version here select the latest version of Gradel.
I think, This happens when we update "kotlin-gradle-plugin" and the other dependencies are not the latest version.
Also, Check your JDK version you can follow official docs.
Upgrade room to 2.4.0-beta02 will fix your problem. Because it fix mine.
We've added a new TypeConverter analyzer that takes nullability information in types into account. As this information is only available in KSP, it is turned on by default only in KSP. If it causes any issues, you can turn it off by passing room.useNullAwareTypeAnalysis=false to the annotation processor. If that happens, please a file bug as this flag will be removed in the future. With this new TypeConverter analyzer, it is suggested to only provide non-null receiving TypeConverters as the new analyzer has the ability to wrap them with a null check. Note that this has no impact for users using KAPT or Java as the annotation processors (unlike KSP), don't have nullability information in types. (Ia88f9, b/193437407)
https://developer.android.com/jetpack/androidx/releases/room#2.4.0-beta02
In your dependencies below the //Room comment add the following :
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"
and make sure you are using latest room_version = [2.3.0]
I receive following warnings when I sync Gradle in Android Studio 4.1.2 from stable channel :
Failed to resolve: legacy-support-v4-1.0.0
Failed to resolve: asynclayoutinflater-1.0.0
Failed to resolve: media-1.0.0
Failed to resolve: swiperefreshlayout-1.0.0
Failed to resolve: slidingpanelayout-1.0.0
Failed to resolve: legacy-support-core-ui-1.0.0
Here is my app module build.gradle file :
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'androidx.navigation.safeargs.kotlin'
androidExtensions {
experimental = true
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.sample.android.storytel"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
buildConfigField "String", "STORYTEL_BASE_URL", "\"https://jsonplaceholder.typicode.com/\""
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// Support libraries
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$version_kotlin"
implementation "androidx.appcompat:appcompat:$version_support"
implementation "com.google.android.material:material:$version_material"
implementation "androidx.constraintlayout:constraintlayout:$version_constraint_layout"
implementation "androidx.palette:palette-ktx:$version_palette"
implementation "androidx.test.espresso:espresso-idling-resource:$version_espresso"
// Android KTX
implementation "androidx.core:core-ktx:$version_core"
// Navigation
implementation "androidx.navigation:navigation-fragment-ktx:$version_navigation"
// Architecture components
implementation "androidx.lifecycle:lifecycle-extensions:$version_lifecycle_extensions"
// Retrofit
implementation "com.squareup.retrofit2:retrofit:$version_retrofit"
implementation "com.squareup.retrofit2:converter-moshi:$version_retrofit"
implementation "com.squareup.retrofit2:adapter-rxjava2:$version_retrofit"
// Dagger
implementation "com.google.dagger:dagger:$version_dagger"
kapt "com.google.dagger:dagger-compiler:$version_dagger"
implementation "com.google.dagger:dagger-android:$version_dagger"
implementation "com.google.dagger:dagger-android-support:$version_dagger"
kapt "com.google.dagger:dagger-android-processor:$version_dagger"
// Network
implementation "com.squareup.okhttp3:logging-interceptor:$version_okhttp"
implementation "com.squareup.picasso:picasso:$version_picasso"
implementation "com.github.florent37:picassopalette:$version_picasso_palette"
// Moshi for parsing the JSON format
implementation "com.squareup.moshi:moshi:$version_moshi"
implementation "com.squareup.moshi:moshi-kotlin:$version_moshi"
//Android RX
implementation "io.reactivex.rxjava2:rxjava:$version_rxjava"
implementation "io.reactivex.rxjava2:rxandroid:$version_rxandroid"
// Timber
implementation "com.jakewharton.timber:timber:$version_timber"
// Dependencies for local unit tests
testImplementation "org.mockito:mockito-core:$version_mockito"
// Dependencies for Instrumentation tests
androidTestImplementation "androidx.test.ext:junit:$version_junit_ext"
// Espresso UI Testing
androidTestImplementation "androidx.test.espresso:espresso-core:$version_espresso"
androidTestImplementation "androidx.test.espresso:espresso-contrib:$version_espresso"
// Testing Architecture components
testImplementation "androidx.arch.core:core-testing:$version_lifecycle_test"
// Android Testing Support Library's runner and rules
androidTestImplementation "androidx.test:runner:$version_runner"
androidTestImplementation "androidx.test:rules:$version_rules"
// AndroidX Test - JVM testing
testImplementation "androidx.fragment:fragment-testing:$version_fragment"
}
When I build the project, I receive following error :
Could not resolve asynclayoutinflater-1.0.0.aar (androidx.asynclayoutinflater:asynclayoutinflater:1.0.0)
Here you can find my project : https://github.com/Ali-Rezaei/Colors
Do you know why it happens and how to resolve it?
Addenda : I realized it is related to following dependency :
implementation "com.github.florent37:picassopalette:$version_picasso_palette"
Without this dependency, it works as expected.
The problem here is with
implementation "com.github.florent37:picassopalette:$version_picasso_palette"
is that this library is that it uses support library dependencies of android and you are trying to use it in a project where you are using jetpack library.
You can resolve it by
Using a version of that library which is migrated to JetPack..
OR
You can download the zip of that library and extract it and then open it as a project and then from refactor menu migrate to AndroidX then you import that custom project as a library into your project.
You live in a country that is under sanctions. You must use a filter breaker.
you can use this
Could not resolve asynclayoutinflater-1.0.0.aar (androidx.asynclayoutinflater:asynclayoutinflater:1.0.0)
This means gradle cannot find that dependency anywhere. Make sure that the library can be accessed by gradle inorder to resolve the problem.
Basically gradle is seeing your dependency as some unresolvable gibberish.
I just integrated Kochava SDK to my app recently. While I installing or running apk first time its crashed, but its working fine while running second time! However I also checked by generating signed(released) apk and then installing manually on device then its continuously crashing!
Here is my Project gradle file:
buildscript {
repositories {
jcenter()
google()
maven {
url 'https://maven.fabric.io/public'
}
maven {url "http://kochava.bintray.com/maven"}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'io.fabric.tools:gradle:1.31.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "https://jcenter.bintray.com" }
jcenter()
google()
maven {
url 'https://maven.google.com/'
}
maven {
url "http://dl.bintray.com/glomadrian/maven"
}
maven { url "https://jitpack.io" }
maven {url "http://kochava.bintray.com/maven"}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And Module gradle file is:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 28
dataBinding {
enabled = true
}
defaultConfig {
applicationId "xyz.xyz.myapplication"
minSdkVersion 19
targetSdkVersion 28
versionCode 31
versionName "4.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary true
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
aaptOptions {
ignoreAssetsPattern "!*ffprobe"
ignoreAssetsPattern "!*ffmpeg"
ignoreAssetsPattern "!arm"
ignoreAssetsPattern "!x86"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
android.buildTypes.each { type ->
type.buildConfigField 'String', 'Base_URL', WEBServiceBaseURL
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//Android necessary...
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
//Support libs...
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.browser:browser:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'commons-io:commons-io:2.6'
//Facebook ads
implementation 'com.google.ads.mediation:facebook:5.6.0.0'
implementation 'com.facebook.android:audience-network-sdk:5.6.0'
implementation 'com.facebook.android:facebook-android-sdk:4.41.0'
//Firebase
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.google.firebase:firebase-ads:18.3.0'
implementation 'com.google.firebase:firebase-config:19.0.3'
implementation 'com.google.firebase:firebase-core:17.2.1'
implementation 'com.google.firebase:firebase-messaging:20.0.1'
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation 'com.google.android.play:core:1.6.4'
//FFMPEG
implementation 'com.writingminds:FFmpegAndroid:0.3.2'
//Image crop
implementation 'com.naver.android.helloyako:imagecropview:1.2.2'
//Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
//Exo Player
implementation 'com.google.android.exoplayer:exoplayer:2.10.5'
//Progress bar
implementation 'com.dinuscxj:circleprogressbar:1.3.0'
//Range seekbar
implementation 'com.crystal:crystalrangeseekbar:1.1.3'
//Glide...
implementation 'com.github.bumptech.glide:glide:4.9.0'
//GPUImage...
implementation 'jp.co.cyberagent.android:gpuimage:2.0.3'
//Fetch a downloader library...
implementation "androidx.tonyodev.fetch2:xfetch2:3.1.4"
implementation "androidx.tonyodev.fetch2okhttp:xfetch2okhttp:3.1.4"
//Downloader for Android 19...
implementation 'com.mindorks.android:prdownloader:0.6.0'
//Lottie...
implementation 'com.airbnb.android:lottie:3.2.0'
//Volley for Anfroid 4!
implementation 'com.android.volley:volley:1.1.1'
//Introduction for any screen...
implementation 'com.github.paolorotolo:appintro:4.0.0'
//ViewPagerEffects...
implementation 'com.eftimoff:android-viewpager-transformers:1.0.1#aar'
//Kochava...
implementation 'com.kochava.base:tracker:3.6.3'
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
implementation 'com.android.installreferrer:installreferrer:1.1'
//AVLoader...
implementation 'com.wang.avi:library:2.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation project(path: ':jiaozivideoplayer')
}
apply plugin: 'com.google.gms.google-services'
I also implemented Application class as per suggestion and rule:
public class MyApplication extends MultiDexApplication {
#Override
public void onCreate() {
super.onCreate();
MultiDex.install(this);
final Fabric fabric = new Fabric.Builder(this)
.kits(new Crashlytics())
.debuggable(true)
.build();
Fabric.with(fabric);
AudienceNetworkAds.initialize(this);
AudienceNetworkAds.isInAdsProcess(this);
MobileAds.initialize(this, getString(R.string.app_id));
if (Build.VERSION.SDK_INT < 21) {
PRDownloaderConfig config = PRDownloaderConfig.newBuilder()
.setReadTimeout(30_000)
.setConnectTimeout(30_000)
.build();
PRDownloader.initialize(getApplicationContext(), config);
}
Tracker.configure(new Tracker.Configuration(getApplicationContext())
.setAppGuid("koboo-8bod4gz3")
.setLogLevel(Tracker.LOG_LEVEL_INFO)
);
}
}
Above code is OK for Kochava integration. But another thing is that, here I also need all those google and firebase sdk! So, may be its problem is in between google sdk and Kochava sdk! But I need can't remove google sdk or crashlytics and also I need to integrate Kochava for tracking my application in Ad campaign in "Tik Tok" as per its suggestion!
Well if I don't initialize Tracker.configure(....); in application class then app run fine and not crashing but then Kochava not working!
So, after initialize Tracker.configure(...); Kochava sdk it will be generate error:
2019-12-03 15:33:14.254 E/AndroidRuntime: FATAL EXCEPTION: main
Process: xyz.xyz.myapplication, PID: 6113
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/aidl/BaseStub;
at com.android.installreferrer.api.InstallReferrerClientImpl.startConnection(InstallReferrerClientImpl.java:133)
at com.kochava.base.c$a.run(Unknown Source:15)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.aidl.BaseStub" on path: DexPathList[[zip file "/data/app/videostatusmaker.videostatus.boo-Ptd9gTEkM8rXlvGCnCByPg==/base.apk"],nativeLibraryDirectories=[/data/app/videostatusmaker.videostatus.boo-Ptd9gTEkM8rXlvGCnCByPg==/lib/x86, /data/app/videostatusmaker.videostatus.boo-Ptd9gTEkM8rXlvGCnCByPg==/base.apk!/lib/x86, /system/lib, /system/product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.android.installreferrer.api.InstallReferrerClientImpl.startConnection(InstallReferrerClientImpl.java:133)
at com.kochava.base.c$a.run(Unknown Source:15)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
May be there is some problem in Kochava library or something I missing in integration?! Please tell me what is the problem? Or it is not suitable with google sdk?
Here is the link for Android Kochava SDK integration.
Well if you have more than one module in your app then put all Kochava dependencies in all of those module :
implementation 'com.kochava.base:tracker:3.6.3'
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
implementation 'com.android.installreferrer:installreferrer:1.0'
These all must be in all module level gradle files. This is not mentioned is in documentation but you can try it. Because I tried your code in my application and I also have Google ads and other Google's libraries and also have three modules in my app. But added these libraries in all modules than its work perfectly!
I don't know if you have more than one module in your app but if there is than this will helpful.
EDIT
It has been fixed by google, on the same version...
It should work now, if it's still crashing it's probably linked to the previous version being cached, the following should fix it:
implementation('com.android.installreferrer:installreferrer:1.1') { changing .= true}
More information here: https://github.com/adjust/android_sdk/issues/402
Try with com.android.installreferrer:installreferrer:1.0 instead of 1.1
Looks like IGetInstallReferrerService expects com.google.android.aidl.BaseStub in the 1.1 implementation, which does not come with installreferrer
mVck is correct and as far as we can tell, it's likely on Google's end and looks to be specific to version 1.1 of their library. This is our theory because it appears others on SO are experiencing similar issues with other vendor SDKs.
We've reached out to our Google reps to confirm, but in the meantime, please
stay on version 1.0 of Google's library as indicated above. Once we receive confirmation we'll be sure and update our support documentation. Thanks!
I just ran into the same thing and what fixed it for me was to delete the install referrer dependency from my gradle cache and then re-sync with gradle. I think it was something to do with the cached aar. It's bizarre though because it was fine earlier this week and the aar didn't change as far as I'm aware. Regardless, deleting it and re-syncing did the trick for me.
I was having trouble downgrading to 1.0 after attempting to fix this issue with the 1.1.1 fix. In my case the installreferrer was adding the permission READ_PHONE_STATE to my application. Gradle was attempting to resolve 1.1 even after I backed down the version to 1.0 in my app.gradle.
In order to fix this I now force installreferrer to use version 1.0.
dependencies {
configurations.all {
resolutionStrategy.force 'com.android.installreferrer:installreferrer:1.0'
}
implementation 'com.android.installreferrer:installreferrer:1.0'
}
I didn't call variant.getAssemble() from my project but still showing these messages. When I try to run the project I get this error "Manifest Merger failed with multiple errors in Android Studio
"
'variant.getAssemble()' is obsolete and has been replaced with 'variant.getAssembleProvider()'.
Gradle.build file is here, I don't use variant.getAssemble() here. If the system is calling this then where can I find it to solve the issue. I have multiple modules.
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-crash'
dependencies {
implementation project(':A')
implementation project(':B')
implementation project(':C')
implementation project(':D')
//implementation project(':E')
implementation project(':F')
implementation project(':G')
implementation "com.android.support:appcompat-v7:$project.supportVersion"
implementation "com.android.support:support-v4:$project.supportVersion"
implementation "com.android.support:cardview-v7:$project.supportVersion"
implementation "com.android.support:recyclerview-v7:$project.supportVersion"
implementation "com.android.support:design:$project.supportVersion"
implementation "com.android.support:support-v13:$project.supportVersion"
implementation "com.android.support:support-vector-drawable:$project.supportVersion"
implementation "com.google.firebase:firebase-core:$project.firebaseCore"
implementation "com.google.firebase:firebase-ads:$project.firebaseAds"
implementation "com.google.firebase:firebase-auth:$project.firebaseAuth"
implementation "com.google.firebase:firebase-messaging:$project.firebaseMessaging"
implementation "com.google.firebase:firebase-crash:$project.firebaseCrash"
implementation "com.google.code.gson:gson:$project.gsonVersion"
implementation "com.google.guava:guava:$project.guavaVersion"
implementation "org.jsoup:jsoup:$project.jsoupVersion"
implementation "ch.acra:acra:$project.acraVersion"
implementation "com.mcxiaoke.volley:library:$project.volleyVersion"
// optional
debugImplementation "com.squareup.leakcanary:leakcanary-android:$project.leackcanaryVersion"
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$project.leackcanaryVersion"
testImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$project.leackcanaryVersion"
implementation 'com.android.support:multidex:1.0.3'
implementation "com.squareup.retrofit2:retrofit:$project.RetrofitVersion"
implementation "com.squareup.retrofit2:converter-gson:$project.RetrofitGsonVersion"
}
android {
defaultConfig {
applicationId "com.XXX.XXXX"
multiDexEnabled = true
vectorDrawables.useSupportLibrary = true
}
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
def relativeRootDir = output.packageApplication.outputDirectory.toPath().relativize(rootDir.toPath()).toFile()
output.outputFileName = new File( "$relativeRootDir" + File.separator+"libs", project.name+"-"+project.versionName+".apk")
}
}
}
apply plugin: 'com.google.gms.google-services'
You can safely ignore it. Some plugins like Fabric cause those warnings, as it's devs have to adapt to new Android Studio/Gradle releases. Just make sure to use latest versions of your dependencies.
Recently I have dived into learning new andoirdX artefacts including Android Architecture Components.
After reading through the officials docs and a google code samples I have successfully added the necessary dependencies in both my project and app level Gradle files.
They are as follows
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:$navigationVersion"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
and
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'androidx.navigation.safeargs'
android {
compileSdkVersion 28
defaultConfig {
applicationId "_ _ _ _ _ _"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
implementation 'com.google.android.material:material:1.0.0-rc01'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
def lifecycle_version = "2.0.0-beta01"
def room_version = "2.0.0-beta01"
def navigationVersion = '1.0.0-alpha06'
kapt "androidx.room:room-compiler:$room_version"
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
implementation 'androidx.core:core-ktx:1.0.0-alpha1'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-runtime:$lifecycle_version"
implementation "android.arch.navigation:navigation-fragment-ktx:$navigationVersion"
implementation "android.arch.navigation:navigation-ui-ktx:$navigationVersion"
implementation "androidx.room:room-runtime:$room_version"
}
after giving Gradle sync everything worked fine, however, it showed an error saying "Manifest merge error please see logs for more info"
I have double checked with an app from google repository and everything seems normal.
Please accept my humble appreciation in advance
Recently I have run into the same issue, Before giving you the solution I would like to tell you that in recent days, due to fast-paced development tools offered by Google our days-old development technique has changed significantly.
Take jetpack as an example, which is a part of AndroidX, and adding it into your projects requires some necessary steps. Moreover, if you are like me who uses Android studio's dialogs for creating an app, you are likely to have these kinds of issues including the one you have mentioned.
The reason for this is android studio still use Appcompat-v7, androidX on the other hand, uses
androidx.appcompat:appcompat:1.0.0
see the full artifacts listing
Above all, after adding responsible dependencies you need to add these two lines in you gradle.properties file
android.useAndroidX=true
android.enableJetifier=true
Unfortunately, if have come this far you would still probably face
Manifest marge error
this is because your automated layout files still have old classpaths such as
android.support.design.widget.CoordinatorLayout
which should be like this androidx.constraintlayout.widget.ConstraintLayout
this one android.support.design.widget.AppBarLayout should be com.google.android.material.appbar.AppBarLayout and So on.
After rechecking every classpath rebuild your project and everything should be fine.