- Download development Kits :- We need to download a Java Development Kit called JDK for Windows. And Android Development Kit called ADK. I have downloaded JDK 1.6 because its old & old is gold. Its lesser in size and complexity and has been tested and is stable with known bugs only. Similarly try downloading older version of Android SDK haveing GUI version of SDK Manager so that you can download essentials. Avoid the slow moving Android Studio. Using SDK Manager download Android-23 platform build tools.
- Configure Kits :- Set Windows PATH variable by Rt.Clicking My Computer -> Properties ->Advanced System Settings or reach through Control-Panel. PATH should include the javac.exe file in JDK directory, android.bat file of ADK.
- Download Build-Tool :- We dont need it but it is very convenient if we have one. Gradle is preferred , though Ant is fast. These programs configure the ADK command-line tools for easy usage for our convenience. I downloaded gradle old version 2.2.1 as it can use old java & old android.
- For a detailed illustration kindly see this link: https://letsmakeandroidapp.wordpress.com
- SCREENSHOTS of my devlopment environment:-
This is to illustrate coding an Android app using notepad and compiling to Apk at command prompt without using IDE
19 Aug 2017
Step 1. Convert your Windows Laptop into an Android App Development Environment
Step 2. Create Android Mobile App Project Structure into root directory and sub directories
This will be root directory of our Project. What is our Project? Say our project is to design as many apps as we can for Android-Mobiles.
<Project Directory>
D:\AndroidApps\>
- appNo.1
- src
- main
- java
- com
- pkg
- App.java
- res
- drawable
- ic_launcher.png
- layout
- main.xml
- values
- strings.xml
- attrs.xml
- assets
- fonts
- AndroidManifest.xml
- androidTest
- appNo.2
- appNo.3
31 Jul 2017
Android app code to illustrate sqlite database
Make android java code
Let's make Main.Java
This Main class file of android Java must be an extension of Activity class. It's instantiated by Android system when app is run by user.
public class Main extends Activity
{
protected void onCreate ()
{
}
}
Above is a skeleton which says
Let's have a publicly available code resembling inbuilt code of Activity and let's only change a portion of it called onCreate.
This function is called when an object of this code is instantiated in RAM memory of Android mobile. What is created is an empty screen shown to user with a top title as Activity label defined in manifest.
We can place many more text and buttons etc in this empty screen by putting code in this custom function.
But what code. So see below.
TextView tv = new TextView (this)
Above statement allocates a textview object in RAM memory.
tv.setText("Hi dude");
This puts Hi dude in its data variable for containing text.
setContentView(tv);
This above statement let's the empty screen window object point to the newly allocated tv object so that contents of tv view object are displayed on mobile screen.
30 Jul 2017
Make AndroidManifest.xml
We need one androidManifest.xml file to describe icon and name of app to be displayed in mobile to user. Also this file will tell which .class file to execute first out of all classes stored in Dex file. We can call it as main class file. Let's make it.
AndroidManifest. xml
manifest xmlns:android = "URI" version=1.0 encoding=utf-8
Above statement tells that all elements inside tags in this XML if prefixed by word 'android' then replace Android by URI. URI can be HTTP:/schema/apk... Etc.
application android:icon="@drawable/myicon" android:label="@string/app name".
Above statement tells what icon to use and what label for this app to be displayed to users. Android URI will be prefixed to icon and label elements. When aapt tool makes apk it will only consider those elements which have this prefix.
activity android:name="Main" android:label="My App"
Above statement uses activity element and says that Main.class code must be executed first and title label should be My App.
intent-filter
action android:name="android.intent.action.MAIN"
category android:name = "android. intent. category.LAUNCHER"
intent-filter
Here optional Activity related commands can be placed.
While Activity refers to screen of mobile placed before user.
So things like making it full screen without title bar or allowing it's auto resizing or panning thereby denying scrolling on pop-up of soft keyboard can be done here.
'activity windowSoftInputMode ="adjustSize|adjustPan" /
'activity Orientation="Portrait"/>
Window feature flag full screen.
activity
application
manifest
In above statement two elements <action>,<category> are defined within <intent-filter> element. User actions of clicking touching mobile screen suggest there intentions. When there intention is fired from launching an app by app launcher service in mobile then the category of intention is stored as LAUNCHER.
Now is the user deleting uninstalling or running this app. If running then action is MAIN.
This manifest will be used two time.
First time when generating R.java and R.class etc.
Second time to generate apk by aapt tool.
29 Jul 2017
Generate android app apk on shell or command prompt
Generation of Android app apk at command prompt of Windows will be as follows:
1. Install Java in form of jdk and jre in folders c:\jdk and c:\jre. Only install version 6 standard edition as it is small size compatible with Android.
Next install Android in folder. c:\android.
Run Android package manager and put Android API level 23 platform tools for version 6 of Android lollipop in directory
c:\android\platform\android-23
.This will have a file Android.jar containing all class files as a library jar for making a Dex file run and execute as app on Android lollipop mobile.
Set path environment variable in advance system settings of Windows. Include c:/jdk;c:/jre;c:/Android/tools etc in path variable.
2. Lets use shortcut mypro for my project. Mypkg means my package. Make directory folder c:\mypro\com\mypkg.
Note that com.pkg is a package where dot or period separates com and pkg sub directories.
In case your package doesn't have this dot or period, then during compilation no error but when you install in mobile, it will say invalid apk.
Put myapp.java containing your code in this directory.
Put needed image icon files in c:\mypro\res\drawable.
Put AndroidManifest.XML file in c:\mypro.
3. Now we generate R class for res directory. R.drawable class for subdir drawable and R.attr class for attributes to gather information from AndroidManifest.XML file and other layout XML style XML string xml files.
For this we use aapt command.
aapt p -S res -J ./com/pkg -I android.jar
Where
aapt=Android app pkging tool
S= Sources in res directory
J= Java generated files
I = Include dir or jar file
For target Android mobile
Say lollipop.
This generates R.Java, having R.attr.class,etc classes in it.
4. Now goto dir c:\mypro\com\mypkg. Give command
javac *.java
to get myapp.class
,R.class, R.attr.class, etc in same directory.
5. Now we make a Dex file from these classes.
dx -dex --output=classes.dex .
Notice the dot above represents current directory.
So all binaries including .class and .jar and .apk all will be compiled to Dex file.
Therefore remove all other jar and apk files. delete them prior executing above command. Also don't keep Android.jar here.
6.Now make apk out of Dex and resources.
First delete all class files as we have incorporated already in dex. Also delete any previous jar or apk. Goto directory
c:/mypro.
aapt p -I android.jar -S res -F myapp.apk classes.dex
Where F=file to be created