distriqt / ANE-CustomResources

Android Custom Resources for AIR Applications
https://airnativeextensions.com
15 stars 4 forks source link

error while compiling with com.distriqt.CustomResources.ane #9

Closed Xgamefactory closed 5 years ago

Xgamefactory commented 7 years ago
dx tool failed:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/distriqt/extension/custo
mresources/R$attr;
        at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:12
2)
        at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
        at com.android.dx.command.dexer.Main.processClass(Main.java:737)
        at com.android.dx.command.dexer.Main.processFileBytes(Main.java:678)
        at com.android.dx.command.dexer.Main.access$300(Main.java:83)
        at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:607)
        at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpen
er.java:284)
        at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.j
ava:166)
        at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java
:144)
        at com.android.dx.command.dexer.Main.processOne(Main.java:637)
        at com.android.dx.command.dexer.Main.processAllFiles(Main.java:511)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:281)
        at com.android.dx.command.dexer.Main.run(Main.java:247)
        at com.android.dx.command.dexer.Main.main(Main.java:215)
        at com.android.dx.command.Main.main(Main.java:106)
1 error; aborting
                <extensionID>com.distriqt.Core</extensionID> 
        <extensionID>com.distriqt.AndroidSupport</extensionID>
        <extensionID>com.distriqt.Volume</extensionID>
        <extensionID>com.distriqt.Notifications</extensionID>
        <extensionID>com.distriqt.Exceptions</extensionID>
        <extensionID>com.distriqt.CustomResources</extensionID>

ane file generated with ANE-CustomResources and

rename zip to ane

com.distriqt.CustomResources.zip

marchbold commented 7 years ago

When exactly is this error occurring?

Xgamefactory commented 7 years ago

during the packaging apk

package error com distriqt customresources

Xgamefactory commented 7 years ago

maybe because there are two distriqt.extension.customresources.android.jar inside Android-ARM and Android-x86 folders ?

or conflict with other distriqt extensions

marchbold commented 7 years ago

There shouldn't be any other extensions using that package name. Are you sure you only have one version of the custom resources ANE in your project?

Xgamefactory commented 7 years ago

yes only one ane file.

Xgamefactory commented 7 years ago

i have attached ane file generated by your ant compiler. if you have a test com.distriqt.CustomResources.ane send me i will check it maybe there is something from with my CustomResources.ane

marchbold commented 7 years ago

https://www.dropbox.com/s/7lr4h84nvxtk027/com.distriqt.CustomResources.ane?dl=0

Xgamefactory commented 7 years ago

the plugin you have sent has compiled without error.

but mine gives error. there is only icons generated from https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.type=image&source.space.trim=1&source.space.pad=0&name=ic_stat_notificationicon

Xgamefactory commented 7 years ago

did you compile it with your ant script that on github ? it seams adding R class into jar that is the conflict. Weird but there is no resource defined in java library in your ane file. no ic_stat_distriqt resource defined in your ane file but it works. i guess it is already defined in your core extension.

distriqt extension customresources_conflic_r

Xgamefactory commented 7 years ago

You ant file was generating R file that was the conflict. generated resource after removing R gen task worked perfectly.

marchbold commented 7 years ago

Can you explain a little more what you removed?

This script is exactly what we used to generate the example I sent you so that suggests to me that there is something different in our environments that's causing differences in the generated jar file.

Xgamefactory commented 7 years ago

error tells about R file conflict so after removing this part it works. win7 64bit java 1.7 jdk air sdk 23

<!-- Builds the R file -->

        <aapt executable="${aapt}"

                command="package"

                verbose="false"

                manifest="${android.dir}/AndroidManifest.xml"

                originalManifestPackage="${android.package}"

                androidjar="${android.sdk}/platforms/${android.target}/android.jar"

                rfolder="${android.dir}/gen"

                nonConstantId="${android.library}"

                libraryResFolderPathRefid="project.library.res.folder.path"

                libraryPackagesRefid="project.library.packages"

                libraryRFileRefid="project.library.bin.r.file.path"

                ignoreAssets="true"

                binFolder="${android.dir}/${output.tmpdir}"

                proguardFile="${android.dir}/proguard.cfg">

            <res path="${android.dir}/res" />

        </aapt>
