using Eclipse for Android development - cant find jarsigner.exe4 - android

Now I am at the stage of preparing my android app for publishing I discover that jarsigner.exe is not on my hard disk ( done a full search) I have the jave sdk and java jre and keytool.exe but no jarsigner. I have googled and followed thro links that appeared to offer download of jarsigner but none of them acftually do. I have been to the official java site but cant find an option to download this file - can anyone help?
I am using Eclipse and thought that when I did the various downloads for Eclipse, Android and Java I would have all the necessary files.
From the reading I have done it seems that the Eclipse export wizard only prepares debug signed .apk and I must follow the unsgned/keytool/jarsigner route to get a distrbutable file.

You don't need it.
Right-click on the project in the Package Explorer view, in the popup menu choose Android Tools/Export signed application package.

In the directory of the JDK (not JRE).
%JDK_HOME%\bin\jarsigner.exe
You can download it from here - http://www.oracle.com/technetwork/java/javase/downloads/index.html

Related

Eclipse Error while importing project

I'm trying to import my game which I built in cocos2dx to eclipse so I can make a APK file and publish it to the play store, when I try to import my project it gives me an error, this is the error
http://tinypic.com/view.php?pic=2jfabs2&s=8#.VRBxHIufuh8 (click to see screenshot)
I have tried solving this problem by browsing the web but all solutions aren't clear or not related to my problem.
You do not have the android sdk where Eclipse expects it.
Two possibilities:
you do not have the sdk anywhere on your computer.
Then do what follows:
In the Eclipse toolbar, click on "window" section, and go to the "android sdk manager".
It will open the manager and allows you to download the last version of the SDK Tools.
You have the SDK somewhere on your computer but in the wrong folder, then you must find it and copy it in the expected folder (as it is said on the image you shared)

Android SDK gives wrong path, Android Studio

