Error when parsing a custom apk file - android

I started to look into Android programming today and created a very small app that is supposed to play MP3s. The tools I used where the Android SDK and eclipse. The code executed flawlessly in the Android emulator but after exporting it and attempting to install the apk on my Samsung Galaxy S2 I received a message telling me there was an error when parsing the file.
Here is my phone's configuration: Android v2.3.3, installation from unknown sources = allowed, USB-Debugging = enabled. The target system for my project has been set to Android v2.3.3 as well and the CPU architecture of the AVD has been set to ARM (armeabi).
I signed the apk using a custom keystone when exporting it, as I initially thought the problem might be a debug key which wouldn't work on real devices.
I attempted to install the app using both, the internal file explorer and a custom explorer (ES File Explorer) but it didn't work for.
Suggestions on how to make my phone execute my custom apps would be highly appreciated. :)

First, since it's complaining about the .apk file, try opening the .apk file by renaming the extension to .zip. If you can rename the file, and open it normally in Windows Explorer, then that should indicate the file itself isn't corrupt.
Secondly, I would try installing by connecting your device via usb and using the command adb -d install "path-to-your-apk-file.apk". If this doesn't work, hopefully adb will spit out something more descriptive, and you can update your question with the error.

I found the answer to the parsing error on custom apk files here. Removing the required API level tag android:minSdkVersion in AndroidManifest.xml solved the problem.

Related

Is it possible to Install Android Package (.apk) on the emulator without access to sources?

I think the answer is No but I’m not 100% sure as I’m a newbie with Android SDK.
So, I downloaded adt-bundle-linux-x86-20140702 to my CentOS 6.5 machine. Following the documentation, I was able to create an AVD using ‘AVD Manager’ interface (using the eclipse binary).
I’m able to view my AVD that I created by running emulator -avd <name>.
I have a .apk file which I didn’t build but downloaded from a website (I don’t have the source code). If I would like to load this .apk into my emulator to see how it works, is it something that’s doable? If yes, may I know the steps please?
Many thanks in advance.
Update:
Following this link, I tried:
adb install /path/to/my.apk
which returns,
“failed to copy ‘/path/to/my.apk’ to ‘/data/local/tmp/my.apk’: No such file or directory”
I also tried copying /path/to/my.apk to the directory where adb is located. I created a /data/local/tmp directory as well with the same result. Perhaps, it’s looking for /data/local/tmp on the AVD (?). Not even sure if it is a compatible issue with the device/target/cpu configured on my AVD ..
Appreciate any help.

Remove Phone application from Android emulator?

