Android application apk - android

When I install my application on device using Eclipse, my app works as expected.
Then in Eclipse I export signed app using platform tools. However, when I install this signed apk file using adb in shell or by opening link to apk in internet it does not work as expected. It launches and runs, but some functionality does not work. The app just crushes.
What am I missing?

A signed build usually goes through a Proguard step. In your app's project.properties file, there's probably an entry that looks like:
proguard.config=proguard.cfg
or
proguard.config=proguard-project.txt
The file after the equals sign contains the Proguard configuration, which, amongst other things, defines rules for what parts of your Java code may be optimized, obfuscated and stripped. You can customize the configuration to make it keep certain elements for which Proguard couldn't automatically determine the correct dependencies. Quite commonly this involves code that is dynamically loaded at runtime, e.g. through reflection. Alternatively, you could disable the Proguard step by putting a dash (#) in front of the relevant line above.

Related

Pro Guard for a basic application : android

I have made my first application for android. It does nothing much just stores some user specified data in SQLiteDatabase and manages it. Now, the app requires no special permission. And while reading the guidelines for publishing it, I came across Pro-Guard. On researching it and reading the developer page on it, I am not able to understand that do I also for a basic app need to set up this pro guard file. I already have a proguard-project.txt in my application folder. It does not have a code, but normal English sentences. What should I do ?
In the project.properties file you can enable Proguard by uncommenting the line that says proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt.
Note:
When you build your application in release mode, either by running ant release or by using the Export Wizard in Eclipse, the build system automatically checks to see if the proguard.config property is set. If it is, ProGuard automatically processes the application's bytecode before packaging everything into an .apk file. Building in debug mode does not invoke ProGuard, because it makes debugging more cumbersome.
This is the documentation.

Ludei Android App requires unnecessary permissions

