Question

These days, I am trying to integrate AdMob into my Adobe Air based android app, with Google Play Service. After I get the ane file ready, I got following error after I debug app in Flash builder 4.6:

Error occurred while packaging the application:

dx tool failed: UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/R$attr; at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123) at com.android.dx.dex.file.DexFile.add(DexFile.java:143) at com.android.dx.command.dexer.Main.processClass(Main.java:301) at com.android.dx.command.dexer.Main.processFileBytes(Main.java:278) at com.android.dx.command.dexer.Main.access$100(Main.java:56) at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:229) at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244) at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:130) at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108) at com.android.dx.command.dexer.Main.processOne(Main.java:247) at com.android.dx.command.dexer.Main.processAllFiles(Main.java:183) at com.android.dx.command.dexer.Main.run(Main.java:139) at com.android.dx.command.dexer.Main.main(Main.java:120) at com.android.dx.command.Main.main(Main.java:89) 1 error; aborting

This problem is quite similar with post: Cannot build Android Release Build on Flash Builder 4.7 due to "dx tool failed"

I know there must be something wrong with my ane file. But I really don't know where is the problem. Here is my android native extension .jar folder: enter image description here

Here is my platform.xml file:

<platform xmlns="http://ns.adobe.com/air/extension/4.0"> 
    <packagedDependencies>
        <packagedDependency>android-support-v4.jar</packagedDependency>
        <packagedDependency>google-play-services.jar</packagedDependency> 
    </packagedDependencies> 
    <packagedResources>
        <packagedResource> 
            <packageName>com.google.android.gms</packageName> 
            <folderName>google-play-services-res</folderName> 
        </packagedResource> 
    </packagedResources>
</platform>

I am using following command line to compile the ane file:

adt -package -target ane Output.ane extension.xml -swc AdmobLibrary.swc -platform Android-ARM -platformoptions platform.xml -C android . -platform default -C default .

I can get the ane file. But after debuging my Flex app, the error is coming out.

Was it helpful?

Solution

I finally found the problem solution. The problem is in the process of exporting native extension to .jar file. More specifically, when I export my android project to .jar file, I made a mistake. I select the whole java project files to export into .jar file, including gen folder which is not necessary. Here is the screen shot:

What I am doing is incorrect: enter image description here

This is the correct way: enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top