com.android.build.api.transform.TransformException - android

i've ben facing this and tried to solve without any luck. Below are the error out put and my gradle file. Before marking this as duplicate i would like to point out almost all the suggested ways didn't work for me.
What i have tried so far
set multiDexEnabled to true
un-commented the line org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 in my gradle.properties file
change my application class to extend MultiDexApplication instead of Application
Check if i have duplicates class and i don't
updated android studio and google play services to latest versions (3.1.2 for android studio)
cleaned the project and even deleted .gradle file
any help will be appreciated. thanks in advance

so if anyone in the future will be having having this, the correct way for me was to check my library versions that utilize live data. As the error suggests, it had an association with live data. You don't have to implement live data to get this error but utilizing any library that has connection with live data can lead to this problem.
In my case it was Firebase ui library as i updated android support library to 27.1.0.
so i also updated firebase ui ,library to 3.2.2.
as per google, this was an Intended behavior so the only thing to fix that is to update firebase ui library to a version that supports library 27.1.0.
as suggested here

Related

Unsupported kotlin version

My gradle build completes successfully, but I get:
WARNING: Unsupported Kotlin plugin version.
The `embedded-kotlin` and `kotlin-dsl` plugins rely on features of Kotlin `1.5.31` that
might work differently than in the requested version `1.6.10`.
All of my build.gradle.kts scripts refer to using version 1.5.31. The only association my project has with version 1.6.10 is that Android Studio has the Kotlin version 1.6.10 plugin added. If I try to disable that plugin, I get a message that several other plugins will be disabled. If I accept that, android studio crashes and will not start up again. It won't start up again even if you reinstall android studio again. The solution is to find the file named "disabled-plugins.txt" and delete that file. It's in your AppData folder and in a JetBrains subdirectory. It turns out that it's one or more of those other disabled plugins that prevents Android Studio from starting up again.
The question I have is how do I fix this version mismatch issue. I can't delete the plugin from Android Studio for the reasons I mentioned above. If I try to update my project to using version 1.6.10 I get literally 100's of unresolved dependencies. And it seems from opinionated investigation that 1.6.10 still have too many issues for general use.
By the way, when I look at the gradle window for the project I can see where the dependencies come from. Usually when I look at the gradle window I just see sub project folders that I can drill into for more information, but for this project, it has an additional folder name dependencies. I don't know how they get into my project. But when I look at their version numbers that's where the 1.6.10 mismatch happens.
So, I think I understand why the warning message is valid, I'm at a lost on what I need to do to correct this situation. For the moment, I'm just ignoring the warning, and so far I'm not finding any issues in proceeding that way. But that's means I'm proceeding, without an understanding of what's going on here! Sometimes that's okay and at other times that's a bad judgment The error message itself seems inverted. I would think that 1.6.10 is the embedded kotlin and kotlin-dsl since it an android studio plugin, but the error message seems to say it in the opposite way. So anyway, if someone can bring some clarity as to what's going on, and how I'm thinking wrongly about this problem would be greatly appreciated.
I'll accept the following as the answer to what's going on about the unsupported kotlin version:
https://github.com/gradle/gradle/issues/13020
So, for the moment, I'll go on like this is just a nuisance warning and ignore that.
What I just did was to re-create my Android Studio from a blank brand new project. I copied and pasted stuff from the previous project into the new project. I copied the source and build.script.kts files, so essentially everything is a copy of the disabandoned project. This new project didn't give me the WARNING message anymore. And in additional, I'm now able to upgrade my project to using kotlin 1.6.10, which I previously couldn't do because of the literally 100's of dependencies resolution issues. Whatever, that issue went away, and a lot of others things started working as expected once I recreated the project. I can't say what got my project into that weird state. Deleting the .gradle and .idea folders, wouldn't fix the problem. I didn't try deleting the JetBrains cache, I wish I would have tried that.

Gradle issue with sceneform - Program type already present: com.google.ar.schemas.lull

I am working on a project that will have a 3D model viewer in one fragment. In order to do so, I decided to use sceneform.
I downloaded sceneform plugin into Adnroid studio, downloaded and extracted sdk from Github, and I also copied libsceneform_runtime_schemas library into my project. I've added to my sceneform buil.gradle file line
implementation files("../libs/libsceneform_runtime_schemas.jar")
but that results in an error:
Program type already present: com.google.ar.schemas.lull.AabbDef
It is worth noticing that this is the first file in the jar under this path - which probably means that there will be more collisions.
If I'd try not to implement this library, then I get an error:
error: package com.google.ar.schemas.sceneform does not exist
I am using ar:core:1.17.0, and minSdkVersion 24 in sceneform gradle.
I've cleaned and rebuilt the project, Invalidate Caches/Restart, and added multiDexEnabled- although I am not sure if I did it correctly.
By using gradlew sceneform:dependencies I didn't find mentioned file.
I don't know how I can move forward, any help is much appreciated. If I can provide additional information, please let me know.
Edit 1:
I've also tried to work with
implementation files("../libs/libsceneform_runtime_schemas.jar"){
exclude ...
}
But I couldn't make it work. I wonder if that could be my solution.
Also, why does it try to implement this class since it already exists? Shouldn't there be some sort of check for that?
I solved my problem by restoring my project from repo to the last moment before including sceneform, and I proceeded with all of the steps again; Gradle dependencies to the libsceneform_runtime_schemas, min java 8, min SDK version, copying scenformscr and sceneformux to my project again, and lastly - upgrading all classes to AndroidX.
After two days almost I couldn't remove the error, and I don't know what went wrong before, but this time it works like a charm.
TL;DR - I removed the sceneform from my project and imported it again.

