Android Room tutorial does not build - android

UPDATE: Solved! (see fix at the bottom)
I'm trying to go through the Android Room tutorial but get stuck on step3. I keep getting an error when trying to update the gradle file as specified by the tutorial.
https://codelabs.developers.google.com/codelabs/android-room-with-a-view/index.html?index=..%2F..index#1
When trying to build, I get the following error:
Setting roomVersion to "2.1.0-alpha06" or just "2.1.0" generates the same type of error.
Is it only me or is there something wrong with this tutorial?
Anyone with an idea why the androidx.room:room-testing dependancy fails to build?
UPDATE:
I solved the issue by uninstalling Android Studio and re-installing it. I also needed to do a full cleanup and remove all "android studio" and "gradle" related files on my system. Maybe a bit overkill, but this is whats fixed it for me.

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.

How to resume a stuck code analysis in Android Studio?

I recently noticed a behaviour, that the default code analysis does not finish anymore in one of my android projects, in particular in kotlin files - unfortunately without an error message. With a stuck analysis I am not able to identify errors in my code anymore and basic stuff like autocompletion does not work, which makes it unable to work.
In the top right corner of the opened file I constantly get Analyzing...
I already tried restarting Android Studio, invalidating its cache, deleting and cloning my project again, rebooting and deleting all kind of gradle and Android Studio cache files but without success.
I finally got it working again with the help of the idea.log file, which can be found via Help > Show Log in Explorer in Android Studio.
The log stated an Exception while analyzing expression at different locations in my files, caused by java.lang.IllegalStateException: #NotNull method org/jetbrains/kotlin/builtins/KotlinBuiltIns.getBuiltInClassByFqName must not return null.
Since it looked like a Kotlin related issue, I upgraded org.jetbrains.kotlin:kotlin-stdlib-jdk7 in my build.gradle from 1.4.10 to 1.5.10 and it worked instantly again. I hope the info helps anyone!
Please remove butterknife plugin in Settings-> Plugin. It is worked for me in java files.

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.

org.jetbrains.kotlin.util.KotlinFrontEndException: Exception while analyzing expression

I run a kotlin project successfully on my desktop, but when I import the same project on my laptop and when I rebuild the project, it's throwing "org.jetbrains.kotlin.util.KotlinFrontEndException: Exception while analyzing expression".
As suggested in net, I tried with clean build, invalidate cache and restart. I deleted the cache folders and logs but no results.
I have tried Googling, but found no answer for this particular problem.
Details:
Current kotlin plugin version: 1.3.61-release-Studio3.5-1, latest version of plugin is installed, using Android Studio 3.5.2
Any help is apreciated!
I was facing a similar error, updating Kotlin Plugin and restarting Android Studio fixed the issue for me
This seems to be a sync issue. To solve this, I performed these two steps in succession and then re-ran the project:
Deleted the entire build folder
Build > Clean-Project
In my case I was missing some jar files that were required for the app to build. So if you encounter this, check if you have all required dependencies on your classpath.
In my case it was broken xml layout file (the expection message did not indicate the file).

Android - Deprecated NDK warnings in Android Studio

After a long time working fine my project suddenly build failed. The image below is what i get from log.
I already have gradle.properties file with 'android.useDeprecatedNdk=true' in my project but the error keep show up.
Please help. :(
The warning says that useDeprecatedNdk=true will stop working soon. If you plan to keep using the latest Gradle Plugin, you should edit your build.gradle and use externalNativeBuild.
Actually, the change should be pretty easy, and the explanation on developer.android.com is quite straightforward.
The error you see is probably not related to the warning. Something went wrong in your build. The easiest way to find out is to run same ndk-build in the terminal window of your Android Studio, and analyze the results.
Carefully copy all parameters from the log, and add V=1:
/Users/haulx94/Library/Android/sdk/ndk-bundle/ndk-build NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/haulx94/AndroidProject/hd1-android/HDONE/app/build/intermediates/ndk/stagging/debug/Android.mk APP_PLATFORM=android-25 NDK_OUT=/Users/haulx94/AndroidProject/hd1-android/HDONE/app/build/intermediates/ndk/stagging/debug/obj NDK_LIBS_OUT=/Users/haulx94/AndroidProject/hd1-android/HDONE/app/build/intermediates/ndk/stagging/debug/lib APP_STL=gnustl_shared APP_ABI=armeabi-v7a V=1

Categories

Resources