marchbold commented 7 years ago

I'll have to look into that, that section actually packages the resources so I'm not sure you are removing the correct part. You definitely are packaging the jar with this script?

Xgamefactory commented 7 years ago

yes. with this R building function it generates R class inside jar file check your ane and you will see that there is no R class inside your jar file.

marchbold commented 7 years ago

It should be excluded from the jar.

https://github.com/distriqt/ANE-CustomResources/blob/master/build.xml#L178

Must be something with the version of Java you have not accepting that parameter.

marc-squarewave commented 7 years ago

How was this resolved? I'm receiving a similar error upon compiling an App that is using the CustomResouces ANE:

Unknown error.

unexpected failure: duplicate entry: air/com/distriqt/CustomResources/R.class java.util.zip.ZipException: duplicate entry: air/com/distriqt/CustomResources.class at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:232)

Note: I was able to bypass this by removing classes.jar from the ANE. Though I haven't been able to test my app to see if the resources are present. I'm using this for the notification icons and the value.xml (Firebase). I'm using the latest Android Studio SDK, Java, and AIR 25.

marchbold commented 7 years ago

Are you using the new version of the script. It should have a completely new build process using AndroidStudio which shouldn't have this issue.

marc-squarewave commented 7 years ago

I believe so ... I grabbed it on Friday. build file is dated 6/19/17? If removing classes.jar from the ANE fixes it, I'm okay for now. No need to hop on this.

cevansOTBS commented 7 years ago

I'm also getting that exact same issue with the duplicate R.class when I compile my app with the customResources ANE. I downloaded the ANE-CustomResources-master zip file on 6/30/17

marchbold commented 7 years ago

Can you tell me about your build environment, java version , android studio, os, air sdk?

cevansOTBS commented 7 years ago

Ant 1.10.1 Android 2.3.3 JDK 1.8.0.131 Windows 7 64bit AIR26 SDK

marc-squarewave commented 7 years ago

MacOS Ant 1.9.6 JDK 1.8.0_45 AIR25 SDK Android 2.3.3

is there a requirement for Android SDK Platform? Which are targeting?

marchbold commented 7 years ago

What settings are you changing in the config ?

marc-squarewave commented 7 years ago

Only the top portion:air.sdk, android.sdk and android.package (i'm using firebase).

cevansOTBS commented 7 years ago

Same here. I just modified those three values in the build.config file.

cevansOTBS commented 7 years ago

Oh, I also did add the FLEX_HOME property to the build.xml. Like so: <property name="FLEX_HOME" value="C:\Programs\Adobe Flash Builder 4.7 (64 Bit)\sdks\4.6.0" />

marchbold commented 7 years ago

Could you try using a android.package that is slightly different from your application package?

cevansOTBS commented 7 years ago

Great, that solved the issue.

For reference, I originally had this: android.package = air.myapp

I changed it to this: android.package = air.myapp.extension.customresources

Now I'm able to successfully compile the AIR APK in Flash/Animate with the custom resource ANE. Probably should add a small note in the custom resource documentation to not name the android package as the same as the application package.

Thanks!

marc-squarewave commented 7 years ago

Sorry - finally had a chance to test this. Switching it to the following worked like a charm (with Firebase) - android.package = air.com.myapp.CustomResourcesExtension

cevansOTBS commented 7 years ago

Actually I'm still encountering an error related to this.

So I'm able to Publish the Android in Animate. However I can no longer run a Test Movie of the app. When I press CTRL+T to run the Test Movie in Animate, I get "Test movie launch failed" with the following error: "The content cannot be loaded because there was a problem loading an extension: Error: Duplicate platform Android-ARM found for extension com.distriqt.CustomResources"

When I remove the remove extension, then the test movie is able to run again.

marchbold commented 7 years ago

Sounds like you have 2 extensions in your extensions path using that ID. Make sure you only have the extension you require in your application dir.