Type mismatch when creating a new ViewModel for Room implementation - kotlinx.coroutines obsolete since 1.3

I am building an app that will rely heavily on user data and plan on using Room to help manage and store their information. However, while following a tutorial I ran into a few versioning issues that I was having troubles resolving on my own.
Since I am fairly new to both Android development as well as using Room, I have been following this tutorial: Android Room with a View - Kotlin
I first noticed there might be some issues in step 3 when I updated my Gradle files. I was met by the following error on the last two lines of the dependencies block:
Library should be updated to be compatible with Kotlin 1.3
I was confused by this since the tutorial uses a variable of some kind to determine the library versions. I ran the app at this point and it seemed to work fine so I continued.
When I got to step 9, I also ran into additional errors which now prevent builds from completing:
Type mismatch: inferred type is kotlin.coroutines.experimental.CoroutineContext but kotlin.coroutines.CoroutineContext was expected
Type mismatch: inferred type is kotlin.coroutines.CoroutineContext but kotlin.coroutines.experimental.CoroutineContext was expected
This is on top of errors that implementations of kotlinx.coroutines.experimental are obsolete, however, I couldn't find references to libraries without experimental using Android Studio's intellisense.
What do I need to do in order to resolve these library issues and allow me to continue the tutorial?
To the best of my knowledge, here is the recommended way to resolve these issues.
To try and solve these issues, I started with the errors in my Gradle scripts to see if that would maybe resolve dependencies in the code. I did find this post, which I'm still not completely convinced is the best solution, but just following the first couple of suggestions in the top answer did clear most of my issues.
To be clear, I changed the following:
Changed the variable in the last line of the dependencies Gradle block to have a hard-coded version number (I did the latest as found in the kotlinx.coroutines repo). If possible, I would like this to be auto-generated again as the tutorial implies
Removed the kotlin block from the bottom of that same Gradle file
Synced my Gradle project
Update Kotlin and Gradle (I was asked by Android Studio, you might not be depending on your versions)
Manually removed problem libraries from code, and Alt+Enter'ed any missing libraries back into existence
If you update Gradle, you may also find it necessary to include the following in your Module: app Gradle file inside the android block:
packagingOptions {
exclude 'META-INF/*'
}
(* might be overkill for some, but the suggestion from this post didn't completely eliminate all of my errors.)
After all that, I was then able to rebuild the SDK which loaded to my phone with zero errors.

Android Studio: migration to AndroidX with third-party

I followed the official migration: https://developer.android.com/jetpack/androidx/migrate
The migration worked perfectly.
In my project, I use several third libraries. The complete build of my entire project works.
BUT now from Android Studio, I have a lot of syntax errors (from the editor, not after the build!). ie with the third-party "advrecyclerview" where the property "itemView" doesn't know now because:
So how can I change editor syntax analysis, etc. have you got some solutions?
Thank you very much
In your question you are using the wrong recycler view.
If you follow the link you posted, you will see the new package should be
androidx.recyclerview:recyclerview:1.0.0
(which means androidx.recyclerview in imports)
You need to make sure to change the XML to match
Edit
As it is in a library, make sure to enable Jetifier to auto-fix the libraries. It can still fail, but it does a good job for the majority.
You need to put the following gradle.properties:
android.enableJetifier=true
android.useAndroidX=true
More information on this is in the migration document
Ok guys, I found the problem: from Android Studio, I did "Invalide Caches and Restart", and the editor syntax works perfectly now.

Why do we need to copy the Google Play Services library in our project?

Why does Google have this note? [ref]
What is the harm in adding reference to the library in the SDK directory? I have done it and my app worked just fine.
I think maybe it could will change name in some sdk updates, so if you referece to your copy nothing can go wrong.
instead reference it on gradle to avoid this problem (Gradle work for us to avoid dependecy problem :)).
Yes, you can use it directly from there. I used to do it too till i realized what the problem could be.
If you are making no changes to the library it should work fine. But if you plan to add some build files or configuration etc you should copy it to the project. (I had some for my ant builds) If you dont have any, at the time of updating the library from SDK manager you lose everything you changed or configured. Apparently it deletes all unidentified or manually added stuff when updating the library.
With Android studio it is much simpler and you just add a dependency with required version to your build.gradle file.

Categories

Resources