project Root project "Gradle project not found for Module: "MyApplication" - android

My new Android studio version is giving below error for the sample project could you please help?
Below is the logs for IDE Fatal Error i got
IDE Error
Root project path of the Gradle project not found for Module: 'MyApplication2'
com.intellij.openapi.diagnostic.Logger$EmptyThrowable
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:140)
at org.jetbrains.plugins.gradle.execution.GradleOrderEnumeratorHandler.addCustomModuleRoots(GradleOrderEnumeratorHandler.java:110)
at com.android.tools.idea.gradle.project.AndroidGradleOrderEnumeratorHandlerFactory$1.addCustomModuleRoots(AndroidGradleOrderEnumeratorHandlerFactory.java:93)
at com.intellij.openapi.roots.impl.OrderEnumeratorBase.addCustomRootsForModule(OrderEnumeratorBase.java:422)
at com.intellij.openapi.roots.impl.OrderRootsEnumeratorImpl.collectModuleRoots(OrderRootsEnumeratorImpl.java:238)
at com.intellij.openapi.roots.impl.OrderRootsEnumeratorImpl.lambda$computeRoots$0(OrderRootsEnumeratorImpl.java:108)
at com.intellij.openapi.roots.impl.OrderEnumeratorBase.processEntries(OrderEnumeratorBase.java:303)
at com.intellij.openapi.roots.impl.ModuleOrderEnumerator.forEach(ModuleOrderEnumerator.java:47)
at com.intellij.openapi.roots.impl.OrderRootsEnumeratorImpl.computeRoots(OrderRootsEnumeratorImpl.java:104)
at com.intellij.openapi.roots.impl.OrderRootsEnumeratorImpl.getRoots(OrderRootsEnumeratorImpl.java:74)
at com.intellij.openapi.roots.OrderEnumerator.getClassesRoots(OrderEnumerator.java:159)
Because of this error Gradle build is getting failed Gradle error screen shot attached
Also in Project structure required files are not getting generated
for example: Application specific build.gradle Project structure picture attached
PS: Android studio version is 3.1.4

I had the same problem and solved it by below methods.
I don't know what OS you are running, but mine is macOS High Sierra, and
Android Studio version is same as yours. (v 3.1.4)
First thing I tried, and it worked.
I changed the gradle version to 4.2 and re-opened the project.
File -> Project Structure -> Project -> Gradle version from 4.4 to 4.2
I changed the gradle version from 4.2 to 4.4 again.
I closed the project and re-opened it after I deleted the gradle on the below directory.
/Users/$USERNAME/.gradle/wrapper/dists/GRADLE_VERSION

Related

gradle refuse to sync even after downloading from their site

I tried to sync my gradle in android studio and it showed me this error even after I tried to sync it locally, still the same error:
Error:BUG!
exception in phase 'class generation' in source unit
'ijinit0_8gov8jl8pmdtxuu0gk1mcw4af' unsupported Target MODULE
What Gradle and Java versions are you using?
Try downgrading them & delete the build and .gradle folders in your project directory

gradle error in unity exported android project

I am going to use the build config property "multiDexEnabled true" to break 64K methods limit following link
https://developer.android.com/studio/build/multidex.html#about
I update to use unity 5.6.1f1 and android studio 2.3.3. I set "build system" option to "Gradle(New)", which is new added from 5.5, then click "Export" to create an android project.
I open the exported project with android studio, then I get the following error
I try the two blue links, but I keep geting this same result.
For my unity project, I only create an empty project and add a button to a unity scene, then export it. I have also tried to build API directly, it works.
It is important for me to export unity project to andoid studio project, because it can help us to use additional compile options
Do any one know what I miss? Or how to export unity project correctly?
Thanks
The gradle error text, if cannot see the image link
Error:org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection
Possible causes for this unexpected error include:Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
I had the same issue with unity 2017.1.0b4 and Android Studio 2.3.3, gradle 3.3.
You should change android plugin for graddle version in Android studio to 2.3.3
You can specify the Android plugin for Gradle version in either the
File > Project Structure > Project menu in Android Studio, or the
top-level build.gradle file. The plugin version applies to all modules
built in that Android Studio project. The following example sets the
Android plugin for Gradle to version 2.3.3 from the build.gradle file:
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
https://developer.android.com/studio/releases/gradle-plugin.html
Check your local gradle version in directory -
C:\Users\yourname\.gradle\wrapper\dists
Modify your project gradle configuration -
project\gradle\wrapper\gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Make sure gradle-3.3-all match to your gradle version.
If you have wasted a lot of time fixing unity Gradle error but nothing worked then you tried unity internal builder but that gave "Parsing Package error"
then try this, it will not help you make your project using unity's Gradle but it will make your project without any error successfully.
Export your project from unity to a folder eg: ProjectName_Gradle.
open android studio, make sure you are connected to the internet .
close current project then select "Open Gradle, eclipse ADT, etc;" option and open ProjectName_Gradle folder.
check the version of buildTools installed in your android-SDK by opening android-SDK settings from the android studio itself.
edit "build.gradle" file under Gradle Scripts section or under your project.
and change "buildToolsVersion" to the latest version installed in your SDK.
then click "syn project with Gradle Files" from file option and let it sync.
it may ask to update Gradle version, then click update
now there should not be any errors.
now try building APK.

