I've been developing an app for a while and now I want to hand it out to friends for testing. The app works perfectly when debugging to my device but when I build and sign the apk and move it to my device I can install it without any errors but it will not run (I don't even get any error messages). Sometimes the screen goes black as if the app is about to start but then it just reverts back to the previous screen (One time the Monogame splash screen appeared before it reverted to the previous screen).
Here is what I have done so far and any specific details:
I'm using Visual Studio Professional 2014 with Xamarin.Android 4.20.
I'm creating my app using MonoGame.
I have cleaned and built my app in Release mode.
These are my packaging options:
These are my linker options:
(I believe choosing "None" only means my apk will be larger).
I created a keystore using Java's keytool.
I created and signed the apk using Xamarin's Visual Studio "Publish" command.
After all of this the apk will still not run.
So it turns out this was nothing to do with the signing or building of the release mode apk, it was actually down to an exception which was only being thrown when the app was built in release mode (I have no idea why this was the case).
The thing that was throwing the exception was the DotNetZip library, I'd post an issue on it's page but it looks like the project is dead anyway (Also, they don't explicitly support Xamarin Android).
My solution was to use ZipStorer alongside Mono's .Net compression implementation. Everything works nicely now.
Related
I'm using Visual Studio mac for developing Xamarin, recently I released my Android app but a rare behave happened! Releasing app popped out 2 files named app.apk and app-Signed.apk and I think the 2nd one should be the one I should upload to Google Play store (am I right?), but after opening it on my device I found out many changes that was appearing in debug app are not exist in Singned one! while app.apk is OK with changes I applied to app.
Is app.apk in debug mode?
What should be app-Signed.apk and why it has this problem and how can I fix it (if answer to #1 is true)?
Sometimes Visual Studio Mac for some reason does that. Remove obj and bin folder from a project directory, and then build again. If that happens again (2 files) the odd thing that you need to upload to google play non signed one.
I used to test my Android apps (min API 21, target 25) in an API 21 AVD. After clicking the "run app" button in Android Studio, a debug APK was built in {project}/app/build/outputs/apk/. I then copied that APK to my physical API 25 device for further testing.
Since upgrading Android Studio from 2.2.3.0.145.3537739 to 2.3.0.8.162.3764568 on Gentoo Linux, those autogenerated APKs no longer run on the physical device. The apps crash instantly upon startup and the log shows a "java.lang.RuntimeException: Unable to instantiate activity" caused by a "java.lang.ClassNotFoundException: Didn't find class {my main activity class}".
When I build a debug APK manually by clicking on "Build > Build APK", the generated APK has a different file size than the autogenerated one, plus it runs on the physical device without any complaints.
So, there are actually two questions:
1. Why does the manually generated debug APK differ from the autogenerated one?
2. What is causing the autogenerated one to fail on my physical device since Android Studio 2.3? It worked fine with all Studio versions before.
Hoping for some insight, even though USB debugging exists and the process of copying the debug APK to the device is actually pretty pointless. :-)
As a recap of the comments to the question, if Instant Run is enabled then generated debug apk will contain device API specific code hence rendering it not usable on other APIs that it was not built for. Turning off the Instant Run would solve that.
I need to debug a new version of an Adobe Air app on Android. This has to be not a "clean install", but an actual update so that all the data is preserved from the previous version. Debugging from Animate CC (formerly Flash Professional) automatically deletes the app and data. Is there a way circumvent that?
Make sure the app version is higher, export apk and manually install the apk on the device without animate cc.
That works for release builds, debug builds im not sure give it a shot
I'm running the latest version of Android Studio (2.2 Preview 1) that was just released and trying to take advantage of some of the new tools.
The new APK Analyzer is very useful but I can't get it to work with debug builds, it only seems to be accurate for release builds.
Here is a screenshot of what the release build looks like, as you can see the method count looks accurate and all the android libraries that I am using are included.
Now, if I pull in the debug build of the same application it looks totally different. All of my application code is missing, as well as all the third party libraries. And you can see that the method count has also been reduced dramatically.
So am I doing something wrong here? How can I get this analyzation to take place on my debug builds as well?
Note via James Lau on G+:
tool was designed to help you understand and reduce the size of your
release APK, since that is what you publish. As such, you probably
want to run it on your Release APK. You can leave Instant Run turned
on for building Release APK as Instant Run only works on Debug.
Are you sure you have a complete debug build and not a APK file for an HOT or WARM SWAP?
Android Studio since 2.0 has a feature called "Instant Run" that allows to create some sort of "delta-APKs" for updating an app on-device after you made some small changes. The advantage is that you don't have to execute a full gradle build process and therefore such a HOT SWAP is much faster.
Those special HOT/WARM SWAP APKs include only the changes you made recently and some additional code for merging the created APK into the existing APK on-device.
Therefore you should try to execute "Rebuild project" or "Clean project" and see if the created debug APK is as you expect.
Now that my android app is released on the google app store, I would like to continue developing and debugging on the device.
I have a few options:
Delete the app from the device and install a new version during development.
This has disadvantages. I lose the local files saved with the released app, and, when the time comes for the next release, I do not share the same experience as my users while upgrading.
Introduce a minimal change by, say, renaming the package. The two apps are now distinct and can co-exist on the device.
This introduces a superfluous change in the souce tree, with all the headaches that that entails.
If you have avoided these difficulties, what approach have you taken when you continued to develop after release?
I recommend switching to Android Studio and Gradle. Using build types (which I can't link to because I am a n00b and have no reputation), you can easily switch between debug and release builds, and set up your build file to have both on your device at the same time without changing anything in your source or manifest.
The one big gotcha that I failed to understand and bit me in the butt several times until I got it is that in the Build Variants tool window, the selected build variant controls everything. If you choose the release variant:
when you build, it will build an APK with your release keys (if you've set them up in the build files)
when you run the app, it will put the release version on your device
if you try to debug the app, the debugger will not attach because the app is not debuggable
And of course all the reverse if you select the debug build variant.
You have to give up Eclipse, which if you're like me is a sad thing, but I've heard they're planning to add Gradle support to Eclipse at some point.