From: Jacob N. <jac...@gm...> - 2012-04-11 13:53:02
|
Good work! I didnt try to run it, but it looks good, except that you include way too much in rules.jar: j@jacob-linux-baerbar:/tmp$ ~/bin/dex2jar-0.0.9.8/dex2jar.sh rules.jar dex2jar version: translator-0.0.9.8 dex2jar rules.jar -> rules_dex2jar.jar Done. j@jacob-linux-baerbar:/tmp$ unzip -l rules_dex2jar.jar Archive: rules_dex2jar.jar Length Date Time Name --------- ---------- ----- ---- 468 2012-04-11 15:35 android/annotation/SuppressLint.class 395 2012-04-11 15:35 android/annotation/TargetApi.class 165 2012-04-11 15:35 in/arink/gsoc/pair/BuildConfig.class 204 2012-04-11 15:35 in/arink/gsoc/pair/R$attr.class 267 2012-04-11 15:35 in/arink/gsoc/pair/R$drawable.class 256 2012-04-11 15:35 in/arink/gsoc/pair/R$layout.class 289 2012-04-11 15:35 in/arink/gsoc/pair/R$string.class 358 2012-04-11 15:35 in/arink/gsoc/pair/R.class 789 2012-04-11 15:35 or/apertium/transfer/generated/GeneratedTransferBase.class 2202 2012-04-11 15:35 in/arink/rule/eo_en/eo_en_antaux_t2x.class 43108 2012-04-11 15:35 in/arink/rule/eo_en/eo_en_t1x.class 12690 2012-04-11 15:35 in/arink/rule/eo_en/eo_en_t2x.class 2132 2012-04-11 15:35 in/arink/rule/eo_en/eo_en_t3x.class 503 2012-04-11 15:35 or/apertium/interchunk/ApertiumInterchunk$CommandLineParams.class 3660 2012-04-11 15:35 or/apertium/interchunk/ApertiumInterchunk.class 1049 2012-04-11 15:35 or/apertium/interchunk/Interchunk$InterchunkMode.class 8823 2012-04-11 15:35 or/apertium/interchunk/Interchunk.class 1567 2012-04-11 15:35 or/apertium/interchunk/InterchunkWord.class 1066 2012-04-11 15:35 or/apertium/lttoolbox/Alphabet$IntegerPair.class 7688 2012-04-11 15:35 or/apertium/lttoolbox/Alphabet.class 1976 2012-04-11 15:35 or/apertium/lttoolbox/Compression.class 464 2012-04-11 15:35 or/apertium/lttoolbox/Expander$EntList.class 952 2012-04-11 15:35 or/apertium/lttoolbox/Pair.class 1198 2012-04-11 15:35 or/apertium/transfer/ApertiumRE.class 3934 2012-04-11 15:35 or/apertium/transfer/ApertiumTransfer.class 2104 2012-04-11 15:35 or/apertium/transfer/BufferT.class 3005 2012-04-11 15:35 or/apertium/transfer/MatchExe.class 1295 2012-04-11 15:35 or/apertium/transfer/MatchNode.class 2028 2012-04-11 15:35 or/apertium/transfer/MatchState.class 345 2012-04-11 15:35 or/apertium/transfer/MyGetOpt.class 9374 2012-04-11 15:35 or/apertium/transfer/Transfer.class 3500 2012-04-11 15:35 or/apertium/transfer/TransferClassLoader.class 1122 2012-04-11 15:35 or/apertium/transfer/TransferToken$TransferTokenType.class 542 2012-04-11 15:35 or/apertium/transfer/TransferToken.class 2599 2012-04-11 15:35 or/apertium/transfer/TransferWord.class 1329 2012-04-11 15:35 or/apertium/transfer/WordList.class 3275 2012-04-11 15:35 or/apertium/transfer/compile/ApertiumTransferCompile.class ... etc Basically the rule file should *only* contain 2202 2012-04-11 15:35 in/arink/rule/eo_en/eo_en_antaux_t2x.class 43108 2012-04-11 15:35 in/arink/rule/eo_en/eo_en_t1x.class 12690 2012-04-11 15:35 in/arink/rule/eo_en/eo_en_t2x.class 2132 2012-04-11 15:35 in/arink/rule/eo_en/eo_en_t3x.class Even the superclass (org/apertium/transfer/generated/GeneratedTransferBase.class) *should* not be in the language pair dex file: The loaded classes *should* link with the build in classes when loaded as youve coded below: final String libPath = Environment.getExternalStorageDirectory() + "/apertium/"+MODE+"/rules.jar"; final File tmpDir = getDir("dex", 0); String RulePackage = "in.arink.rule.eo_en"; String classT1x = "eo_en_t1x"; String classT2x = "eo_en_t2x"; String classT3x = "eo_en_t3x"; String classAT2x = "eo_en_antaux_t2x"; final DexClassLoader classloader = new DexClassLoader(libPath, tmpDir.getAbsolutePath(), null, this.getClass().getClassLoader()); final Class<?> Eo_En_t1x = classloader.loadClass(RulePackage+"."+classT1x); final Class<?> Eo_En_t2x = classloader.loadClass(RulePackage+"."+classT2x); final Class<?> Eo_En_t3x = classloader.loadClass(RulePackage+"."+classT3x); final Class<?> Eo_En_At2x = classloader.loadClass(RulePackage+"."+classAT2x); This is because the loaded transfer files will get invoked methods like: // REGULO: DE DET TEMPO (de/ekde tiu januaro -> from this January -- ŝanĝo de prepozicio public void rule2__de_ekde__c_det__tempo(Writer out, TransferWord word1, String blank1, TransferWord word2, String blank2, TransferWord word3) throws IOException Here, for example TransferWord should be the TransferWord class of the containing app, not another version of the TransferWord class included in the language pair which the containing app doesent know about (is this why you have a renamed 'org' to 'or' in your dex/jar file?). but... good work! Jacob 2012/4/11 Arink Verma <ari...@gm...> > Solved: External loading of rule class using dex class loader > > > http://cloud.github.com/downloads/arinkverma/Apertiurm-Androind-app-devlopment/ApertiumCode22.zip > > This zip contains > > /ApertiumAndroid : > This is src of android Apertium application > Included with data of eo-en language pair which will be installed at > /sdcard/apertium/eo-en > > ./Data-eo-en.zip : > Include bin datafile and rules.jar having .dex file for eo-en > language pair > Incase installation fails, this has be extracted at > /sdcard/apertium/ > > /ApertiumEo_En : > Source code for .dex class files in rules.jar > - > Arink Verma > Computer Science and Engineering > Indian Institute of Technology > > > ------------------------------------------------------------------------------ > Better than sec? Nothing is better than sec when it comes to > monitoring Big Data applications. Try Boundary one-second > resolution app monitoring today. Free. > http://p.sf.net/sfu/Boundary-dev2dev > _______________________________________________ > Apertium-stuff mailing list > Ape...@li... > https://lists.sourceforge.net/lists/listinfo/apertium-stuff > -- Jacob Nordfalk <https://plus.google.com/114820443085046080944> http://javabog.dk Android-udvikler og underviser på IHK<http://cv.ihk.dk/diplomuddannelser/itd/vf/MAU>og Lund&Bendsen <https://www.lundogbendsen.dk/undervisning/beskrivelse/LB1809/> |