Extension Android - Error during Base64 decoding haxe/openfl side

Hi all, i’m looking to create an extension in order to make a my own image loader targetting android.
I’m starting creating an extension use lime specific tool. In order to achive my goal I must import a jar on extension. I’ve trying to put jar into dependencies/android/lib/ and modify include.xml as you can see below.

<?xml version="1.0" encoding="utf-8"?>
	<ndll name="redevoandroidspecifics" />
	<!-- Use the following for an Android Java extension, not needed otherwise -->
	<dependency name="redevoandroidspecifics" path="dependencies/android" if="android" />
	<android extension="org.haxe.extension.RedEvoAndroidSpecifics" />
	<java path="dependencies/android" />
	<java path="dependencies/android/lib/android-async-http.jar" />

As a result I’ve this error:

[javac] D:\code\redevo\RedEvoCode\ProgettiInLavorazione\redevoclients\redevoclients\games-generated\AndroidDevelop\Export\android\bin\deps\redevoandroidspecifics\src\org\haxe\extension\RedEvoAndroidSpecifics.java:13: error: package com.loopj.android does not exist
[javac] import com.loopj.android.*;
[javac] ^

I’ve made some try but I obtain always same error.
Can someone help?

Thanks, David.

Solved many issues about this extension, now i’ve one during dexing, the above was my fault to consider an import in java part of code.

Anyone have experience with these kind of issues?

      [dex] Converting compiled files and external libraries into D:\code\redevo\RedEvoCode\ProgettiInLavorazione\redevoclients\redevoclients\games-generated\AndroidDevelop\Export\android\bin\bin\classes.dex...
       [dx] Merged dex A (106 defs/57.8KiB) with dex B (8 defs/5.9KiB). Result is 114 defs/72.7KiB. Took 0.1s
       [dx] Merged dex A (114 defs/72.7KiB) with dex B (47 defs/56.7KiB). Result is 161 defs/154.3KiB. Took 0.0s
       [dx] com.android.dex.DexException: Multiple dex files define Lorg/haxe/extension/RedEvoAndroidSpecifics$1$1;
[dx] 	at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:593)
       [dx] 	at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:551)
       [dx] 	at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:532)
       [dx] 	at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:169)
       [dx] 	at com.android.dx.merge.DexMerger.merge(DexMerger.java:187)
       [dx] 	at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
       [dx] 	at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
       [dx] 	at com.android.dx.command.dexer.Main.run(Main.java:230)
       [dx] 	at com.android.dx.command.dexer.Main.main(Main.java:199)
       [dx] 	at com.android.dx.command.Main.main(Main.java:103)

Thanks in advance.

Check for two classes named RedEvoAndroidSpecifics. (I’ve been known to forget to update the class name after copying a file.)

If that isn’t it, check to make sure you aren’t including the same Java library twice. Also, try deleting Export/android/bin, in case there’s an old Java file in there. (OpenFL makes no attempt to keep that folder clean.)

Hi player_03! I read many posts and articles from you on OpenFL Extensions, really thanks for all your effort.
And you are right! One of my library was imported two times in include.xml, was not simple to find because error doesn’t regard this lib but main java file extension.

Really Thanks again!

I’m near to solution but there’s always something between me and goal.
I’ve decided to encode image bytes using Java Base64 encoder in order to pass String into HaxeObject.callback.directly pass byte[] cause > 25 call JNI crash.

String byteString = Base64.encodeToString(responseBody,Base64.DEFAULT);

Arriving on the other side I’ve an app crash during Base64 decode on OpenFL/Haxe side. I’ve tryed various way but no one help to overtake decode step. Last try is:

var bytes = StringHelper.base64Decode(base64);
		return ByteArray.fromBytes(bytes);

Also tried Base64 and worked around it without result.
Anyone has experience with this kind of encoding/decoding? I’ve no specific needs to use Base64 to encode to a String and I’m available to change this way for another.

Thanks in advance.

I’ve been encoding/decoding images between java and haxe like this:

public static String encodeToBase64(Bitmap image, Bitmap.CompressFormat compressFormat, int quality)
        ByteArrayOutputStream byteArrayOS = new ByteArrayOutputStream();
        image.compress(compressFormat, quality, byteArrayOS);
        return Base64.encodeToString(byteArrayOS.toByteArray(), Base64.DEFAULT | Base64.NO_WRAP);
private static var BASE_64_CHARS:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
private static function base64Decode (base64:String):ByteArray
      base64 = StringTools.trim (base64);
      base64 = StringTools.replace (base64, "=", "");
      var base64Encoder :BaseCode= new BaseCode (Bytes.ofString (BASE_64_CHARS));
      var bytes = base64Encoder.decodeBytes (Bytes.ofString (base64));
      return ByteArray.fromBytes (bytes);
1 Like

Really thanks hcwdikk I’m going to try!
For other users I suppose you mean this for BASE_64_CHARS:

private static var BASE_64_CHARS:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

Thanks again, David.

Yeah, sorry, I forgot about that. I’ve added it to my post :slight_smile:

Working perfectly, really thanks!