

The -source option specify the java version of your source files. To solve the problem, you have to specify 1.7 java version in the previous javac command: cd /path/to/AndroidHello javac -d obj -source 1.7 -target 1.7 -classpath src -bootclasspath /opt/android-sdk/platforms/android-19/android.jar src/com/example/helloandroid/*.java

If you have the error UNEXPECTED TOP-LEVEL EXCEPTION, it can be because you use old build tools and DX try to translate java 1.7 rather than 1.8. dx -dex -output=$PROJ/bin/x $PROJ/*.jar $PROJ/obj dx -dex -output=$PROJ/bin/x $PROJ/objīut if you use external libraries, do rather. We have to translate them in a file called “x” which will be read by the dalvik Android runtime: cd /opt/android-sdk/build-tools/26.0.1/. class files are in obj folder, but Android can’t read them. If you have use an external, add it the classpath: javac -d obj -classpath "src:libs/.jar" -bootclasspath /opt/android-sdk/platforms/android-19/android.jar src/com/example/helloandroid/*.java java files: cd /path/to/AndroidHello javac -d obj -classpath src -bootclasspath /opt/android-sdk/platforms/android-19/android.jar src/com/example/helloandroid/*.java You can find yours in a location like android-sdk/platforms/android-/android.jar -I tells aapt where the android.jar is.-S specifies where is the res directory with the drawables, layouts, etc.

Saying -J src will create a file like src/com/example/helloandroid/R.java -m instructs aapt to create directories under the location specified by -J.aapt package -f -m -J $PROJ/src -M $PROJ/AndroidManifest.xml -S $PROJ/res -I /opt/android-sdk/platforms/android-19/android.jar

Now, I recommend to store the project path in a variable: export PROJ=path/to/HelloAndroidįirst, we need generate the R.java file which is necessary for our code: cd /opt/android-sdk/build-tools/26.0.1/.
