Android Studio breaks a part package into seperate directories - android-studio

I recently imported a project I have been working on from eclipse to android studio and have been using robolectric to test units of my code. The unit tests are placed in a file system similar to this: src/test/java/com.foo.bar where com.foo.bar is a package. On every reboot of Android Studio the file system breaks a part the directory into src/test/java/com/foo/bar where all of the folders are directories (including the java folder which should be a Java folder).
Has anyone else experienced this problem?

Related

How to solve gradle; "contains too many directories after formatting system"

I am developing an app using android studio and java. I downloaded gradle 6.1.1.zip and it was working fine. I formatted my system and installed android studio. I want to use the same gradle but I'm getting error.
file:/C:/sam/gradle-6.1.1-all.zip' contains too many directories. Expected to
find exactly 1 directory.
The zip file contains only one gradle. How do I solve this issue?
According to this android dev doc, you can specify the gradle version either in: File > Project Structure > Project menu in Android Studio, or in the file gradle/wrapper/gradle-wrapper.properties . In your case, for gradle 6.1.1.zip, you use the following in the above mentioned file:
...
distributionUrl = https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
...

Android Studio "Scanning For Files To Index"

I am trying to achieve the following project structure in Android Studio
project/
projectA/
projectB/
Where projectA is an "app" module created by Android Studio which I have renamed, and projectB is a Kotlin project I wish to depend on in the app. I can get the projects to appear correctly as modules in my project however no matter what I try, as soon as I add projectB to my Android Studio project, it seems to get stuck in a loop "searching for files to index". When I look at the files it is always just looping through the same 2-3 files. They are always META-INF files but not always the same ones.
How do I successfully add a module to an Android Studio Project without hitting this error or how can I set out my project from the start to achieve this structure?
Thanks.
The problem seemed to be that I had a gradle/ directory under my project/projectB directory that was there because the project was originally created as a standalone project by IntelliJ. Deleting that fixed the issue.

where does gradle put the jars it downloads?

I am using Android Studio with Gradle. Where in my project do I find the jar files that I am pulling with Gradle with say
compile 'com.squareup.picasso:picasso:2.5.2'
Digging through Android Studio I find a xml file under
/Users/myname/StudioProjects/Myproject/.idea/libraries/picasso_2_5_2.xml
I look inside, opened a terminal and routed to the path suggested. I get to the jar. Now I want to browse it. If I source for picasso-2.5.2-sources.jar using Spotlight Search then nothing is found. So obviously I cannot just get to it to view what's inside. So how might I do that?
When running Gradle, a .gradle folder is created in your home directory: ~/.gradle/caches.

Android training for FragmentBasics won't import into AS 1.5.1

In trying to get the hang of Fragment, I imported into Android Studio 1.5.1 the unzipped folder FragmentBasics after extracting the downloaded file FragmentBasics.zip to that Folder.
Now I have Gradle problems and I have no clue what to do to be able to run the app. I don't know that the .zip file is from Eclipse as the message suggests.
I did move the folder FragmentBasics to C:\Users\Dov because of the space in "Google Drive" but got same error.
Gradle project sync failed . Basic functionality (e.g., editing, debugging) will not work properly.
Failed to sync gradle project 'FragmentBasics'
Error:Cause: failed to find target with hash string 'android-15' in: C:\Users\Dov\AppData\Local\Android\sdk
Open Android SDK Manager
ECLIPSE ANDROID PROJECT IMPORT SUMMARY
Risky Project Location:
The tools should handle project locations in any directory. However,
due to bugs, placing projects in directories containing spaces in the
path, or characters like ", ' and &, have had issues. We're working to
eliminate these bugs, but to save yourself headaches you may want to
move your project to a location where this is not a problem.
C:\Users\Dov\Google Drive\AndroidStudioProjects\FragmentBasics
-
Replaced Jars with Dependencies:
The importer recognized the following .jar files as third party
libraries and replaced them with Gradle dependencies instead. This has
the advantage that more explicit version information is known, and the
libraries can be updated automatically. However, it is possible that
the .jar file in your project was of an older version than the
dependency we picked, which could render the project not compileable.
You can disable the jar replacement in the import wizard and try again:
android-support-v4.jar => com.android.support:support-v4:18.0.0
Moved Files:
Android Gradle projects use a different directory structure than ADT
Eclipse projects. Here's how the projects were restructured:
AndroidManifest.xml => app\src\main\AndroidManifest.xml
res\ => app\src\main\res\
src\ => app\src\main\java\
Next Steps:
You can now build the project. The Gradle project needs network
connectivity to download dependencies.
Bugs:
If for some reason your project does not build, and you determine that
it is due to a bug or limitation of the Eclipse to Gradle importer,
please file a bug at http://b.android.com with category
Component-Tools.
(This import summary is for your information only, and can be deleted
after import once you are satisfied with the results.)
I installed sdk 15 but then had problems with Gradle griping about
gradle-wrapper.properties file having a line with
gradle-2.8-all.zip that needed to be changed to
gradle-2.1-all.zip, so I edited gradle-wrapper.properties file to contain 2.1 instead of 2.8.
Message said after making change, re-import project. And it works.
Before importing I only removed following line from AndroidManifest.xml
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15" />
Worked with FragmentsBasics.zip in Android Studio 2.3.3

Cloning a project in Android Studio causes gradle exception

I have ligdx/robovm/gradle/android studio project with core, ios, android and desktop subprojects. I wanted to clone android subproject and create very similar one (I named it android-full). I've copy-pasted android directory and renamed it as well as stuff inside it's (build.gradle, AndroidManifest.xml). In settings.gradle I've added 'android-full' to the list. In build.gradle (root directory) I've copy-pasted project(":android") to project(":android-full"). When I'm trying to sync gradle I'm getting an exception:
Error:exception during working with external system:
Full stacktrace from logs here:
http://pastebin.com/T2XUWtYN
A guy from libgdx forums even created github repo with demo project for me (with 2 android subprojects ofc). Gradle works on it without any problem. Here it is: https://github.com/piotr-j/doubledroid
But when I've copy-pasted source code from core/src and android/android-full (without build.gradle) I've immediately got the same exception. I also compared all gradle files with diff checker and they're almost the same (structure is the same as well as version of gradle, I only have more libs).
I use latest android studio (1.4) and gradle 2.4.
I've tried restarting android studio, doing everything again from scratch, deleting .gradle directory, messing in .idea configs and still the same exception, which isn't very informative.
I don't understand how, but I fixed the problem. I just imported it in Eclipse (with gradle plugin). Project appeared without any problem. Then I realized there were fix small bugs in code, cleaned & builded everything again. Then project worked, I closed it and opened Android Studio again. Then it just worked! Some gradle vs android studio bug I guess.

Resources