• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

<packageName> question when building an Android ANE

Explorer ,
Apr 24, 2015 Apr 24, 2015

Copy link to clipboard

Copied

Hi,

I'm trying to implement an external library ANE wrapper for Android.

I'm always receiving "class not found" error message in LogCat. No problem accessing native code, but when I try to access to external library functions it fails.

I've tried

External library inside Air native extension for android

How to include additional Jar in Android Native Extension for Adobe Air Mobile - Stack Overflow

Unsuccessfuly.

Reading these docs: Adobe Flash Platform * Including resources in your native extension package I think I could have a problem loading the resources and, because of that, not access to the class properly or crashing somewhere.

My platformoptions file

<platform xmlns="http://ns.adobe.com/air/extension/17.0">

    <packagedDependencies>

        <packagedDependency>my_sdk.jar</packagedDependency>

    </packagedDependencies>

  <packagedResources>

  <packagedResource>

  <packageName>com.my_sdk</packageName>

  <folderName>res</folderName>

  </packagedResource>

  </packagedResources>

</platform>

My question is, how can I know the "packageName", "res" is the folder where I copied and pasted all the resources from the external library, but the package? I've just written randomly "com.my_sdk"

Thanks!

TOPICS
Development

Views

1.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Apr 26, 2015 Apr 26, 2015

Copy link to clipboard

Copied

You can find out the <packageName> if you're using any classes of third party jar in your ANE.

For example if I am using Google play services library in an ANE then the <packageName> will be com.google.android.gms.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 27, 2015 Apr 27, 2015

Copy link to clipboard

Copied

Hi,

in Google Play Services case is easy, because all the services are implemented in the same package (Setting Up Google Play Services | Android Developers)

But, for example, if you are integrating Facebook sdk the packages could be

com.facebook.android

com.facebook.internal

com.facebook.model

com.facebook.widget

I know it's the firs one because it's the dependency in build.gradle file. Otherwise I don't know how I could know it.

thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Apr 27, 2015 Apr 27, 2015

Copy link to clipboard

Copied

One way to find out packageName is to decompile the jar to know its contents, there are lot of third party java decompilers present in market.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 27, 2015 Apr 27, 2015

Copy link to clipboard

Copied

That's what I did But, for example, Facebook SDK works with few different packages like

com.facebook.android

com.facebook.internal

com.facebook.model

com.facebook.widget

which one to use? tricky question. Fortunatly, Facebook (and most of third parties SDK) permits to integrate their SDK by gradle, and there you can find the packageName.

In the end I just asked tech support and they answered.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 27, 2015 Apr 27, 2015

Copy link to clipboard

Copied

Setting correctly the package id does not solve my problem, still "class not found" message on logcat.

The jar I'm wrapping does have a lib folder with other jars inside, do you know if I attach them using platformoptions?

It's hard to know what can be wrong, I've tried few different apporaches with no luck. And if I decompile the jar I find the requested classes.

thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 27, 2015 Apr 27, 2015

Copy link to clipboard

Copied

On the other hand, another question.

It¡s a push notification service, so I need to change the Android Manifest. Which manifest should I change? I have a test app using my ANE, and I'm just changing this manifest.xml. I'm not sure if I should change the Android wrapper manifest too.

thanks again!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Apr 27, 2015 Apr 27, 2015

Copy link to clipboard

Copied

For class not found issue- You don't have to provide other JARs which are present in lib folder as they must be merged in the final JAR. Are you packaging this jar within your ANE? Can you please list down the ANE contents package structure and platform.xml here?

For push notification- you have to make changes in the application descriptor's tag itself:

<android>

    <manifestAdditions></manifestAdditions>

</android>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 28, 2015 Apr 28, 2015

Copy link to clipboard

Copied

Yes, if I decompile the ANE the jar files are found inside. But still "class not found" error.

Both, .class and .java clases are inside thirdPartie_sdk.jar

- android

     - res

          - drawable

          - drawable-hdpi

          - ...

     thirdPartie_sdk.jar

     wrapper.jar

     library,swf 

- lib

library.swc

extension.xml

platform-options.xml

platform-options.xml