Recently I've started to get involved in Android developing, and I learned that Android Studio was available contrary to Eclipse. So I downloaded the new software by Google and started it up. It prompted me to install some SDK packages and I did all that it recommended me to do at
http://developer.android.com/tools/help/sdk-manager.html
Then I saw a link that said you can find out where your SDK path is by opening the SDK manager up top, as well as the answer described on this page
Android Studio - How to Change Android SDK Path
So I copied the path and tried to use the run command (I can't post images yet) The path is described as
C:\Users\baruy\AppData\Local\Android\sdk
I get an error saying that it doesn't exist. I browse for the files by myself, to learn that there is no AppData folder under baruy
Windows 8 64-bit, home edition. Please help, thanks
AppData is a hidden folder on windows. In order to show hidden files and folders on windows 8, follow this guide on msdn.
In short, you should go to Control panel->Folder options->"View" tab and then check the "Show hidden files, folders and drives". If you don't find the android sdk after that than it is simply not there.
AppData is an hidden folder. Paste that path in the window manager path and you should get there. Alternatively use the console and type:
cd AppData\Local\Android\sdk
After upgrading to Android 3.0 this path error came up. The default Sdk path in mac is /Users/username/Library/Android/sdk, and as that was marked in the systems settings the studio just had to be restarted and it worked again.

How do I export an Android Studio project?

I just started using the Android Studio IDE and I already released and published a simple APK to Google Play store.
The problem is that I did this at work.
Now I downloaded the Android Studio at my home and I want to continue working and fixing bugs on my Project.
I see that there is Import Project in the Android Studio home screen, but from where I export the project in order to import it?
I tried Zipping my whole Project folder and import it but it didn't work very well.
In the Android Studio go to File then Close Project. Then take the folder (in the workspace folder) of the project and copy it to a flash memory or whatever. Then when you get comfortable at home, copy this folder in the workspace folder you've already created, open the Android Studio and go to File then Open and import this project into your workspace.
The problem you have with this is that you're searching for the wrong term here, because in Android, exporting a project means compiling it to .apk file (not exporting the project). Import/Export is used for the .apk management, what you need is Open/Close project, the other thing is just copy/paste.
As mentioned by other answers, as of now android studio does not provide this out of the box. However, there are ways to do this easily.
As mentioned by #Elad Lavi, you should consider cloud hosting of your source code. Checkout github, bitbucket, gitlab, etc. All these provide private repositories, some free, some not.
If all you want is to just zip the sources, you can achieve this using git's git archive. Here are the steps:
git init # on the root of the project folder
git add . # note: android studio already created .gitignore
git commit -m 'ready to zip sources'
git archive HEAD --format=zip > /tmp/archive.zip
Note: If you intend to send this by email, you have to remove gradlew.bat from zip file.
Both these solutions are possible thanks to VCS like git.
It seems as if Android Studio is missing some features Eclipse has (which is surprising considering the choice to make Android Studio official IDE).
Eclipse had the ability to export zip files which could be sent over email for example.
If you zip the folder from your workspace, and try to send it over Gmail for example, Gmail will refuse because the folder contains executable.
Obviously you can delete files but that is inefficient if you do that frequently going back and forth from work.
Here's a solution though:
You can use source control. Android Studio supports that. Your code will be stored online.
A git will do the trick. Look under "VCS" in the top menu in Android Studio.
It has many other benefits as well. One of the downsides though, is that if you use GitHub for free, your code is open source and everyone can see it.
Source control is best way to handle this problem, if you don't want to pay then try bitbucket
It's free, allows private repo for upto 5 members team.
Windows:
First Open Command Window and set location of your android studio project folder like:
D:\MyApplication>
then type below command in it:
gradlew clean
then wait for complete clean process. after complete it now zip your project like below:
right click on your project folder
then select send to option now
select compressed via zip
Apparently, there's a lot of "dead wood" in the "build" directories of a project.
Under linux/unix, a simple way to get a clean, private backup is to use the "tar" command along with the "--exclude=String" option.
For example, to create an archive of all my apps while excluding the build directories, I have a script that creates the following 2 commands :
cd $HOME/android/Studio
tar cvf MyBackup-2017-07-13.tar Projects --exclude=build
For Android Studio below 4.1:
From the Top menu Click File and then click Export to Zip File
For Android Studio 4.1 and above:
From the Top menu click File > Manage IDE Settings > Export to Zip File ()

installing android offline is hard[obsolete]

i am a student in africa and in our land, there actually exist slow and expensive internet connections, which is why we tremble in fear whenever we hear the word "online repository" method of installing software. Damn, that usually means you have to look elsewhere.
The problem.(i cant install android without connecting eclipse to the internet)
It is possible to manually download individual components as .zip files but there is no way of installing them into android eg i have managed to download
platform-tools_r03-windowsandroid-sdk_r10-windowsetcbut no matter what i do, i can't get android to recognise them as components. It seems tens of thousands of other developers have a similar problem (see below)
This qn has 10k views(meaning 10k people had a similar problem)
another lost developer
webpage sudgesting solution that failed to work on windows seven ultimate
If someone has actually ever installed android without connecting eclipse to the internet, please let us know the magic you used. Thanks in advance :)
EDIT:
if someone out there is still interested check out http://qdevarena.blogspot.com/2010/05/download-android-sdk-standalone-for.html
and make sure your folder structure is as shown in http://developer.android.com/sdk/installing.html
For SDK and platform tools you can just extract the zip content, Eclipse has nothing to do here.
For Eclipse ADT plugin:
Download the zip file from http://dl.google.com/android/ADT-10.0.1.zip
Help -> Install New Software -> Add
Select Archive and then provide the location of the zip file
These steps are clearly explained in Eclipse ADT documentation.
Only in Windows
Install (if not installed) Oracle JDK jdk-7-windows-i586.exe
install Eclipse SDK
Add to the PATH environment variable the path to the JDK (for example c:\Program Files\Java\jdk1.7.0\bin)
Edit the file hosts (c:\WINDOWS\system32\drivers\etc\hosts), add the entry "127.0.0.1 dl-ssl.google.com"
It's important! Port 80 must be free at the time of installation Android SDK
Run the Abyss Web Server X1 (abyssws.exe). Works best if you download a fresh copy
Run the Android SDK "SDK Manager.exe" installer
In the "Android SDK Mannager" in the menu "Tools" >> "Options" put the check ("force https:// ... sources to be fetched using http:// ...")
Android SDK Manager will fetch packages in your computer. Choose the packages for API you want to program against, select and install packages
After installation the file hosts (c:\WINDOWS\system32\drivers\etc\hosts) entry "127.0.0.1 dl-ssl.google.com" you entered in step 3
Good Luck!! and remember to update to lastest APIs and revision
You can download Eclipse ADT and install
IN Eclipse: Click Help tab and Install New Software tab
Click add button
In Add Repository Window, add in Name Field Eclipse ADT and Location field click archive to browse in local machine where you downloaded ADT
Press Ok and tick all, Eclipse will install the less
The answer by dtmilano is not valid for the current version of android SDK. (androdi 4.2.2)
The android website says that after the unzipping of the ADT:
Your Eclipse IDE is now set up to develop Android apps, but you need to add the latest SDK platform tools and an Android platform to your environment. To get these packages for your SDK, continue to Adding Platforms and Packages.
http://developer.android.com/sdk/installing/installing-adt.html
Instead, try
http://qdevarena.blogspot.in/2010/05/download-android-sdk-standalone-for.html
as mentioned by
Installing android SDK in eclipse offline
I'M a Ghanaian..I did it about a week ago on ubuntu it might work on windows
your question indicates that you have eclipse installed..so i will just move on to setting it up to run android apps ...
step 1: go to developer.android.com to download the sdk for windows(i recomend you download the one with the installer).
step 2: launch ur favourite browser and open this site.
you will see an xml page using ctr+f (any shortcut for finding a text on your browser) type andoroid 2.2 or any android version you like latest is kitkat 4.4...you will find ur prefered android version in zip file for ur OS i.e windows...just copy the text and append it to this address.
this will download the the platform for you in .zip format....just navigate to where you extracted ur sdk and go to platform folder and then create a new folder with any name and then extract the platfor you downloaded earlier i.e android version into the new folder you created...just launch the sdk.exe and it will auto detect your platform for you...
just go and creae your Android virtual device and start running your apps..

