Changeset 7e84451


Ignore:
Timestamp:
Jun 5, 2011 10:38:35 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
95189c8
Parents:
15b9615
Message:

Android:

  • Import the main_rules file and remove the copied rules
  • Set the version code and name in the apk badging
  • Build target is 8 to allow SD install, MIN-SDK is still 3
  • Fix NPE on new install
  • Remove some debug code from NBigI
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • android/AndroidManifest.xml

    r15b9615 r7e84451  
    22<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    33      package="net.i2p.router"
    4       android:versionCode="1"
    5       android:versionName="1.0.0">
     4      android.versionCode="0"
     5      android.versionName="0.0.0"
     6      android:installLocation="preferExternal"
     7      >
    68    <uses-permission android:name="android.permission.INTERNET" />
     9
    710    <!-- 3 = 1.5, 2 = 1.1, 1 = 1.0; would probably work with 1 but don't have a 1.0 SDK to test against -->
    811    <!-- 3 required for NDK -->
    912    <uses-sdk android:minSdkVersion="3" />
     13
    1014    <application android:label="@string/app_name">
    1115        <activity android:name="I2PAndroid"
  • android/README.txt

    r15b9615 r7e84451  
    3737../../android-sdk-linux_86/tools/emulator -avd i2p &
    3838
     39# or to talk to a real phone in debug mode:
     40adb kill-server
     41sudo adb start-server
     42adb devices
     43
    3944#then wait a couple minutes until the emulator is up
    4045#then install the I2P app
     
    4449../../android-sdk-linux_86/tools/ddms &
    4550
    46 #to rebuild and reinstall to emulator:
     51#to rebuild and reinstall to emulator or phone:
    4752ant reinstall
    4853
  • android/build.xml

    r15b9615 r7e84451  
    6868         targets are used.
    6969    -->
    70     <setup import="false" />
    71 
     70    <setup import="true" />
     71
     72    <echo>Ignore warning about SDK version</echo>
    7273    <!--
    7374         ================================================================================
     
    7576         ================================================================================
    7677    -->
     78
     79    <!-- overrides of those in main_rules.xml -->
     80
     81    <target name="-pre-build" depends="copy-i2p-resources, incrementBuild" />
     82
     83    <target name="-pre-compile" depends="buildrouter" />
     84
     85    <target name="-post-compile" depends="hackcleanup, jbigi" />
     86
     87    <!-- new rules -->
    7788
    7889    <target name="buildrouter" depends="-dirs" >
     
    136147            <arg value="scripts/setversion.sh" />
    137148        </exec>
     149        <!-- this loads my.version.code and my.version.name -->
     150        <property file="scripts/version.properties" />
    138151    </target>
    139152
     
    148161        <delete file="jni/libjbigi.so" verbose="${verbose}" />
    149162        <delete file="scripts/build.number" verbose="${verbose}" />
     163        <delete file="scripts/version.properties" verbose="${verbose}" />
    150164    </target>
    151165
     
    157171    -->
    158172
     173    <!-- not necessary to copy if setup import="true" -->
     174
    159175
    160176    <!--
    161         This rules file is meant to be imported by the custom Ant task:
    162             com.android.ant.SetupTask
    163 
    164         The following properties are put in place by the importing task:
    165             android.jar, android.aidl, aapt, aidl, and dx
    166 
    167         Additionnaly, the task sets up the following classpath reference:
    168             android.target.classpath
    169         This is used by the compiler task as the boot classpath.
    170     -->
    171 
    172     <!-- Custom tasks -->
    173     <taskdef name="aapt"
    174         classname="com.android.ant.AaptExecLoopTask"
    175         classpathref="android.antlibs" />
    176 
    177     <taskdef name="aidl"
    178         classname="com.android.ant.AidlExecTask"
    179         classpathref="android.antlibs" />
    180 
    181     <taskdef name="renderscript"
    182         classname="com.android.ant.RenderScriptTask"
    183         classpathref="android.antlibs" />
    184 
    185     <taskdef name="apkbuilder"
    186         classname="com.android.ant.ApkBuilderTask"
    187         classpathref="android.antlibs" />
    188 
    189     <taskdef name="xpath"
    190         classname="com.android.ant.XPathTask"
    191         classpathref="android.antlibs" />
    192 
    193     <taskdef name="if"
    194         classname="com.android.ant.IfElseTask"
    195         classpathref="android.antlibs" />
    196 
    197     <!-- Properties -->
    198 
    199     <!-- Tells adb which device to target. You can change this from the command line
    200          by invoking "ant -Dadb.device.arg=-d" for device "ant -Dadb.device.arg=-e" for
    201          the emulator. -->
    202     <property name="adb.device.arg" value="" />
    203 
    204     <property name="android.tools.dir" location="${sdk.dir}/tools" />
    205     <property name="android.platform.tools.dir" location="${sdk.dir}/platform-tools" />
    206     <!-- Name of the application package extracted from manifest file -->
    207     <xpath input="AndroidManifest.xml" expression="/manifest/@package"
    208                 output="manifest.package" />
    209     <!-- Value of the hasCode attribute (Application node) extracted from manifest file -->
    210     <xpath input="AndroidManifest.xml" expression="/manifest/application/@android:hasCode"
    211                 output="manifest.hasCode" default="true"/>
    212 
    213     <!-- Input directories -->
    214     <property name="source.dir" value="src" />
    215     <property name="source.absolute.dir" location="${source.dir}" />
    216     <property name="gen.dir" value="gen" />
    217     <property name="gen.absolute.dir" location="${gen.dir}" />
    218     <property name="resource.dir" value="res" />
    219     <property name="resource.absolute.dir" location="${resource.dir}" />
    220     <property name="asset.dir" value="assets" />
    221     <property name="asset.absolute.dir" location="${asset.dir}" />
    222 
    223     <!-- Directory for the third party java libraries -->
    224     <property name="jar.libs.dir" value="libs" />
    225     <property name="jar.libs.absolute.dir" location="${jar.libs.dir}" />
    226     <!-- create a path with all the jar files, from the main project and the
    227          libraries -->
    228     <path id="jar.libs.ref">
    229         <fileset dir="${jar.libs.absolute.dir}" includes="*.jar" />
    230         <path refid="project.libraries.jars" />
    231     </path>
    232 
    233     <!-- Directory for the native libraries -->
    234     <property name="native.libs.dir" value="libs" />
    235     <property name="native.libs.absolute.dir" location="${native.libs.dir}" />
    236 
    237     <!-- Output directories -->
    238     <property name="out.dir" value="bin" />
    239     <property name="out.absolute.dir" location="${out.dir}" />
    240     <property name="out.classes.dir" value="${out.absolute.dir}/classes" />
    241     <property name="out.classes.absolute.dir" location="${out.classes.dir}" />
    242 
    243     <!-- Intermediate files -->
    244     <property name="dex.file.name" value="classes.dex" />
    245     <property name="intermediate.dex.file"
    246                   location="${out.absolute.dir}/${dex.file.name}" />
    247     <property name="resource.package.file.name"
    248                   value="${ant.project.name}.ap_" />
    249 
    250     <!-- The final package file to generate
    251          These can be overridden by setting them earlier to
    252          different values -->
    253     <property name="out.debug.unaligned.file"
    254                   location="${out.absolute.dir}/${ant.project.name}-debug-unaligned.apk" />
    255     <property name="out.debug.file"
    256                   location="${out.absolute.dir}/${ant.project.name}-debug.apk" />
    257 
    258     <property name="out.unsigned.file.name"
    259                   value="${ant.project.name}-unsigned.apk" />
    260     <property name="out.unsigned.file"
    261                   location="${out.absolute.dir}/${out.unsigned.file.name}" />
    262 
    263     <property name="out.unaligned.file.name"
    264                   value="${ant.project.name}-unaligned.apk" />
    265     <property name="out.unaligned.file"
    266                   location="${out.absolute.dir}/${out.unaligned.file.name}" />
    267 
    268     <property name="out.release.file.name"
    269                   value="${ant.project.name}-release.apk" />
    270     <property name="out.release.file"
    271                   location="${out.absolute.dir}/${out.release.file.name}" />
    272 
    273     <!-- set some properties used for filtering/override. If those weren't defined
    274          before, then this will create them with empty values, which are then ignored
    275          by the custom tasks receiving them. -->
    276     <property name="version.code" value="" />
    277     <property name="aapt.resource.filter" value="" />
    278     <property name="filter.abi" value="" />
    279 
    280     <!-- compilation options -->
    281     <property name="java.encoding" value="UTF-8" />
    282     <property name="java.target" value="1.5" />
    283     <property name="java.source" value="1.5" />
    284 
    285     <!-- Verbosity -->
    286     <property name="verbose" value="false" />
    287     <!-- This is needed by emma as it uses multilevel verbosity instead of simple 'true' or 'false'
    288          The property 'verbosity' is not user configurable and depends exclusively on 'verbose'
    289          value.-->
    290     <condition property="verbosity" value="verbose" else="quiet">
    291         <istrue value="${verbose}" />
    292     </condition>
    293     <!-- This is needed to switch verbosity of zipalign. Depends exclusively on 'verbose'
    294          -->
    295     <condition property="v.option" value="-v" else="">
    296         <istrue value="${verbose}" />
    297     </condition>
    298     <!-- This is needed to switch verbosity of dx. Depends exclusively on 'verbose' -->
    299     <condition property="verbose.option" value="--verbose" else="">
    300         <istrue value="${verbose}" />
    301     </condition>
    302 
    303     <!-- properties for signing in release mode -->
    304     <condition property="has.keystore">
    305         <and>
    306             <isset property="key.store" />
    307             <length string="${key.store}" when="greater" length="0" />
    308             <isset property="key.alias" />
    309         </and>
    310     </condition>
    311     <condition property="has.password">
    312         <and>
    313             <isset property="has.keystore" />
    314             <isset property="key.store.password" />
    315             <isset property="key.alias.password" />
    316         </and>
    317     </condition>
    318 
    319     <!-- Tools -->
    320     <condition property="exe" value=".exe" else=""><os family="windows" /></condition>
    321     <property name="adb" location="${android.platform.tools.dir}/adb${exe}" />
    322     <property name="zipalign" location="${android.tools.dir}/zipalign${exe}" />
    323 
    324     <!-- Emma configuration -->
    325     <property name="emma.dir" value="${sdk.dir}/tools/lib" />
    326         <path id="emma.lib">
    327             <pathelement location="${emma.dir}/emma.jar" />
    328             <pathelement location="${emma.dir}/emma_ant.jar" />
    329         </path>
    330     <taskdef resource="emma_ant.properties" classpathref="emma.lib" />
    331     <!-- End of emma configuration -->
    332 
    333     <!-- Macros -->
    334 
    335     <!-- Configurable macro, which allows to pass as parameters output directory,
    336          output dex filename and external libraries to dex (optional) -->
    337     <macrodef name="dex-helper">
    338         <element name="external-libs" optional="yes" />
    339         <element name="extra-parameters" optional="yes" />
    340         <sequential>
    341             <!-- sets the primary input for dex. If a pre-dex task sets it to
    342                  something else this has no effect -->
    343             <property name="out.dex.input.absolute.dir" value="${out.classes.absolute.dir}" />
    344 
    345             <!-- set the secondary dx input: the project (and library) jar files
    346                  If a pre-dex task sets it to something else this has no effect -->
    347             <if>
    348                 <condition>
    349                     <isreference refid="out.dex.jar.input.ref" />
    350                 </condition>
    351                 <else>
    352                     <path id="out.dex.jar.input.ref">
    353                         <path refid="jar.libs.ref" />
    354                     </path>
    355                 </else>
    356             </if>
    357 
    358             <echo>Converting compiled files and external libraries into ${intermediate.dex.file}...</echo>
    359             <apply executable="${dx}" failonerror="true" parallel="true">
    360                 <arg value="--dex" />
    361                 <arg value="--output=${intermediate.dex.file}" />
    362                 <extra-parameters />
    363                 <arg line="${verbose.option}" />
    364                 <arg path="${out.dex.input.absolute.dir}" />
    365                 <path refid="out.dex.jar.input.ref" />
    366                 <external-libs />
    367             </apply>
    368         </sequential>
    369     </macrodef>
    370 
    371     <!-- This is macro that enable passing variable list of external jar files to ApkBuilder
    372          Example of use:
    373          <package-helper output.filepath="/path/to/foo.apk">
    374              <extra-jars>
    375                 <jarfolder path="my_jars" />
    376                 <jarfile path="foo/bar.jar" />
    377                 <jarfolder path="your_jars" />
    378              </extra-jars>
    379          </package-helper> -->
    380     <macrodef name="package-helper">
    381         <attribute name="output.filepath" />
    382         <element name="extra-jars" optional="yes" />
    383         <sequential>
    384             <apkbuilder
    385                     outfolder="${out.absolute.dir}"
    386                     resourcefile="${resource.package.file.name}"
    387                     apkfilepath="@{output.filepath}"
    388                     debugpackaging="${build.packaging.debug}"
    389                     debugsigning="${build.signing.debug}"
    390                     abifilter="${filter.abi}"
    391                     verbose="${verbose}"
    392                     hascode="${manifest.hasCode}">
    393                 <dex path="${intermediate.dex.file}"/>
    394                 <sourcefolder path="${source.absolute.dir}"/>
    395                 <sourcefolder refid="project.libraries.src"/>
    396                 <jarfolder path="${jar.libs.absolute.dir}" />
    397                 <jarfolder refid="project.libraries.libs" />
    398                 <nativefolder path="${native.libs.absolute.dir}" />
    399                 <nativefolder refid="project.libraries.libs" />
    400                 <extra-jars/>
    401             </apkbuilder>
    402         </sequential>
    403     </macrodef>
    404 
    405     <!-- This is macro which zipaligns in.package and outputs it to out.package. Used by targets
    406          debug, -debug-with-emma and release.-->
    407     <macrodef name="zipalign-helper">
    408         <attribute name="in.package" />
    409         <attribute name="out.package" />
    410         <sequential>
    411             <echo>Running zip align on final apk...</echo>
    412             <exec executable="${zipalign}" failonerror="true">
    413                 <arg line="${v.option}" />
    414                 <arg value="-f" />
    415                 <arg value="4" />
    416                 <arg path="@{in.package}" />
    417                 <arg path="@{out.package}" />
    418             </exec>
    419         </sequential>
    420     </macrodef>
    421 
    422     <!-- This is macro used only for sharing code among two targets, -install and
    423          -install-with-emma which do exactly the same but differ in dependencies -->
    424     <macrodef name="install-helper">
    425         <sequential>
    426             <echo>Installing ${out.debug.file} onto default emulator or device...</echo>
    427             <exec executable="${adb}" failonerror="true">
    428                 <arg line="${adb.device.arg}" />
    429                 <arg value="install" />
    430                 <arg value="-r" />
    431                 <arg path="${out.debug.file}" />
    432             </exec>
    433         </sequential>
    434     </macrodef>
    435 
    436     <!-- Rules -->
    437 
    438     <!-- Creates the output directories if they don't exist yet. -->
    439     <target name="-dirs">
    440         <echo>Creating output directories if needed...</echo>
    441         <mkdir dir="${resource.absolute.dir}" />
    442         <mkdir dir="${jar.libs.absolute.dir}" />
    443         <mkdir dir="${out.absolute.dir}" />
    444         <if condition="${manifest.hasCode}">
    445             <then>
    446                 <mkdir dir="${gen.absolute.dir}" />
    447                 <mkdir dir="${out.classes.absolute.dir}" />
    448             </then>
    449         </if>
    450     </target>
    451 
    452     <!-- empty default pre-build target. Create a similar target in
    453          your build.xml and it'll be called instead of this one. -->
    454     <!-- I2P add depends -->
    455     <target name="-pre-build" depends="copy-i2p-resources, incrementBuild" />
    456 
    457     <!-- Generates the R.java file for this project's resources. -->
    458     <target name="-resource-src" depends="-dirs">
    459         <if condition="${manifest.hasCode}">
    460             <then>
    461                 <echo>Generating R.java / Manifest.java from the resources...</echo>
    462                 <aapt executable="${aapt}"
    463                         command="package"
    464                         verbose="${verbose}"
    465                         manifest="AndroidManifest.xml"
    466                         androidjar="${android.jar}"
    467                         rfolder="${gen.absolute.dir}">
    468                     <res path="${resource.absolute.dir}" />
    469                 </aapt>
    470             </then>
    471             <else>
    472                 <echo>hasCode = false. Skipping...</echo>
    473             </else>
    474         </if>
    475     </target>
    476 
    477     <!-- Generates java classes from .aidl files. -->
    478     <target name="-aidl" depends="-dirs">
    479         <if condition="${manifest.hasCode}">
    480             <then>
    481                 <echo>Compiling aidl files into Java classes...</echo>
    482                 <aidl executable="${aidl}" framework="${android.aidl}"
    483                         genFolder="${gen.absolute.dir}">
    484                     <source path="${source.absolute.dir}"/>
    485                     <source refid="project.libraries.src"/>
    486                 </aidl>
    487             </then>
    488             <else>
    489                 <echo>hasCode = false. Skipping...</echo>
    490             </else>
    491         </if>
    492     </target>
    493 
    494     <!-- Compiles RenderScript files into Java and bytecode. -->
    495     <target name="-renderscript" depends="-dirs">
    496         <if condition="${manifest.hasCode}">
    497             <then>
    498                 <echo>Compiling RenderScript files into Java classes and RenderScript bytecode...</echo>
    499                 <renderscript executable="${renderscript}"
    500                         framework="${android.rs}"
    501                         genFolder="${gen.absolute.dir}"
    502                         resFolder="${resource.absolute.dir}/raw">
    503                     <source path="${source.absolute.dir}"/>
    504                     <source refid="project.libraries.src"/>
    505                 </renderscript>
    506             </then>
    507             <else>
    508                 <echo>hasCode = false. Skipping...</echo>
    509             </else>
    510         </if>
    511     </target>
    512 
    513     <!-- empty default pre-compile target. Create a similar target in
    514          your build.xml and it'll be called instead of this one. -->
    515     <!-- I2P add depends -->
    516     <target name="-pre-compile" depends="buildrouter" />
    517 
    518     <!-- Compiles this project's .java files into .class files. -->
    519     <target name="compile" depends="-pre-build, -aidl, -renderscript, -resource-src, -pre-compile"
    520                 description="Compiles project's .java files into .class files">
    521         <if condition="${manifest.hasCode}">
    522             <then>
    523                 <!-- If android rules are used for a test project, its classpath should include
    524                      tested project's location -->
    525                 <condition property="extensible.classpath"
    526                         value="${tested.project.absolute.dir}/bin/classes"
    527                         else=".">
    528                     <isset property="tested.project.absolute.dir" />
    529                 </condition>
    530                 <condition property="extensible.libs.classpath"
    531                         value="${tested.project.absolute.dir}/libs"
    532                         else="${jar.libs.dir}">
    533                     <isset property="tested.project.absolute.dir" />
    534                 </condition>
    535                 <javac encoding="${java.encoding}"
    536                         source="${java.source}" target="${java.target}"
    537                         debug="true" extdirs=""
    538                         includeantruntime="false"
    539                         destdir="${out.classes.absolute.dir}"
    540                         bootclasspathref="android.target.classpath"
    541                         verbose="${verbose}"
    542                         classpath="${extensible.classpath}"
    543                         classpathref="jar.libs.ref">
    544                     <src path="${source.absolute.dir}" />
    545                     <src path="${gen.absolute.dir}" />
    546                     <src refid="project.libraries.src" />
    547                     <classpath>
    548                         <fileset dir="${extensible.libs.classpath}" includes="*.jar" />
    549                     </classpath>
    550                 </javac>
    551             </then>
    552             <else>
    553                 <echo>hasCode = false. Skipping...</echo>
    554             </else>
    555         </if>
    556     </target>
    557 
    558     <!-- empty default post-compile target. Create a similar target in
    559          your build.xml and it'll be called instead of this one. -->
    560     <!-- I2P add depends -->
    561     <target name="-post-compile" depends="hackcleanup, jbigi" />
    562 
    563     <!-- Obfuscate target
    564         This is only active in release builds when proguard.config is defined
    565         in default.properties.
    566 
    567         To replace Proguard with a different obfuscation engine:
    568         Override the following targets in your build.xml, before the call to <setup>
    569             -release-obfuscation-check
    570                 Check whether obfuscation should happen, and put the result in a property.
    571             -debug-obfuscation-check
    572                 Obfuscation should not happen. Set the same property to false.
    573             -obfuscate
    574                 ** Make sure unless="do.not.compile" is used in the target definition **
    575                 check if the property set in -debug/release-obfuscation-check is set to true.
    576                 If true:
    577                     Perform obfuscation
    578                     Set property out.dex.input.absolute.dir to be the output of the obfuscation
    579     -->
    580     <target name="-obfuscate" unless="do.not.compile">
    581         <if condition="${proguard.enabled}">
    582             <then>
    583                 <property name="obfuscate.absolute.dir" location="${out.absolute.dir}/proguard" />
    584                 <property name="preobfuscate.jar.file" value="${obfuscate.absolute.dir}/original.jar" />
    585                 <property name="obfuscated.jar.file" value="${obfuscate.absolute.dir}/obfuscated.jar" />
    586                 <!-- input for dex will be proguard's output -->
    587                 <property name="out.dex.input.absolute.dir" value="${obfuscated.jar.file}" />
    588 
    589                 <!-- Add Proguard Tasks -->
    590                 <property name="proguard.jar" location="${android.tools.dir}/proguard/lib/proguard.jar" />
    591                 <taskdef name="proguard" classname="proguard.ant.ProGuardTask" classpath="${proguard.jar}" />
    592 
    593                 <!-- Set the android classpath Path object into a single property. It'll be
    594                      all the jar files separated by a platform path-separator.
    595                 -->
    596                 <property name="android.libraryjars" refid="android.target.classpath"/>
    597                 <!-- Build a path object with all the jar files that must be obfuscated.
    598                      This include the project compiled source code and any 3rd party jar
    599                      files. -->
    600                 <path id="project.jars.ref">
    601                     <pathelement location="${preobfuscate.jar.file}" />
    602                     <path refid="jar.libs.ref" />
    603                 </path>
    604                 <!-- Set the project jar files Path object into a single property. It'll be
    605                      all the jar files separated by a platform path-separator.
    606                 -->
    607                 <property name="project.jars" refid="project.jars.ref" />
    608 
    609                 <mkdir dir="${obfuscate.absolute.dir}" />
    610                 <delete file="${preobfuscate.jar.file}"/>
    611                 <delete file="${obfuscated.jar.file}"/>
    612                 <jar basedir="${out.classes.dir}" destfile="${preobfuscate.jar.file}" />
    613                 <proguard>
    614                     @${proguard.config}
    615                     -injars ${project.jars}
    616                     -outjars ${obfuscated.jar.file}
    617                     -libraryjars ${android.libraryjars}
    618                     -dump ${obfuscate.absolute.dir}/dump.txt
    619                     -printseeds ${obfuscate.absolute.dir}/seeds.txt
    620                     -printusage ${obfuscate.absolute.dir}/usage.txt
    621                     -printmapping ${obfuscate.absolute.dir}/mapping.txt
    622                 </proguard>
    623             </then>
    624         </if>
    625     </target>
    626 
    627     <!-- Converts this project's .class files into .dex files -->
    628     <target name="-dex" depends="compile, -post-compile, -obfuscate"
    629             unless="do.not.compile">
    630         <if condition="${manifest.hasCode}">
    631             <then>
    632                 <dex-helper />
    633             </then>
    634             <else>
    635                 <echo>hasCode = false. Skipping...</echo>
    636             </else>
    637         </if>
    638     </target>
     177         override this because the ant task com.android.ant.AaptExecLoopTask has issues:
     178             a) it uses version.code which main_rules sets to "" and
     179             b) it can't set versionName via the aapt task, have to use the aapt command line
     180    -->
    639181
    640182    <!-- Puts the project's resources into the output package file
     
    645187    <target name="-package-resources">
    646188        <echo>Packaging resources</echo>
    647         <aapt executable="${aapt}"
    648                 command="package"
    649                 versioncode="${version.code}"
    650                 debug="${build.packaging.debug}"
    651                 manifest="AndroidManifest.xml"
    652                 assets="${asset.absolute.dir}"
    653                 androidjar="${android.jar}"
    654                 apkfolder="${out.absolute.dir}"
    655                 resourcefilename="${resource.package.file.name}"
    656                 resourcefilter="${aapt.resource.filter}">
    657             <res path="${resource.absolute.dir}" />
    658             <!-- <nocompress /> forces no compression on any files in assets or res/raw -->
    659             <!-- <nocompress extension="xml" /> forces no compression on specific file extensions in assets and res/raw -->
    660         </aapt>
    661     </target>
    662 
    663     <!-- Packages the application and sign it with a debug key. -->
    664     <target name="-package-debug-sign" depends="-dex, -package-resources">
    665         <package-helper
    666                 output.filepath="${out.debug.unaligned.file}" />
    667     </target>
    668 
    669     <!-- Packages the application without signing it. -->
    670     <target name="-package-release" depends="-dex, -package-resources">
    671         <package-helper
    672                 output.filepath="${out.unsigned.file}"/>
    673     </target>
    674 
    675     <target name="-compile-tested-if-test" if="tested.project.dir" unless="do.not.compile.again">
    676        <subant target="compile">
    677             <fileset dir="${tested.project.absolute.dir}" includes="build.xml" />
    678        </subant>
    679     </target>
    680 
    681     <target name="-debug-obfuscation-check">
    682         <!-- proguard is never enabled in debug mode -->
    683         <property name="proguard.enabled" value="false"/>
    684     </target>
    685 
    686     <target name="-set-debug-mode" depends="-debug-obfuscation-check">
    687         <!-- property only set in debug mode.
    688              Useful for if/unless attributes in target node
    689              when using Ant before 1.8 -->
    690         <property name="build.mode.debug" value="true"/>
    691 
    692         <!-- whether the build is a debug build. always set. -->
    693         <property name="build.packaging.debug" value="true" />
    694 
    695         <!-- signing mode: debug -->
    696         <property name="build.signing.debug" value="true" />
    697 
    698     </target>
    699 
    700     <!-- Builds debug output package, provided all the necessary files are already dexed -->
    701     <target name="debug" depends="-set-debug-mode, -compile-tested-if-test, -package-debug-sign"
    702                 description="Builds the application and signs it with a debug key.">
    703         <zipalign-helper in.package="${out.debug.unaligned.file}"
    704                                    out.package="${out.debug.file}" />
    705         <echo>Debug Package: ${out.debug.file}</echo>
    706     </target>
    707 
    708     <!-- called through target 'release'. Only executed if the keystore and
    709          key alias are known but not their password. -->
    710     <target name="-release-prompt-for-password" if="has.keystore" unless="has.password">
    711         <!-- Gets passwords -->
    712         <input
    713                 message="Please enter keystore password (store:${key.store}):"
    714                 addproperty="key.store.password" />
    715         <input
    716                 message="Please enter password for alias '${key.alias}':"
    717                 addproperty="key.alias.password" />
    718     </target>
    719 
    720     <!-- called through target 'release'. Only executed if there's no
    721          keystore/key alias set -->
    722     <target name="-release-nosign" unless="has.keystore">
    723         <echo>No key.store and key.alias properties found in build.properties.</echo>
    724         <echo>Please sign ${out.unsigned.file} manually</echo>
    725         <echo>and run zipalign from the Android SDK tools.</echo>
    726     </target>
    727 
    728     <target name="-release-obfuscation-check">
    729         <condition property="proguard.enabled" value="true" else="false">
    730             <and>
    731                 <isset property="build.mode.release" />
    732                 <isset property="proguard.config" />
    733             </and>
    734         </condition>
    735         <if condition="${proguard.enabled}">
    736             <then>
    737                 <!-- Secondary dx input (jar files) is empty since all the
    738                      jar files will be in the obfuscated jar -->
    739                 <path id="out.dex.jar.input.ref" />
    740             </then>
    741         </if>
    742     </target>
    743 
    744     <target name="-set-release-mode">
    745         <!-- release mode is only valid if the manifest does not explicitly
    746              set debuggable to true. default is false.
    747              We actually store build.packaging.debug, not build.release -->
    748         <xpath input="AndroidManifest.xml" expression="/manifest/application/@android:debuggable"
    749                 output="build.packaging.debug" default="false"/>
    750 
    751         <!-- signing mode: release -->
    752         <property name="build.signing.debug" value="false" />
    753 
    754         <if condition="${build.packaging.debug}">
    755             <then>
    756                 <echo>*************************************************</echo>
    757                 <echo>****  Android Manifest has debuggable=true   ****</echo>
    758                 <echo>**** Doing DEBUG packaging with RELEASE keys ****</echo>
    759                 <echo>*************************************************</echo>
    760             </then>
    761             <else>
    762                 <!-- property only set in release mode.
    763                      Useful for if/unless attributes in target node
    764                      when using Ant before 1.8 -->
    765                 <property name="build.mode.release" value="true"/>
    766             </else>
    767         </if>
    768     </target>
    769 
    770     <!-- This runs -package-release and -release-nosign first and then runs
    771          only if release-sign is true (set in -release-check,
    772          called by -release-no-sign)-->
    773     <target name="release"
    774                 depends="-set-release-mode, -release-obfuscation-check, -package-release, -release-prompt-for-password, -release-nosign"
    775                 if="has.keystore"
    776                 description="Builds the application. The generated apk file must be signed before
    777                             it is published.">
    778         <!-- Signs the APK -->
    779         <echo>Signing final apk...</echo>
    780         <signjar
    781                 jar="${out.unsigned.file}"
    782                 signedjar="${out.unaligned.file}"
    783                 keystore="${key.store}"
    784                 storepass="${key.store.password}"
    785                 alias="${key.alias}"
    786                 keypass="${key.alias.password}"
    787                 verbose="${verbose}" />
    788 
    789         <!-- Zip aligns the APK -->
    790         <zipalign-helper in.package="${out.unaligned.file}"
    791                                    out.package="${out.release.file}" />
    792         <echo>Release Package: ${out.release.file}</echo>
    793     </target>
    794 
    795     <target name="install" depends="debug"
    796                 description="Installs/reinstalls the debug package onto a running
    797                             emulator or device. If the application was previously installed,
    798                             the signatures must match." >
    799         <install-helper />
    800     </target>
    801 
    802     <target name="-uninstall-check">
    803         <condition property="uninstall.run">
    804            <isset property="manifest.package" />
    805         </condition>
    806     </target>
    807 
    808     <target name="-uninstall-error" depends="-uninstall-check" unless="uninstall.run">
    809         <echo>Unable to run 'ant uninstall', manifest.package property is not defined.
    810         </echo>
    811     </target>
    812 
    813     <!-- Uninstalls the package from the default emulator/device -->
    814     <target name="uninstall" depends="-uninstall-error" if="uninstall.run"
    815                 description="Uninstalls the application from a running emulator or device.">
    816         <echo>Uninstalling ${manifest.package} from the default emulator or device...</echo>
    817         <exec executable="${adb}" failonerror="true">
    818             <arg line="${adb.device.arg}" />
    819             <arg value="uninstall" />
    820             <arg value="${manifest.package}" />
     189        <exec executable="${aapt}" failonerror="true" >
     190            <arg value="package" />
     191            <arg value="--version-code" />
     192            <arg value="${my.version.code}" />
     193            <arg value="--version-name" />
     194            <arg value="${my.version.name}" />
     195            <arg value="-f" />
     196            <arg value="-m" />
     197            <arg value="-M" />
     198            <arg value="AndroidManifest.xml" />
     199            <arg value="-I" />
     200            <arg value="${android.jar}" />
     201            <arg value="-S" />
     202            <arg value="${resource.absolute.dir}" />
     203            <arg value="-J" />
     204            <arg value="${gen.absolute.dir}" />
     205            <arg value="-F" />
     206            <arg value="${out.absolute.dir}/${resource.package.file.name}" />
    821207        </exec>
    822208    </target>
    823209
    824     <target name="clean" description="Removes output files created by other targets.">
    825         <delete dir="${out.absolute.dir}" verbose="${verbose}" />
    826         <delete dir="${gen.absolute.dir}" verbose="${verbose}" />
    827     </target>
    828 
    829     <!-- Targets for code-coverage measurement purposes, invoked from external file -->
    830 
    831     <!-- Emma-instruments tested project classes (compiles the tested project if necessary)
    832              and writes instrumented classes to ${instrumentation.absolute.dir}/classes -->
    833     <target name="-emma-instrument" depends="compile">
    834         <echo>Instrumenting classes from ${out.absolute.dir}/classes...</echo>
    835         <!-- It only instruments class files, not any external libs -->
    836         <emma enabled="true">
    837             <instr verbosity="${verbosity}"
    838                    mode="overwrite"
    839                    instrpath="${out.absolute.dir}/classes"
    840                    outdir="${out.absolute.dir}/classes">
    841             </instr>
    842             <!-- TODO: exclusion filters on R*.class and allowing custom exclusion from
    843                  user defined file -->
    844         </emma>
    845     </target>
    846 
    847     <target name="-dex-instrumented" depends="-emma-instrument">
    848        <dex-helper>
    849           <extra-parameters>
    850             <arg value="--no-locals" />
    851           </extra-parameters>
    852           <external-libs>
    853             <fileset file="${emma.dir}/emma_device.jar" />
    854           </external-libs>
    855        </dex-helper>
    856     </target>
    857 
    858     <!-- Invoked from external files for code coverage purposes -->
    859     <target name="-package-with-emma" depends="-dex-instrumented, -package-resources">
    860         <package-helper
    861                 output.filepath="${out.debug.unaligned.file}">
    862             <extra-jars>
    863                 <!-- Injected from external file -->
    864                 <jarfile path="${emma.dir}/emma_device.jar" />
    865             </extra-jars>
    866         </package-helper>
    867     </target>
    868 
    869     <target name="-debug-with-emma" depends="-set-debug-mode, -package-with-emma">
    870         <zipalign-helper in.package="${out.debug.unaligned.file}"
    871                                    out.package="${out.debug.file}" />
    872     </target>
    873 
    874     <target name="-install-with-emma" depends="-debug-with-emma">
    875         <install-helper />
    876     </target>
    877 
    878     <!-- End of targets for code-coverage measurement purposes -->
    879 
    880     <target name="help">
    881         <!-- displays starts at col 13
    882               |13                                                              80| -->
    883         <echo>Android Ant Build. Available targets:</echo>
    884         <echo>   help:      Displays this help.</echo>
    885         <echo>   clean:     Removes output files created by other targets.</echo>
    886         <echo>   compile:   Compiles project's .java files into .class files.</echo>
    887         <echo>   debug:     Builds the application and signs it with a debug key.</echo>
    888         <echo>   release:   Builds the application. The generated apk file must be</echo>
    889         <echo>              signed before it is published.</echo>
    890         <echo>   install:   Installs/reinstalls the debug package onto a running</echo>
    891         <echo>              emulator or device.</echo>
    892         <echo>              If the application was previously installed, the</echo>
    893         <echo>              signatures must match.</echo>
    894         <echo>   uninstall: Uninstalls the application from a running emulator or</echo>
    895         <echo>              device.</echo>
    896     </target>
    897210</project>
  • android/default.properties

    r15b9615 r7e84451  
    99
    1010# Project target.
    11 target=android-3
     11target=android-8
  • android/scripts/setversion.sh

    r15b9615 r7e84451  
    5050
    5151echo "Android version: '$VERSIONSTRING' (${VERSIONINT})"
     52echo "my.version.name=${VERSIONSTRING}" > version.properties
     53echo "my.version.code=${VERSIONINT}" >> version.properties
    5254
    5355SUBST='s/android.versionCode="[0-9]"/android.versionCode="'${VERSIONINT}'"/'
  • android/src/net/i2p/router/I2PAndroid.java

    r15b9615 r7e84451  
    77import android.content.res.Resources;
    88import android.content.res.Resources.NotFoundException;
     9import android.os.Build;
    910import android.os.Bundle;
    1011
     
    2021import net.i2p.router.RouterLaunch;
    2122import net.i2p.util.OrderedProperties;
     23import net.i2p.util.NativeBigInteger;
    2224
    2325public class I2PAndroid extends Activity
    2426{
    2527    static Context _context;
    26     private String DIR = "/data/data/net.i2p.router/files";
     28    private String _myDir;
    2729
    2830    /** Called when the activity is first created. */
     
    3436
    3537        _context = this;  // Activity extends Context
    36         DIR = getFilesDir().getAbsolutePath();
     38        _myDir = getFilesDir().getAbsolutePath();
    3739        debugStuff();
    3840        initialize();
    39         // 300ms per run
     41        // 300ms per run on emulator on eeepc
    4042        // 5x slower than java on my server and 50x slower than native on my server
    41         // NativeBigInteger.main(null);
     43        // 33 ms native 29 ms java moto droid 2.2.2
     44        NativeBigInteger.main(null);
    4245    }
    4346
     
    105108        System.err.println("user.home" + ": " + System.getProperty("user.home"));
    106109        System.err.println("user.name" + ": " + System.getProperty("user.name"));
    107         System.err.println("getFilesDir()" + ": " + DIR);
     110        System.err.println("getFilesDir()" + ": " + _myDir);
    108111        System.err.println("Package" + ": " + getPackageName());
    109112        System.err.println("Version" + ": " + getOurVersion());
     113        System.err.println("MODEL" + ": " + Build.MODEL);
     114        System.err.println("DISPLAY" + ": " + Build.DISPLAY);
     115        System.err.println("VERSION" + ": " + Build.VERSION.RELEASE);
     116        System.err.println("SDK" + ": " + Build.VERSION.SDK);
    110117    }
    111118
     
    128135
    129136        // Set up the locations so Router and WorkingDir can find them
    130         System.setProperty("i2p.dir.base", DIR);
    131         System.setProperty("i2p.dir.config", DIR);
    132         System.setProperty("wrapper.logfile", DIR + "/wrapper.log");
     137        System.setProperty("i2p.dir.base", _myDir);
     138        System.setProperty("i2p.dir.config", _myDir);
     139        System.setProperty("wrapper.logfile", _myDir + "/wrapper.log");
    133140    }
    134141
     
    179186                System.err.println("Creating file " + f + " from resource");
    180187            } finally {
    181                 try { fin.close(); } catch (IOException ioe) {}
     188                if (fin != null) try { fin.close(); } catch (IOException ioe) {}
    182189            }
    183190
  • core/java/src/net/i2p/util/NativeBigInteger.java

    r15b9615 r7e84451  
    499499        } catch (UnsatisfiedLinkError ule) {
    500500            if (_isAndroid) {
    501                 // temp debug
     501                // Unfortunately,
     502                // this is not interesting on Android, it says "file not found"
     503                // on link errors too.
    502504                warn("jbigi loadLibrary() fail", ule);
    503                 try {
    504                     System.load("/data/data/net.i2p.router/lib/libjbigi.so");
    505                     return true;
    506                 } catch (Throwable t) {
    507                     warn("jbigi load() fail", t);
    508                 }
    509                 warn("Is the file there? " + (new File("/data/data/net.i2p.router/lib/libjbigi.so")).exists());
    510505            }
    511506            return false;
Note: See TracChangeset for help on using the changeset viewer.