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.
Related
This is the repository that demonstrates this issue.
This is simple standard project with one page. I created the archive for publishing (release mode).
If I use the "AOT compile" option, I get the error:
"Apk failed to install Error:could not parse error string"
If I disable this option, then the APK works.
To use my test project, update the option AndroidSigningKeyStore in ApkSignerIssue.Android.csproj to point to file test.keystore in the folder test.
I'm on Windows 10 and I'm using Android Api 26. If I try Api 25, it does not work. I've tried using VS 15.5.7 and 15.8.0(preview) with "AOT compile" and neither of those work.
Without this option, XF+Android can not be used; the first load of the app will take 8-10 seconds.
It worked earlier, but now I can not build a package to release an update to my application.
Downgrade to 15.5.7 working for me now.
I do not know why this did not work right away, maybe I rebooted the computer. but now it works.
That's good - I was able to release an update my app.
And this is very sad - this is my fourth Downgrade in three months(starting from 15.6).
Archiving the package does not work normally three months, three months, Karl!
I lost a lot of time.
When I install my application in debug mode, and open it for the first time it takes a lot of time (nearly 20-30 seconds). I guess it is due to multi dex enabled. It is happening after updating my Android Studio to version 2.0 and upgrding the android gradle plugin to version '2.0.0'. What is the reason for this behaviour? Is somebody else also facing similar issues?
I have been testing on Moto G3 with android marshmallow.
This happens most of the time because of the prolonged time needed to build the solution. The time needed to build a solution is mostly dependent on the number of libraries you are referencing, and the complexity of your code.
Remember that it is the first time you are building the app, so Android Studio has no record of the solution in its cache, hence it has to build everything from scratch.
Android Studio 2.0 also has the instant run feature, so it takes longer to run the first time, so that you can then debug instantly in the subsequent runs.
Hope this helps :)
I think is because of the new Instant Run feature. The first time takes a lot of time, but after that new changes are visible almost at the same time in your device.
In any case you can disable Instant Run in: File->Settings->Build,Execution,Deployment->Instant Run
There is an issue with multidex and API level 21+, relative to Instant Run. The documentation only mentions it without explanation though.
Instant Run
Settings/Preferences(Mac) → Build, Execution, Deployment → Instant Run and uncheck Instant Run
I was also facing the same problem and finally i fixed this.
note: 1) before generating an apk file unchecked all these option to resolve delay issue from your production build.
2) while you are developing or adding new features then keep it as default setting(instant run) to make development faster.
I hope this will resolve your issue.
I'm quite new to Maven.
Before using Maven, I had only two main single click buttons (and keys) that I've used: run and debug. Of course I have others, but those are things that I use a lot.
Now that I need to use Maven, I use some special commands. For updating the dependencies, compiling and running on the device/emulator, I use:
clean install android:deploy android:run
However, this also uninstalls the previous app.
For debugging, sadly I do what is written here (which doesn't allow debugging from the beginning, plus it has many more steps), or use Debug.waitForDebugger() (which requires me to change to code each time for toggling run and debug modes).
How can I have the same functionality of running and debuggsing as the normal ADT plugin?
Edit: about the uninstallation issue, the answer would be to set undeployBeforeDeploy to false instead of true.
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
I have been quite interested in developing an application for my Android device. I downloaded the all the required tools for VS2010 following this guide - http://mono-android.net/Installation/Visual_Studio and everything went pretty smoothly.
Now, the first time I ran the default application and it copied everything to the emulator, it ran perfectly. If I make a simple change to the application and hit F5 to redeploy - it starts the app, but it seems to have the old version on there still and doesn't show my changes. I've cleaned the solution and rebuilt the application, so I don't think its that. I've also completely changed the code (just in case it was something I was doing wrong), but that didn't work either. Oh and the build also succeeds!
Now the Emulator seems a bit flaky and slow...but is it something that I am doing? Is there somewhere I need to clear before hitting F5?
When it is doing the deploy, does it say "Uninstalling the previous version"?
Another thing to try is to manually remove the app from the emulator (Settings -> Applications -> Manage Applications -> -> Uninstall. Then deploy again and see if the new version is copying. This should narrow down if it's a deployment issue or a build issue.