REM @echo off
setlocal
REM Pfad zum Android
SDK
if x%ANDROID% == x set ANDROID=C:\Users\Public\Documents\Embarcadero\Studio\19.0\CatalogRepository\AndroidSDK-2433_19.0.29899.2631
REM Pfad zum Java-Compiler
set JAVAC_DIR="C:\Program Files\Java\jdk1.8.0_60\bin"
REM Pfad zur Android-Plattform
set ANDROID_PLATFORM=%ANDROID%\platforms\android-22
set DX_LIB=%ANDROID%\build-tools\22.0.1\lib
set EMBO_DEX="C:\Program Files (x86)\Embarcadero\Studio\19.0\lib\android\debug\classes.dex"
set PROJ_DIR=%CD%
echo ==========================================================================================
echo.
echo 1. Compiling the Java service activity source files
echo.
mkdir output 2> nul
mkdir output\classes 2> nul
%JAVAC_DIR%\javac -verbose -Xlint:deprecation -cp %ANDROID_PLATFORM%\android.jar -d "output\classes" "src\
com\MNCClasses\AlarmReceiver.java"
echo ==========================================================================================
echo.
echo 2. Creating jar containing the new classes
echo.
mkdir output\jar 2> nul
%JAVAC_DIR%\jar cvf %PROJ_DIR%\output\jar\MNCClasses_classes.jar -C output\classes
com\MNCClasses\AlarmReceiver.class
echo ==========================================================================================
echo.
echo 3. Converting from jar to dex...
echo.
mkdir output\dex 2> nul
java -jar %DX_LIB%\dx.jar --dex --verbose --output=output\dex\MNCClasses_classes.dex --positions=lines output\jar\MNCClasses_classes.jar
REM erzeugt Fehler:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
echo ==========================================================================================
echo.
echo Merging dex files
echo.com.android.dx.merge.DexMerger
java -cp %DX_LIB%\dx.jar
com.android.dx.merge.DexMerger %PROJ_DIR%\output\dex\classes.dex %PROJ_DIR%\output\dex\MNCClasses_classes.dex %EMBO_DEX%
echo Tidying up
echo.
rmdir /s /q output\classes
del output\dex\test_classes.dex
rmdir /s /q output\jar
echo ==========================================================================================
echo Now we have the end result, which is output\dex\classes.dex
:Exit
endlocal
pause