I use construct 2 to build my apps and then I export them to CocoonJS which then compiles them as a native app. I download an unsigned .apk file, sign it then upload it Google Play. The apps work great, just like they were natively written.
When I compile my app with CocoonJS it requires all of these permissions that my app doesn't need. How can I remove the unneeded permissions?
Until Ludei implement an optional permissions on their cloud compiler, we have to do a bit of "hacking" to fix the problem ourselves.
Get the attached apktool.zip, extract it to a folder C:\Android (to make it easier later).
https://static3.scirra.net/uploads/articles/1071/apktool.zip
Copy your release CJS compiled game.apk (from herein, referring to that APK file as game.apk) into C:\Android so its in the same folder as the extracted apktool files.
Open command prompt in C:\Android by right clicking somewhere in that folder while holding SHIFT key.
First, we need to install the framework of our CJS compiled game.apk, type this in:
apktool if game.apk
Its instant, with a feedback that it installed in location 127 or thereabouts. Now we have to decompile the APK, type this in:
apktool d game.apk game
It take awhile depending the size of your game & speed of your PC, but all the contents of your game.apk will be decompiled and stored in a subfolder with the same name as your game.apk, ie. game. Note, if you use different versions of apktool, you may need to change the flag to: apktool d game.apk -o game so it decompiles properly.
Browse the new game subfolder, you will see all the contents. What we are after is the AndroidManifest.xml, open it with Notepad++
Hi-res version: halfgeekstudios.files.wordpress.com/2014/07/androidmanifest.jpg
Remove the permissions by deleting the grey highlighted lines!
The permissions ACCESS_NETWORK_STATE & INTERNET are required, if you remove it, your game is likely to crash on startup. This is true even if you have no Ads or IAPs or Social plugins. CJS needs these since its got some built in analytics that require it. BILLING is also required if you implement IAPs. Interestingly, Google has decided that these three aforementioned permissions will now be considered normal and they do not warn users when games have these three only, only if it contains the other permissions!
Here, I'd like to point out this line:
You can edit your game to be on phones or tablets by setting them to false. If you set smallScreens & normalScreens ="false", the game is only compatible with tablets or vice versa (I've tested this with my own games). This is handy if you design your target to tablets and don't want to manually filter over 6,400 devices, one at a time. :D
Once the changes are done, save it. Go back to the command prompt, type this in to recompile it into a new APK:
apktool b game game_new.apk
Takes awhile, but you will get your game_new.apk that is modified. Now you need to proceed with normal signing and zip aligning prior to uploading to Google Play.
https://www.scirra.com/tutorials/1071/removing-permissions-from-cocoonjs-compiled-apk
You cannot remove it. Try other tools like Phonegap. phonegap

Where do I find Androidmanifest.xml on my device?

I'm trying to modify the Androidmanifest.xml for the browser on my device so that I can execute an app by loading a URI in the browser.
I've been running around the file system in ADB SHELL all day, but can't seem to find it. Plus there is no FIND, nor LOCATE command on the system.
You can theoretically find the Androidmanifest.xml file in the APK.
Every APK contains the compiled source code of the application. There is no useable decompiler for APKs at the moment so it is not possible to change the content of one.
In addition to the compiled code and the other resources of the application, an APK also contains a signature from the developer, which will become invalid when the content is changed to verify the source of an APK. An Android system won't install an APK with an invalid signature, so even if you could change the content of the APK, you still couldn't use it.
The conclusion: You cannot do what you are trying to do.
Android Studio on Windows 10/11, it’s in: app/src/main.

Can an APK be repacked after a minor text edit?

I'm creating a software that will guide the user through a few steps, to publish an android application (APK file).
The way I am doing this, is that the APK file is already compiled, and all I need to do is replace an XML file in the package, and that will change the behaviour of the application. My big problem now, is that unpacking the apk file, and doing any tiny text edit, and then packing it again, breaks the signature and prevents the application from running on any device, giving a message that the signature is incorrect.
How can I solve this? I want to safely open the APK, write something in a text file, and close it again. Note that this operation will be done on the user's computer (after he purchases our application) so we're look for a command-line tool with no special requirements like JDK.
Any help?
Ok I reached the best "tested" solution - I'm posting it here to save other developers hours of googling. The only downside is that I will require the customer to install JDK on his machine, unfortunately. The reason is because I did not find any apk-signing tool that works purely on windows, without relying on JDK.
I have my android application created using Air, so this makes things easy for me - all of the air files are treated as resource assets. So have your APK archive file ready.
Once you have your modifications ready, put them inside a temporary folder named "assets". You will use the 7-zip command line tool (free: http://sourceforge.net/projects/sevenzip/) to update the contents of your apk. To have it working with your apk you will have to rename your apk's extension to zip - don't worry, you'll change it back later.
Now from a .bat file (or directly in the command prompt) from the location containing both your apk file (zip extensioned) and your assets folder, you'll call: 7za u APK-file.zip assets
Now your apk file is updated. Rename it back to .apk extension
Now you'll use the signAPK tool from here https://code.google.com/p/signapk/ and note that this is the only step requiring JDK installed. It also assumes that you have your key files ready (replace the dummy ones included in the package). Extract the file contents and call: java -jar signapk.jar key.x509.pem key.pk8 [android_app].apk [signed_android_app].apk
At the very end, you may find your signed apk file size drammatically increased. So you need to use the android's zipAlign tool: (darn, can't post the link since new users can only post a maximum of two hyperlinks)
you will be calling the command: zipAlign -c 4 [signed_android_app].apk
And voila! That's the route I'm taking.
If someone finds a way to do the signing process without relying on JDK (assuming the key files are ready) please share.
How can I solve this?
You don't. If you modify an APK file, by any means, it must be re-signed.
Android apk files must be signed. That signature proves that the contents of the apk have NOT BEEN MODIFIED from what was initially published. (Which is exactly what you are doing.) The signature at the same time, also proves who the author is.
So in a normal signed apk file:
You know who the author is. (Even if it's not something you as a human can understand.)
You know the contents were put there by the author, and not modified since.
This is a key security measure built into Android, is there for very good reason, and cannot be overcome. It prevents things like viruses from being embedded inside innocent apk files.

How can I build multiple Android app builds for beta testers and for the Market?

I would like to produce 2 builds of my Android app:
one build which will be as close as possible to what ends up on the Android Market when I release it, and which will be distributed to testers who do not work at my company
one build which will be tested internally by programmers at my company. This will be very similar to the other build, but will have some extra functionality, like being able to configure (at runtime) which server environment it talks to
Is there an easy way to modify my build to build both these artifacts? If I could just set a single variable's value to something passed in on the command line during the build, I could dispatch on that value in different parts of the app for different behavior. However, I'm not sure that's the best way to do this, nor do I know a good way of getting that into my code.
I'm using the off the shelf build.xml file that Android produced for me right now.
Thanks!
When you have an automatic build chain (i.e. running everything through ant), you can create one java file that contains that variable from the ant run.
And here you can set the variable depending on the target environment. The build will then compile that file with all others and package it up.
It may be possible to also have a replace task in ant, that takes an existing file and just replaces a token ##var## with the variable content.

Categories

Resources