How do I (forcibly) remove the stock android Phone application from the emulator instance?
I would especially like answers from people who have actually successfully removed the Phone application.
Removing the Phone application probably also necessitates removing the Contacts application, as they are tightly integrated, that is fine.
Solution
After much research it seems the only solution is to rebuild the Android SDK from source, as Maciej Pigulski answered.
After fetching the android source, remove Phone and Contacts from the Android makefile build/target/product/core.mk. And build the SDK as usual, i.e.:
. build/envsetup.sh
lunch generic-eng
make sdk
And in out/host/linux-x86/sdk you will have a zip file containg a fresh new sdk ready for use in e.g. Eclipse.
I successfully remove Phone apps WITHOUT rebuilding the SDK (very long op...)
You can edit you system.img in your SDK (located for ex : ~/android-sdk-linux_x86/platforms/android-10/images/system.img) corresponding to the system part of your emulator ( Phone apos is located at /system/apps/Phone.apk)
I launched the emulator, connect with adb to the emulator shell. I removed the packaged /system/apps/Phone.pak after remounting the system partition with read/write option ( mount -o rw,remount /system /system )
I push into my emulator the mkfs.yaffs2 tools compiled for arm found here (http://code.google.com/p/android-group-korea/downloads/detail?name=mkfs.yaffs2.arm)
use this tools to recreate my system.img in my emulator shell:
mkfs.yaffs2 /system /sdcard/system.img
pull the /sdcard/system.img into my PC. Replace the system.img of the emulator (~/android-sdk-linux_x86/platforms/android-10/images/system.img) and restart the emulator.
The Phone app is Gone!
I have an idea how this could be done but this is not an easy way.
It requires source code of the Android OS you need an emulator for. Then in the make files you can disable including of the Phone application to the output image and build the OS with 'make sdk' task. This will produce an SDK (like ones available from the Google site) with the binaries that has Phone application excluded. Then when you will create an emulator with this SDK it wont have the Phone.apk.
Painful but if you really need it, give it a try.
If you have root acces you can remove the .apk file that provides this app. You would have to look around in the folders on the device where it is installed.
It may be necessary to re-compile the Android OS that is running on the emulator. During the compile the default apps are rolled up into the build so it would be a matter of getting the egg before the chicken... or killing the chicken before it lays the egg...

Android install apk on phone

I have a game I built in eclipse and now want to install on my phone.
I downloaded ASTRO per an example in YouTube, then copied the .apk file to the SD Card, went to the phone, found it try to install it but it seems like it doesn't recognize it because it does not give me the option to install although I can browse through my assets, drawables etc...
Am I missing something? I just want to download it to the phone ... but all I see is a black list under summary with no description and no button to click on for "Install".
try installing it via adb. Type
'the path to your adb on the pc - it's located in the platform-tools directory of the sdk' install 'the path to your apk on the pc'
in the shell. i.e
adb install myapp.apk in case the path to your adb installation is in the system path and your current directory is the one with the apk.
If you develop i think you got android sdk set up, try to fire up install from the command line by using : adb install
Make sure adb is in your path and your phone has development settings turned on.
you can also open it using the webrowser
using file:///sdcard/bla.apk
If you can browse your assets etc then it sounds like you used long-press in Astro and then told it to 'Extract'. This doesn't install the app, it simply unpacks the apk into its component parts.
Do a 'short-press' (click) on the apk file with Astro and it should give you the option to 'Open App Manager'. This should allow you to install it.
I had this happen to me and this is what I had to do to fix it. Since the option to install is grayed out you need to edit your AndroidManifest.xml and tell Android what sdk version it targets. The version on your phone is probably 2.1 and you have been developing on 2.2. This is what you need to insert into the manifest file.
<uses-sdk
android:minSdkVersion="7" android:targetSdkVersion="8" android:maxSdkVersion="8">
</uses-sdk>
Renaming the .apk to some other extension is not enough to enable beaming. Android will look into the file. You must rename the file then zip it. After that a beam will work and just reverse the process before installing on the device.
This is quite a pain because I beam my apk hundreds of times while testing. On my desire with froyo it was allowed but now on my nexus s with gingerbread it is blocked.
Just figured out you can email the apk to your gmail account as an attatchment and you can install the apk straight from the email. When you open up the email scroll to the very botton and you will see a "Install" button. it's a quick and easy solution.

How to make an EXE file using .apk file

am almost done with my project in android, now I want to make the executable version of the application.
I need to demonstrate it in .exe form as soft app as on emulator, not by built and debug process from eclipse.
what the op is asking for is simple - he wants to create a MS Windows program file that runs just like the APK he's made.
Unfortunately this cannot be done. The only way to 'show off' your program is as people have stated:
Through the emulator on Windows
On an acual device (Once installed, you can disconnect the device from the computer and use it like a normal app)
You can't convert an APK file into a .exe file. APK files hold Android apps as self-installable files already - opening an APK file on a phone or the emulator will start the installation process. It sounds like you just want to sign the app with a 'proper' key rather than using a debug key. To do that, read the official page on signing apps.
You don't need to create a .EXE file for doing what you want. You can just create a bat file that executes adb commands that will: install and start your application in the emulator. I guess, the problem here is that you don't understand how the APK files work... I'm just saying.
OK... in order to install an Android application using adb (which is basically what Eclipse does in the background) you need to do this:
adb install path/name_app.apk
Then, you can start the application by using adb shell am command. You can find info here: http://pdk.android.com/online-pdk/guide/instrumentation_testing.html
Another thing you have to take in account is that you will have to run the AVD before installing and executing your application: http://developer.android.com/guide/developing/tools/avd.html
All those commands you have to execute (may be using a .bat file as I mentioned before) are executables that you can find in the android-sdk\tools directory.
When I have a client that want's to show an app, at conference for example, I always use Bluestacks it's not perfect but it allows you to run android apps on your computer without doing all the technical stuff (like installing an emulator etc).
To install an app on your you computer using the Bluestacks device/emulator you simply click on the apk.
http://bluestacks.com/
Once you create a project/application in Eclipse then along with this you also have created the .apk file. Android can run .apk files, so go to the place where your project have been saved and open it, like this Open Project -->bin-->.apk.
Now send the .apk file to your android phone through Bluetooth or copy it.

Shared library missing in android.

02-18 00:02:08.432: ERROR/PackageManager(57): Package com.example.brown requires unavailable shared library com.google.android.maps; failing!
I got this exception in logcat.
Can anyone guide me?
As CommonsWare said, your emulator is missing the library. The Google Maps Library's documentation's Overview page has info on how to create the right kind of virtual device for the emulator. The gist is:
Launch the AVD Manager by using the android command without any options. If you are developing in Eclipse/ADT, you can also access the tool from Window > Android SDK and AVD Manager.
Click the "New" button to begin creating a new AVD.
In the dialog that appears, specify a name for the AVD and select the system image target that you want the AVD to use. Select one of the "Google APIs (Google Inc.)" targets, making sure to choose a version whose API Level matches the android:minSdkVersion attribute in your application's manifest, as described above.
Configure the other options and then click "Create AVD".
Once you've finished creating the AVD, you can run it from the AVD Manager UI or you can use the emulator's command-line interface. If you are developing in Eclipse, you can configure a Run Configuration to start the AVD and install your application on it.
For more information about AVDs, see Android Virtual Devices on the Android Developers site.
I had the similar problem on a real device. After a loot of googling I found this answer
fixing missing shared library. It turns out that on some custom roms the comp.google.android.map library is missing, you have to install it manually.
download googleapps
extract two files
system/etc/permissions/com.google.android.maps.xml
system/framework/com.google.android.maps.jar
remount the /system filesystem rw (mount -o rw,remount /system)
copy the files in
do a chmod 644 on them
reboot
This error occurred to me on an actual device, not an AVD like the other answers. In my case I was running on a Nexus S with a custom ROM that did not have Google Maps installed.
I have read elsewhere that the com.google.android.maps shared library is bundled with the ROM itself and is not bundled as part of an APK.
Therefore the solution for me was to revert to the stock ROM which had Google Maps installed.
BTW, the title of this thread refers to an error that is found in the DDMS LogCat. The first error most users will see (before checking LogCat) will be in the console of Eclipse:
Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY
Please check logcat output for more details.
Your emulator is missing the Google APIs. Create a new AVD that contains the Google APIs, and this error should go away.
As jfritz42 I got this error on a real device with a custom ROM (Cyanogenmod). The error was caused by the fact that I did not install the Google Apps package, since it contains a lot of apps that just annoy me. However, there is a solution how to install the google.maps library without massing up your system with the 19 Google Apps in this package. Just download the package (zip file) and remove all .apk files from system/app in this zip. Afterwards, you can install the zip by using the ROM Manager or via the recovery mode. Then you should have the maps library installed on your system. The Google Apps included in this package (e.g. the Maps app) can be installed separately afterwards.
In case with real device try remove from manifest file:
<uses-library android:name="com.google.android.maps" />
I've experienced this error after the AVD was set up properly and working okay. The AVD was still using the Google APIs and I could see the reference to the maps library in Eclipse. The only way I found to resolve this was to delete the AVD and create a new one, as advised by fiXedd.
fiXedd (see above) is correct.
You can edit devices you have already created or create a new one. When you create or edit a device inside the AVD Manager, instead of selecting this kind of version target:
Android x.x.x - API Level x
Simply use this kind instead:
Google APIs (Google Inc.) - API Level x

Categories

Resources