Android Studio cannot resolve symbol 'android'

I am doing a project in Android Studio and today I saw that suddenly all my code has errors and even the line:
import com.google.android.gms.appindexing.Action;
has error: cannot resolve symbol android
any suggestions why this might have happened?
Please ensure you have mention in your project grades it has been tested and working fine
dependencies {
...
compile 'com.google.android.gms:play-services-appindexing:8.4.0'
...
}
clean your project and rebuild again and wait till android studio make indexing and loaded all resource some time due to system it will slow.
please comment if you found something else. happy coding :)
1st update your SDKs ( Android tools SDK & Google play service)
in your build.gradle "modules" include this code in your dependencies
compile 'com.google.android.gms:play-services-places:<version>
where is the latest version available...my version at the time of this answer is 11.0.4
Please try as follows
Exit Android Studio
Back up your project
Delete all the .iml files and the .idea folder
Relaunch Android Studio and reimport your project
or
Exit Android Studio
Back up your project or rename your project
Clone new project
solved this issue by -> clean project - > save all - > close all tabs ->
Close entire project ->
Reopen it again.
The issue solved

Import a project to Android studio faced problems

I want reading an open source project so I select k9mail for start. The recommendation was run and reading this code in Android Studio. I import k9mail project to AS 1.2.1.1 version. I download gradle 2.4 version and added this in environment variable. When I want to run this application, but I receive some errors that I describe below:
1) When I click Run (Alt+Shift+F10), select Android Application, select my module (there is k9mail) and select USB Device, then I see a warning:
No JDK specified for module 'k-9-master'.
2) When I click on Run (Shift+F10), I faced this error in messages tab:
Gradle DSL method not found: 'android()'
Possible causes:
A)The project 'k-9-master' may be using a version of Gradle that does not contain the method.Open Gradle wrapper file
B)The build file may be missing a Gradle plugin. Apply Gradle plugin
When I updated gradle to 2.4, I changed classpath 'com.android.tools.build:gradle:1.2.3' to 'classpath 'com.android.tools.build:gradle:2.4'' from build.gradle of k9mail, but my problems were not solved.
I googled but I can't find solutions for my problems.
No jdk specified for the module.
For that you have to specify the jdk path through Project Structure.
You may also verify by looking at local.properties
For gradle related issues you just kindly update your gradle build and SDKs to latest versions.
This will minimize your gradle issues.

Importing Eclipse project to Android Studio 0.8.14

I am having huge problems migrating since I am doing it on a big project.
I have: Beta 0.8.14 installed (latest version)
I generated build.gradle from eclipse and imported to android studio. I tried running it but there where no modules so after some googling I tried adding module but got an error:
Error:The project is using an unsupported version of Gradle.
Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.)
Tried again with gradle wrapper and this happened:
10:31:24 AssertionError: Already disposed: Module: 'appName': Already disposed: Module: 'appName'
10:31:30 AssertionError: Already disposed: Module: 'appName': Already disposed: Module: 'appName'
And now I am stuck.
I tried importing normal project as well (without the build.gradle file) and I got the same result.
I don't know what I am doing wrong, I tried multiple tutorials and none worked. The project is fairly large. The reason I am migrating to android studio is to use android-support-multidex that only works with gradle.
I updated android studio to 0.9.3 and it works now.

Categories

Resources