Repackage APK file to contain custom assets - what build tool to use?

Update: This is an old post, and references below to broken aapt versions will be out of date.
Based on previous feedback, I am storing custom text fields in the assets directory of my app.
I will write the app, using default user details in an asset file, and the client would like to rebuild the app for each user, including that user's details in the asset file.
(I am aware this is method has some serious shortcomings, but the client is still keen to do it in this way - see Embed login details in APK file, different for each user (or other options?))
This question relates to troubles I am having with rebuilding the APK file, once I have unzipped it, and updated the custom asset file. I am quite convinced I am missing something small, however, the documentation and posts I have found on these methods are not helpful enough for a newcomer.
aapt - Android sdk tool: Unfortunately the android docs on "Using aapt" on the android docs [link 2 below] are very limited. The console command -help shows a bit more info. When trying to use it to just add a file to the test.apk, it ends up deleting the original, and creating a new file test.apk.zip containing only the file I tried to add. I have not been able to find the correct command line combination to take an unzipped apk and repackage it - that would be my first prize.
apkbuilder - Android sdk tool: Firstly this tool is deprecated, which is a negative point for it. I also can't get it to work with what I have in that unzipped folder. I think I'm missing a pre-apkbuilder step because apkbuilder asks for a resource zip archive, and I have a resource folder.
ant - build tool: Other similar posts say to build with ant, rather than using the android tools. I am having trouble getting ant to work. One particular link to Getting Ant to Work with Android [link 3 below] looks promising but looks like it is for a different android sdk (my build.xml that is generated by android looks different to his). Unfortunately I know little about ant, and am having trouble becoming expert enough to solve my current issue.
Further to NickT's solution below - running the ant script gives me the error
taskdef class com.android.ant.SetupTask cannot be found using the classloader AntClassLoader[].
I have found some references online to this error, have confirmed that local.properties has an sdk.dir setting that is pointing to my android sdk install folder (sdk.dir=/Applications/android-sdk-mac_86).
?????: There might be some other option that I have not listed / discovered, which I would be interested in hearing about.
I realize that delving into the gears that are normally covered up by my ide can lead to diffuculties. But I know that a lot of the SO users can do many of these things, and I hope I get the interest of some of them. Thanks for any help.
(Eclipse 3.6 on Mac Snow Leopard 10.6 64 bit)
PS, I am not able to post more than 1 hyperlink yet, so I have included these addresses to show more info to my question.
(1): stackoverflow.com/questions/4783160/embed-login-details-in-apk-file-different-for-each-user-or-other-options
(2): developer.android.com/guide/developing/tools/aapt.html
(3): www.disgruntledrats.com/?p=27
To answer my own question with the method we finally chose, and "for the record":
I was unable to get Ant working correctly for me (my lack of understanding).
I ended up using the aapt tool. It works as per the Android sdk documentation and really is quite simple to use:
aapt add -v Test.apk "assets/readme.txt"
This will add a readme.txt file (we were storing it in a subfolder of the current running folder, called assets. If you want to store the new file somewhere else, aapt does offer a command line switch to specify that)
However, there are some caveats:
I couldn't get it to work on signed APK files.
some versions of aapt don't work properly! They don't recognise the subfolder...
To solve 1:
Export the APK from eclipse as an unsigned APK.
Use the keytool to generate a key (see Android dev docs).
Use aapt.
Sign the APK using jarsigner.
To solve 2:
I can't really help with this. Every version of the SDK (on Mac) I tried to download included an aapt tool that did not recognize the subfolders. A colleague downloaded a version that worked, but we could still not figure out which version it was that he downloaded, so we kept this "magic" copy and renamed it and will be using it until we find a new version that works.
The simplest solution would be to give the template source of the app to your client with a script that rebuild the app from scratch.
This way your client simply have to change the assets in the folder, double click a batch file and get the apk in a minute or so.
You don't have to know anything about ANT to compile and package without the IDE, just follow the steps here :
http://developer.android.com/guide/developing/other-ide.html
The ANT script is generated by the "android create" "android update" commands. You then just need to run "ant release" and off you go.
A bit late, probably, but this post appears in lots of searches, so I thought this may be of interest.
I just used a standard Zip tool to 'unsign' the APK by removing the META-INF folder, updated any asset files, and then resigned the APK using jarsigner. (If I could find a way to sign JARs without using jarsigner, so we wouldn't need the Java SDK installed everywhere, this would be really useful - ideas anyone?)
To expand on Yahel's answer, yes I think Ant is the way to go. It can be a bit intimidating, but it's urprising how well it works 'out of the box' without too much messing about. Customising it takes a bit of reading but I managed it, so I'll give you the benefit of my experience.
Firstly create a sample application as suggested. Let's suppose you want it to be created in c:\junk.
Then from your a command prompt in Android SDK\tools directory type:
android create project -t 5 -n AndSampleApp -p c:\junk\AndSampleApp -a AndSampleApp -k com.yourpackage.andsample.
( -t 5 gives you API level 7, type 'android list targets' to see other options)
Let's assume you've been building your projects in an Eclipse workspace (it's /dev/projects/EclipseHelios/AndroidWorkspace on my machine). Copy the sample app's build.xml and build.properties to the project folder in Eclipse
and edit the newly created build.xml and remove the line
<project name="AndSampleApp" default="help">
and replace it with just:
<project>
Now edit the the newly created build.properties which will be empty except for comments and add (customisng where necessary):
# The password will be asked during the build when you use the 'release' target.
# OH NO IT WON'T! IF YOU PUT THE KEYS & PWDS IN AS BELOW - It'S AUTOMATIC
# Customised (hard coded) section ---------------------
projectname=YourActualProjectName
# Line below is the parent folder of where the sources are
workspace.dir=/dev/projects/EclipseHelios/AndroidWorkspace
# Line below is where you want the binaries to go
outbasebase.dir=/dev/projects/AntBuilds
key.store=c:/users/you/your-release-key.keystore
key.alias=your_release_alias
key.store.password=YourSecretPassword
key.alias.password=YourSecretPassword
#------------------------------------------------------
ant.project.name=${projectname}
base.dir=${workspace.dir}/${projectname}
source.dir=${base.dir}/src
outbase.dir=${outbasebase.dir}/${projectname}
out.dir=${outbase.dir}/bin
layout.dir=${base.dir}/res/layout
If you then get a command line prompt in /dev/projects/EclipseHelios/AndroidWorkspace/YourActualProjectName
and type 'ant release', you should end up with a built and signed apk in /dev/projects/AntBuilds/YourActualProjectName
You should be able to customise the assets location by the adding an assets.dir entry in the build.properties

Categories

Resources