<platform xmlns="http://ns.adobe.com/air/extension/17.0">

    <packagedDependencies>

        <packagedDependency>thirdPartie_sdk.jar</packagedDependency>

    </packagedDependencies>

  <packagedResources>

       <packagedResource>

            <packageName>com.packageName</packageName>

            <folderName>res</folderName>

       </packagedResource>

  </packagedResources>

</platform>

ANE building

call adt -package -target ane ./lib/appoxee.ane extension.xml -swc library.swc -platform Android-ARM -platformoptions platform-options.xml -C android .

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Apr 28, 2015 Apr 28, 2015

Copy link to clipboard

Copied

What does "lib" folder contain? And also you're not including that in your ANE packaging command.

- android

    - res

          - drawable

          - drawable-hdpi

          - ...

    thirdPartie_sdk.jar

    wrapper.jar

    library,swf

- lib

library.swc

extension.xml

platform-options.xml

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 28, 2015 Apr 28, 2015

Copy link to clipboard

Copied

It's where I build the ane file. Nothing to embed.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Apr 28, 2015 Apr 28, 2015

Copy link to clipboard

Copied

Okay, you're including only one folder of resources "res" and which is for your third party JAR which means your own app doesn't have any resources which need to be included within ANE. If your own ANE JAR has resources then those need to included as well like following:

<packagedResource>

            <packageName>com.myownANE</packageName>

            <folderName>ane-res</folderName>

            <packageName>com.packageName</packageName>

            <folderName>res</folderName>

       </packagedResource>

Also have you tried using this JAR in any native Android app just to check if the library is complete and work fine with the Native Android App?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 28, 2015 Apr 28, 2015

Copy link to clipboard

Copied

My test APP does not have any resources :S

When I have to export the jar file in eclipse, do you know if I should set any special option?

Also have you tried using this JAR in any native Android app just to check if the library is complete and work fine with the Native Android App?

Yep, it works fine.

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Apr 28, 2015 Apr 28, 2015

Copy link to clipboard

Copied

You have to use library project and no special setting is required.

Looks like you're doing everything fine, please log a bug at bugbase.adobe.com with a sample app which is using ANE, AS SWC project, ANE Java project and contents to package the ANE so that issue can be reproduced.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 30, 2015 Apr 30, 2015

Copy link to clipboard

Copied

Ok, I'm sending it.

Anyway, I feel like I'm doind something terrible wrong. Like some missing checkbox or something minor like that.

Can't find any documentation about how to add third party libraries to ANE file, can you tell me if there is any tutorial / sample I could follow?

Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 30, 2015 Apr 30, 2015

Copy link to clipboard

Copied

maybe this will help: Adobe Flash Platform * Creating the native extension package‌

It mentions adding extra android libraries at the bottom.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Apr 30, 2015 Apr 30, 2015

Copy link to clipboard

Copied

To create Android ANE there is a devnet article Developing and using Adobe AIR native extensions for Android devices | Adobe Developer Connection

Accessing third-party native libraries

The original purpose of native extensions was to provide access to native platform features that were not currently covered by the ActionScript API. However, many ActionScript developers targeting Android have expressed a strong interest in taking advantage of available third-party Android libraries that package together a number of popular Android-specific functions, so that they need not reimplement those functions in ActionScript. To use any third party library jar in your project you can use the R* mechanism. For more information, see Developing Native Extensions Guide.

Working with arbitrary assets

In addition to accessing Android native resources, developers often need to access arbitrary resources for assets such as drawables and sound files. These assets are frequently found packaged in arbitrary dependent JAR files instead of a central location, especially for third-party native libraries. To use such assets in your project you can use the R* mechanism. For more information, see Developing Native Extensions Guide.

Adobe help doc to use R* mechanism Adobe Flash Platform * Including resources in your native extension package

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 03, 2015 May 03, 2015

Copy link to clipboard

Copied

LATEST

Thanks to your help, this nightmare is finally over.

The jar library I wanted to embed was broken did not work if you were using Eclipse (discovered while creating a native App with the SDK in Eclipse, it worked in Android Studio and Netbeans). Also, that jar file had 8 more jar files embebed.

In the end, what worked, was to open the jar file and extract all the .java files and add them inside src folder. Add the 8 jar files normally, in platform-options.xml

Terrible week, finally over. Thanks again!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines