Creating a new starter project in Android Studio fails :-( - android

I was trying to revive an Android project that I had been working on about 4 years ago and that is maybe 80% completed, but I got stuck again.
I had installed the latest version of Android Studio and imported the old project but AS fails to build it ("Unable to find Gradle tasks to build: [:]." ?!?).
I thus tried to start over by first creating me a new, essentially empty project first with the intention to then copy the old project over "bit by bit".
So I selected "Basic Activity" as project type and had the "Wizard" create the project but also that does not build but fails with the error message:
Duplicate class androidx.lifecycle.ViewModelLazy found in modules lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1) and lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1)
Is this indeed the sorry state of Android Development? What am I missing here? Is there a project type or template that somewhat reliably works "out-of-the-box" so one can at least get a working base-line to start from?
This is using AS 2021.3.1 Patch 1.

Related

Auto Package Duplication in Test Directory of Android Studio

I was preparing some tests for my module in android studio and everything was working fine, but yesterday when I opened my project again, I found an auto-generated copy of my test package.
when I tried to delete it, my original package got deleted with it.
today I tried to create a package again and the problem is still persisting, and it is only occurring in the "tests" folder
structure at Android level: Duplicate at Android level
structure at Project level: only one package at Project level
I found a similar question here but it defers a bit: link
he found the problem was due to one of his dependencies which were auto-generating the code, but my project structure was fine for a week, the problem occurred just recently. and I've hard-coded the dependency versions so there's no way it might have happened due to an update.
Although Just in case, This are my dependencies:
Does anyone have any idea why this is happening?

Error building android: Duplicate class androidx.annotation.AnimRes found in modules annotation-1.3.0 - Unity 2019.4.40f1

So when I try to build android app, I get these duplicate errors and also warnings about mapping new ns.
I tried many different configuration and sdks etc. For now my setup is:
Unity 2019.4.40f1
Android SDK, JDK and NDK downloaded as a modules from unity hub (I tried different ones, nothing changes)
Gradle 6.9.2 (already tried the latest one version, still same)
My target api is level 30 and minimum is 21.
I am using many libraries for my project like Branch.io for deeplinks, playfab, googleplayservices, facebook sdk etc. It might be the issue, but I am not sure.
I tried also export my project and it works surprisingly.
Also what's important I use custom gradle.properties file which looks like that:
Finally, I solved this by deleting old jars located in gradles templates location, for me: Assets>Plugins>Android

Gradle build failing - "A problem was found with the configuration of task ':app:generateSafeArgsDebug' (type 'ArgumentsGenerationTask')."

I'm trying to open and run the android architecture components sample project here: https://github.com/android/architecture-components-samples/tree/main/GithubBrowserSample in Android Studio. One one machine I'm able to get the project built and run just fine, but on my primary machine I'm seeing a build task error:
A problem was found with the configuration of task ':app:generateSafeArgsDebug' (type 'ArgumentsGenerationTask').
> No value has been specified for property 'enableGradleWorkers'.
I've tried the version of gradle and the gradle plugin that the project seems to have been built with, as well as the latest of each. I do have "android.enableGradleWorkers=true" specified in gradle.properties.
I haven't found this message when searching around, but I often see similar-looking errors when opening projects from different sources. I'd love to be able to fix this one, and ideally understand more about what to check when encountering build errors with projects from different sources in the future.

Android Studio missing src and other part of my project after reopening

currently I'm exploring on using the Android Studio. It's been a while since I last developed on Android and this is really exciting for me having a new tool to develop in Android. Now I already setup the Android Studio successfully and already tested to create a new sample project last week but today after I opened it a message appears saying that "the folders below are removed from gradle..." it has a checkbox and I don't know why it's checked by default. Since I'm not yet that familiar with the environment I pressed ok then all the src and other folders are now missing. Although I can still access the src folder as well as the classes I created through the use of the navigator on the top part but I can't run the app and it acts really strange compared from before.
Also when I try to create a new project a message appers saying:
"Failed to import new Gradle project: Could not fetch model of type 'IdeaProject' using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
Unable to start the daemon process."
Not sure on what to do about this one. Well I know this is still in beta and bugs happen but I hope there's already a workaround for this.
Anyway, here's a screenshot on what happens to my project:
So I tried searching answers based on the error message I got from creating a new project and found out about this one:
Failed to import new Gradle project: Could not fetch model of type 'IdeaProject'
works like charm indeed.

Android Studio Gradle error

Everything is ok but when i try to run it gets one error
Gradle: : java.lang.NullPointerException
Please help me, because i wanna to throw all this stuff with my NTB down from the cliff, after about five hours of configuring git, android studio and copying my projects from Eclipse, still got this
I had the same problem. I solved it by going into 'Project Structure' and one of my modules had both 'Android' and 'Android - Gradle'. I deleted the 'Android - Gradle' and rebuilt the project and the error disappeared.
Edit: I had bigger problems than this and ended up creating a new project...
You need to make sure Gradle is installed and properly configured in the preferences.
I had the same problem. It was because the path to android studio contained a whitespace. Installing android studio to the recomended location solved my problem.
As easycheese underlined the problem is related to the presence of the android-gradle item below one or more modules in your project. Go to the "project structure" (from the File menu) and check which module has two sub-items, one of them must be the android-gradle, delete it and rebuild your project. It should fix the issue......as J.Romero says...Android Studio is far from being ready for professional use, but what it is really annoying is that Google, with all its resources, gives developers such "immature tools" that make rather waste time than anything else....shame
I wont re-write my whole answer, but check out the following page in which i replied to a Gradle common error with over 10 common solutions across the web including mine.
Long story short, for me it turned out to be system resources were getting low (Google Chrome was the greedy one)
If it works after a fresh reboot, but after a few minutes or hours it starts.. This would indicate this.
Gradle Error In Android Studio

Categories

Resources