I have Eclipse with Android set up. The problem is when ever I run a project from eclipse to test it, the application never launches and the emulator never shows up. Even though the launching progress bar shows 100%.
Make sure the AVD's memory is set to 512, if it's higher the emulator will get a memory heap error and fail. Also try to enable verbose output when building, this can be set from within the properties.
Do you have a device attached? Eclipse switches to mobile devices automatically
I had once or twice had such problem. Restart of eclipse worked for me. And Yes also check the Run configuration, make sure your project is linked with emulator.
Go to Window->Preferences->Android->Build and select verbose build output
Now run your project and check Android console. In my case there were thousands of
"Dx processing %classname%..." which took several minutes to finish.
Just to make it clear: dx.bat is an ADT utility program, it converts multiple Java class-files to single "classes.dex" file(Dalvik executable file).
I had a project which used several libraries with lot of classes and the compilation was very fast(several seconds), but the launching was quite slow(2-4 minutes).
Then I found out that the most time consuming part was converting class files from my project and from all third-party libraries to *.dex file(the resulting size of dex-file was about 4 Mb). As far as I know, it's impossible to attach libraries to android project without dexing their class-files, so you have to be patient during launching your project.
UPD: It's possible to strip all unused code from your application.
Please check this link: Always running proguard before Android dex'ing in Eclipse
Related
I know how to enable MultiDex support, but my problem is the opposite.
Seems like my Android Studio's MultiDex option is enabled by default for some reason.
When I unziped the resulting APK file and checked inside, there were two files.
classes.dex and classes2.dex.
You may say my project may hit 64K limit, but no, it doesn't.
I also tried without any dependencies and with some other gradle settings,
but the result was all the same.
I even put the line multiDexEnabled false, but it didn't help either.
So this time I created another new empty project, and hit the Run button without any modification.
Result? Same.
As you can see, I have two .dex files with very low references.
I don't understand what's happening here..
The reason why I'm trying to disable MultiDex is,
First, my app is really simple with a few dependencies so just don't need it.
Second, the app needs to support even older Android OS.
Third, I want to avoid the Dalvik linearAlloc limitation in the old Android devices.
Finally, I want to know the exact cause of this.
One more fun fact.
I decompiled and looked into the the apk file, and couldn't find the class named MainActivity which was created by default while the app ran on my phone as expected.
The same is true for my real project. The app works well but there isn't my code in the classes*.dex. Yeah, it's fine if the app works without any problem, but it's somewhat annoying because I sometimes want to decompile and see the resulted code.
Things like Instant Run change the nature of the APK. What you get when you run the app from the IDE is different than what you get when you build the app by other means (Build APK(s) in the menu, gradle tasks, etc.).
This is one of the reason why I disable Instant Run, as I'm one of those crazy people who wants to run the same app that my users would run.
Android Studio 3.0 makes another change to the APK, compared to what your users will run: it adds android:testOnly="true", preventing that APK from being installed normally. Probably this is a safety measure, so that you only distribute APKs made through some other build mechanism.
In your case, based on the comments, it appears that Instant Run was what was causing the multidex-style behavior. That may be tied to how Instant Run attempts to patch an already-installed APK, rather than push the fresh APK to the device or emulator.
So, either disable Instant Run or don't analyze the Run output, but instead focus on APKs built by other means.
Android Studio not executes the IDE, it only shows the splash screen, after few seconds, it dissapears.
I tried the following solutions:
I uninstalled the program and installed again
I restarted my PC after installation
I added "JAVA_HOME" and "JDK_HOME" as environment variables
I checked if "studio.exe" process is executing, if IDE is executing in background.
I executed Android Studio as "Administrator"
I disabled Antivirus temporarily
I deleted ".android", ".AndroidStudio", ".gradle", ... folders
These solutions not worked.
Which is the problem with execution?
If you have done this:
do you have installed the JAVA SDK donwload the latest release from here!
be sure to have configured the JAVA_HOME and JDK_HOME in your environmet variables.
then check the .log file generated by Android Studio to get more information about your issue:
C:\Users[MyUser].AndroidStudio1.2\system\log\idea.log
I recently experienced this issue as well.
It was related to me having dual monitors and oddly the secondary screen was not able to load android studio.
In my setup the issue resolved itself once the secondary screen was made the primary screen ( I have an ATI graphic card 8300) with Android Studio 2.3 and Canary build 3.x
This is typicaly a low memory problem. I currently have the same and I was able to make few correlations. If you start your task manager, you will notice that "Disk" goes to ceiling when starting Android Studio. Actually, you will surely notice that it goes more often to 100% that you'd expect and Android Studio is just the perfect vector to observe this, since it consumes a lot of resources.
The annoying part of the answer is that this "Disk 100%" bug on windows 8.1 is really widespread and solutions doesn't seem that straightforward. For the record, if I find my cause (or if I'm all wrong in my hypothesis), I'll keep you posted.
Regards
I recently switched from Eclipse to Android Studio because I read that it is now the official IDE for Android application development. I downloaded and installed the latest version (1.0.2) for Windows. When using the program for the first time, I decided to create a test application to see if the program was working correctly. Unfortunately, it was not. Once I clicked the finish button to complete the New Project Wizard, A loading bar showed up that said Gradle: Build. This is where the program gets stuck. There is no error message and it appears that the program is running fine, however the build never actually completes. I am never given my MainActivity.Java class, or my activitymain.xml document. If I click the cancel button, the program freezes and I have to use the TaskManager to kill the program. If I re-enter the program and choose to open an existing project, my project will be there. However, upon trying to open the project, I am greeted with the same Gradle: Build loading bar.. I have been searching for an answer for the last 3 days and nothing has worked. Any help is greatly appreciated!
Things I have tried:
Simply letting the program sit for a while to see if it was actually downloading something and was just really slow. I let it sit for 45+ minutes before killing the program.
Uninstalling and re-installing Android Studio
Restarting my computer
Turning off my firewall (Kaspersky)
Running the program as an administrator
Connecting to a different network
Disconnecting my computer from any networks (to force the program to build in offline mode)
Manually downloading Gradle from the link that Android Studio attempts to use when it gets stuck and telling the program to use that file instead of downloading another one.
(I went to this link https://services.gradle.org/distributions/gradle-2.2.1-all.zip, downloaded the file, unzipped it, went to Gradle settings in Android Studio, checked the Offline work checkbox, and finally set the service directory path to my unzipped Gradle folder.)
Hopefully I have given enough information and made it clear what my problem is. If not please tell me what else I need to explain so I can get this issue resolved. Thanks!
Please note I am working on a 64 bit machine running Windows 8. Also, I use studio64.exe
to run the program.
From the discussion we had in the comments, it does not look like you have your gradle on your windows path.
Please change the below to point to your gradle install:
set GRADLE_HOME=C:\<installation location>\gradle-1.11
set PATH=%PATH%;%GRADLE_HOME%\bin
After this, verify that in the terminal running the following works:
gradle tasks
once you get this working, you will want to run the following in your project:
gradle wrapper
This will produce a .bat file which you can then use to run gradle through the wrapper, letting you support multiple native gradle installations.
I recently started to use Android Studio and while I like it a lot, there is one thing that annoys me a lot:
Gradle - it's nice tool and all, but damn it's such a resource hog, also it's just so painfully slow. No matter if I use my 5 years old laptop or my gaming PC, when it's running, other applications go to a full stop (well almost)...
Is there really a reason for a build tool to be so demanding??? I understand compilation can be a slow process but from my experience javac always seemed to be blazingly fast, so it cannot be source of a problem (also building Android apps with ADT was many times faster too)...
So is there something wrong with my configuration? Can I make Gradle run faster?
Create a gradle.properties file either in your project root directory or your ~/.gradle directory with the following line:
org.gradle.daemon=true
From the Gradle manual:
The Daemon is a long-lived process, so not only are we able to avoid the cost of JVM startup for every build, but we are able to cache information about project structure, files, tasks, and more in memory
Also, you can go to File > Power Save Mode if you want to turn off continuous building in Android Studio.
The following situation will surely be familiar to any Android developer using Eclipse and ADT.
I'm tired of this endless cycle of switching Build Automatically on and off, running Clean, building and running. I'm constantly doing all of these operations when I'm fine tuning UI (i.e., editing XML files and needing to see the results live), and any time I save, an Eclipse window telling me I have these pending operations shows up. When that happens, I turn off Build Automatically. I do my alterations and then run. Sometimes Eclipse decides the changes in the XML file weren't enough, and it won't reinstall the app in the emulator or device, so I force a build and install.
All of this is just wasted time. I've already done an AppleScript to build & run my app into all the emulators and devices I have connected at once, described in this SO question, but my workflow could be much improved if I found a way to save and build silently and fast.
Does anyone have any tips or alternatives?
IntelliJIdea Community Edition now supports Android
Have you tried the bundle for Textmate? It's pretty cool. It's basic but its got all the features you need. Building, Deployment and integration with AVD and Logcat.
I use this for all my Android Dev now as I found Eclipse painfully slow.