I installed the android sdk and gradle on Windows 8.1.
It is too slow because the build tool takes too much time.
Can I get rid of gradle?
How else can I make it faster?
There are some thing, which could help a bit:
1) In Settings->Build->Compiler and add Command line options:
--offline --parallel
and VM options:
-Xmx2048m -XX:MaxPermSize=512m- -
2) In the file gradle.properties add line org.gradle.daemon=true
3) Give a try to Genymotion emulator.
4) Move project to SSD disk. Or flash disk - build time can drop to half.
Last option is not to use AS and Gradle at all. Switch to Eclipse (make new project, move res and src files + import all libraries you using, for example NDK is easier to set up there), but it's also not that "heavy" and up to date as AS, so probably not much helpful after all.
Related
I am using Android Studio 3.1 Preview and get an error when I attempt to import some projects:
Cannot Open Project
The length of the project file exceeds the limit of 100 characters
This error occurs whether I am importing cloned projects from github or old projects I have saved with Eclipse. Is there a way to import these projects?
In Android 3.1, if you are running up against the 100 character limit, instead of using Import project (File>New>Import Project), use File>Open, select your project, and then select the OK button.
I am not sure whether import offers some additional functionality beyond forcing you to rethink using long paths of > 100 characters. For my purposes, using the File>Open method allows the selection of projects with long paths and preserves existing directory structures.
I was facing same problem with Android Studio 3.1 in Linux. After some tests I concluded that it considers the FULL path as the project length (from /home/ to Project root), which cant exceed 100 characters.
This warning message is also shown when you try to create a new project.
I didn't found where to customize it. So, as a workaround, check if you can reduce this full path length.
Best Regards
I faced the same issue and solve this by limiting the character size. Try to limit your project name within 15 characters.
For example, if your project directory name like
some-name-of-the-project
then you need to adjust the name within 15 characters
some-name-of-th
I am looking for the setting to increase the length of the project name more than 15 characters.
With Windows environment you could try to create a virtual driver as I'm doing. Use the subst command. For example I have the following giant path:
C:\Users\MyUser\Source\Demos\Android\ud851-exercises\Lesson02-GitHub-Repo-Search\T02.05-Exercise-CreateAsyncTask
Using the command subst E: "C:\Users\MyUser\Source\Demos\Android\ud851-exercises" I can then import into Android Studio using the virtual path
E:\Lesson02-GitHub-Repo-Search\T02.05-Exercise-CreateAsyncTask
It worked for me since I don't want to change anything in the repository's path.
Anyone having this problem, it is simple. In my cases, the project folder is in a multiple stack folder. What I did is, I copy it and paste it directly in D folder.
D:/project-file.
Dont D:/bla/bla-bla/project-file
You get this error if the number of characters in the full path(including the project root from /home or /Users) >= 100.
You can use this command to check: pwd | wc -c
Move your project folder for example into C: and rename the main folder to contains 1 char. It should looks like C:a\android-project
I was facing same issue in android studio 3.1.3,when I change the project directory name to too short.Error clears.
For example, if your project directory name like
Testingandroidsamplesomeprojectname
Change to
Testing
In Android Studio 3.3.2.
I have faced the same issue. Got following solution.
1.Best way to move your project from particular folder to another folder which contains the short path and then import from there.
2.If you don't want to move your project then try to open it by File -> Open. After that it may not build properly. Then just do File -> Re-Import Gradle Project. It will solve your problem.
Android Studio 2.2.3. I've been building an APK for android with my current project with success until very recently. As far as I know, nothing was changed except a data file, and my "Build APK" step mysteriously started failing with this message in the gradle console:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':VrSamples:Native:myproject:Projects:Android:packageDebug'.
> Java heap space
and in my "messages" window I see this error:
Error:Execution failed for task ':VrSamples:Native:myproject:Projects:Android:packageDebug'.
> Java heap space
mple, the following line, in the gradle.properties file, sets the maximum Java heap size to 1,024 MB:
<em>org.gradle.jvmargs=-Xmx1024m</em>
Read Gradle's configuration guide<br>Read about Java's heap size
I've tried many things:
Reset version control to previous version I know was generating APK's fine
Re-clone the entire project in a new location to rule out and intermetiate files that might be pulled in with the .gitignore, to guarantee it's a fresh build
Rebooted my computer
re-installed android studio
Run the clean step, rebuilt, manually deleted intermediate files
Added org.gradle.jvmargs=-Xmx1024m to my gradle.properties file
increased the 1024m to 4096m
manually increased the -Xmx value in both Android Studio\bin\studio.exe.vmoptions and the 64-bit equivalent
I'm puzzled as to why I'm suddenly hitting this issue now, and why I can't seem to be able to re-create the APK's I've been building without problems until recently. As far as I'm aware, I also haven't updated any libraries either.
Would appreciate any suggestions to resolve this issue, tips on how to debug this kind of thing down the road, etc.
Use this in gradle.properties
org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx12800M
org.gradle.configureondemand=true
Worked for me.
I noticed that when I open the gradle.properties folder in my Android Studios project, and hovered over any line, it gave a warning about "unused property". That put me on the path to do another google search for "Android Studio gradle.properties unused property" and I found this:
gradle.properties. Unused property
and this:
JVM arguments gradle cannot be set in gradle.properties file for Android Studio 2.1.1
The issue is that, at least for me, Windows+Android Studio seems to ignore the gradle.properties file in my project. You need to create one here:
C:\Users\<username>\.gradle\gradle.properties
Then, as suggested in other threads such as the one linked to by #Kevin Tan above, I was able to increase the memory by adding a line such as this:
org.gradle.jvmargs=-XX:MaxHeapSize=256m -Xmx256m
Now I no longer hit the issue
By default, Android Studio has a maximum heap size of 1280MB. If you are working on a large project, or your system has a lot of RAM, you can improve performance by increasing the maximum heap size for Android Studio processes, such as the core IDE, Gradle daemon, and Kotlin daemon.
If you use a 64-bit system that has at least 5 GB of RAM, you can also adjust the heap sizes for your project manually. To do so, follow these steps:
Click File > Settings from the menu bar (or Android Studio > Preferences on macOS).
Click Appearance & Behavior > System Settings > Memory Settings.
For more Info click
https://developer.android.com/studio/intro/studio-config
Has anyone tried to work with AOSP using IntelliJ IDEA? I see in Android sources a specific folder (development/ide/intellij) but I cannot find any information how to use it in case of Android development (for Eclipse the information can be found here: http://source.android.com/source/using-eclipse.html) Can anyone provide similar instructions how to start developing Android in IDEA?
Also a good reading here: https://shuhaowu.com/blog/setting_up_intellij_with_aosp_development.html
If you get
Couldn't find idegen.jar. Please run make first.
You'll need to generate it first:
source build/envsetup.sh
cd development/tools/idegen
mm
croot
development/tools/idegen/idegen.sh
Be prepared that AOSP files indexing in IJ takes long time (more than 1 hour on my notebook with an SSD on board), a reason to use Eclipse, as I believe it doesn't need to build indexes so loads AOSP code much faster.
It's worth reducing android.iml file with removing AOSP parts you are not interested in. You can add them to development/tools/idegen/excluded-paths via a regular expression pattern, see README file there.
I added following lines to excluded-paths:
^cts
^developers
^development
^external
.*/tests/.*
^sdk
so my android.iml got quite moderate size and loads in about 1-2 minutes instead.
idegen has also intellij-gen.sh which can generate IJ project for given module.
As mentioned in the article above, you can tweak IJ to work faster (add more RAM, etc). Here goes my idea64.vmoptions just in case:
-server
-Xms2048m
-Xmx4096m
-XX:MaxPermSize=1024M
-XX:ReservedCodeCacheSize=1024M
-XX:+UseCodeCacheFlushing
-XX:+UseCompressedOops
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC
-XX:ParallelGCThreads=8
-XX:+AggressiveOpts
-XX:+CMSClassUnloadingEnabled
-XX:+CMSIncrementalMode
-XX:+CMSIncrementalPacing
-XX:CMSIncrementalDutyCycleMin=0
-XX:-TraceClassUnloading
-XX:+TieredCompilation
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djsse.enableSNIExtension=false
You can google idea.vmoptions optimization, there are some posts about it (and where I took my IJ config from)
From AOSP root folder,
1) First build your target. That will generate whatever java files that need to be generated during aosp build.
2) Create a shadow dir of aosp dir using lndir.
Assuming your aosp dir is ~john/work/aosp/ics.
Then create ~/john/work/aosp/icsshadow
Cd to icsshadow and invoke "lndir ../ics". That will create symlinks to everything under ics.
3) Now you use icsshadow for all the stuff your IDE needs/generates. If you use ics folder, the aosp build some times fails if the IDE generates any build artifacts.
4) cd to icsshadow directory.
Invoke development/tools/idegen/idegen.sh
Wait until it is done.
5) If you want to use IntelliJ, open android.ipr from icsshadow folder. If you want to use Eclipse, Please check Using Eclipse to edit/browse AOSP code.
Official instructions can be found by going to development/tools/idegen path and checking the README file. It's a good idea to read it yourself. This is the content for IntelliJ:
If you're using IntelliJ...
If this is your first time using IDEGen...
IDEA needs a lot of memory. Add "-Xms748m -Xmx748m" to your VM options
in "IDEA_HOME/bin/idea.vmoptions" on Linux or
"IntelliJ IDEA.app/Contents/Info.plist" on OS X.
Create a JDK configuration named "1.6 (No Libraries)" by adding a new
JDK like you normally would and then removing all of the jar entries
under the "Classpath" tab. This will ensure that you only get access to
Android's core libraries and not those from your desktop VM.
From the project's root directory...
Repeat these steps after each sync...
1) make (to produce generated .java source)
2) development/tools/idegen/idegen.sh
3) Open android.ipr in IntelliJ. If you already have the project open,
hit the sync button in IntelliJ, and it will automatically detect the
updated configuration.
If you get unexpected compilation errors from IntelliJ, try running
"Build -> Rebuild Project". Sometimes IntelliJ gets confused after the
project changes significantly.
The following error message might pop up when following the instructions.
Couldn't find idegen.jar. Please run make first.
You can fix the error message by reading here: https://www.protechtraining.com/blog/post/860?ncr=1
Run the below command from the Android source root directory.
make idegen -j4 && development/tools/idegen/idegen.sh
Then launch IntelliJ idea, and select the .ipr file generated. Then on the next screen select the .ipr based project property.
Works for me and better than using the android studio, because there is an annoying background scan all the time with the android studio.
I have an android application that only has one jar import which is 4 mb in size (Symja https://code.google.com/p/symja/) Literally the only code in the project is creating a new textview and setting it as the content view. But I am getting the error(s):
Conversion to Dalvik format failed: Unable to execute dex: Java heap space
Unable to execute dex: Java heap space
I have another android project which is alot bigger, almost 20,000 lines of code and it runs in seconds. My eclipse.ini has the following settings:
-Dosgi.requiredJavaVersion=1.5
-XX:MaxPermSize=512m
-Xms512m
-Xmx1024m
I do not know why I cannot run this project. So any suggestions are greatly appreciated!
Thanks.
Try the following:
Right click your project. Go to Properties -> Java Build Path -> Order and Export.
Uncheck the check box against your included library. Press OK and run the project.
On doing this Eclipse will take only the classes which are needed in the code, from the jar instead of storing all the classes from the jar.
I read, that symja library needs Java version 1.6. But your Eclipse uses Java 1.5. Maybe, it's a problem.
Modify the -XmsAm and -XmxBm paremeters in eclipse.ini so that they are large enough. The default is -Xms40m -Xmx384m. Try changing them both to -Xms512m -Xmx512m and restart eclipse to see if that helps. If not, continue to increase the values and restart eclipse until either one of two things happens:
Your build completes.
Eclipse won't restart because you don't have enough memory.
eclipse.ini is located at /etc/eclipse.ini in Ubuntu (assuming you installed Eclipse from the Ubuntu repositories).
My eclipse workspace has just one android project in it and is set to "build automatically". Every time I make a change to some code, and save the change, the workspace builds. Initially this is fine, but at some point the builds start to take about 5 seconds for every change. At this point, I create a new workspace and import the project, and everything works great for a while (days or weeks), but inevitably it slows down again. Has anyone else experienced this and/or have a solution?
You can try in Eclipse:
Window - > Preferences - > Android -> Build -> Skip packaging and dexing export or launch.(Speeds up automatic builds on file save)
And
UnMark : Project - > Build Automatically
And you can also complete with :
Window - > Preferences - > General -> Workspace - > Linked Resource - Enable linked resource (unmark) try only if your project not have resources from other project.
For me stoped building slow process after every save.
Under top menu item Project->Build Automatically
uncheck the option, then you'll have to build project manually before testing, just select Project->Build Project then Run after build completes.
Increasing Xms and Xmx parameters in eclipse.ini worked for me:
Original values:
-Xms40m
-Xmx768m
New values:
-Xms256m
-Xmx1024m
Does it help if you clean your project (menu 'project'-> clean) and does that help?
This might be something that's a part of the slowness, although it doesn't explain why it's quick after a new import, and then slows down: Android compilation is slow (using Eclipse)
Removing the device from USB & then re-connect.