Skip to main content
luca-mooncat
Participant
May 12, 2015
Answered

Air 16.0 for Android - Unable to use native extension that include android-support-v4 - ClassNotFoundException

  • May 12, 2015
  • 2 replies
  • 1664 views

Hi there,

this is my first question here, and i really need help on this problem. We are struggling since few days on the following error: C

05-12 17:35:29.321: E/AndroidRuntime(26531): FATAL EXCEPTION: IntentService[MCGcmIntentService]

05-12 17:35:29.321: E/AndroidRuntime(26531): Process: air.com.mooncat.androidTest, PID: 26531

05-12 17:35:29.321: E/AndroidRuntime(26531): java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/app/NotificationCompat$Builder;

05-12 17:35:29.321: E/AndroidRuntime(26531): at com.mooncat.MCGooglePlayServices.MCGcmIntentService.sendNotification(MCGcmIntentService.java:92)

05-12 17:35:29.321: E/AndroidRuntime(26531): at com.mooncat.MCGooglePlayServices.MCGcmIntentService.onHandleIntent(MCGcmIntentService.java:48)

05-12 17:35:29.321: E/AndroidRuntime(26531): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)

05-12 17:35:29.321: E/AndroidRuntime(26531): at android.os.Handler.dispatchMessage(Handler.java:102)

05-12 17:35:29.321: E/AndroidRuntime(26531): at android.os.Looper.loop(Looper.java:145)

05-12 17:35:29.321: E/AndroidRuntime(26531): at android.os.HandlerThread.run(HandlerThread.java:61)

05-12 17:35:29.321: E/AndroidRuntime(26531): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.app.NotificationCompat$Builder" on path: DexPathList[[zip file "/data/app/air.com.mooncat.androidTest-1/base.apk"],nativeLibraryDirectories=[/data/app/air.com.mooncat.androidTest-1/lib/arm, /vendor/lib, /system/lib]]

05-12 17:35:29.321: E/AndroidRuntime(26531): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)

05-12 17:35:29.321: E/AndroidRuntime(26531): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)

05-12 17:35:29.321: E/AndroidRuntime(26531): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)

05-12 17:35:29.321: E/AndroidRuntime(26531): ... 6 more

05-12 17:35:29.321: E/AndroidRuntime(26531): Suppressed: java.lang.ClassNotFoundException: android.support.v4.app.NotificationCompat$Builder

05-12 17:35:29.321: E/AndroidRuntime(26531): at java.lang.Class.classForName(Native Method)

05-12 17:35:29.321: E/AndroidRuntime(26531): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)

05-12 17:35:29.321: E/AndroidRuntime(26531): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)

05-12 17:35:29.321: E/AndroidRuntime(26531): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)

05-12 17:35:29.321: E/AndroidRuntime(26531): ... 7 more

05-12 17:35:29.321: E/AndroidRuntime(26531): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

My Native Extension use Google Play Services, and rely on the android support v4. The google play services functions works perfectly ( eg: i'm able to register the token through the google cloud functions ).

I saw this problem also in some other thread in github, and seems they solve it, but it doesn't fit my case. It's like if in the flash publication the android support v4 is 'removed'. I say this because i tried to decompile the generated apk, and i discovered that all the source exist ( like com/something/else, com/google/android/gms/..... ) BUT not the android/support/v4/.... . Instead, seems that the build apk contains only the android/support/v7/appcompat/R.java ( .java because is decompiled ). In the .ane file i have the android-support.v4.jar, and also the contained platform.xml at /META-INF/ANE/Android-ARM/. In the platform.xml i have  this:

<?xml version="1.0" encoding="utf-8" ?>

<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>


In the eclipse project i tried to include the support-v4 library in all the possible ways, like dependency project, external jar, or kept as defult library in the libs folder. Nothing works...


I really can't figure out hot to solve this crazy problem.....

This topic has been closed for replies.
Correct answer luca-mooncat

I just discover the problem...... just crazy!


It was caused by the version of android.support.v4.jar. I made a test now, for some magic reason, using the one i had before (i got it, in Eclipse, with right click on the library project, Android Tools > Add Support Library  it wasn't recognized). Then, i tried with other two different version of android.support.v4.jar , and this magically solved the problem! Just to say, using the Add Support Library method, the android.support.v4 file size was 1.2 MB, the other two versions were respectively 759KB and 628KB, depending on their version. I was expecting that this library was properly added by eclipse, also relying on the androd target in the project.properties, but seems not. Hope this could help someone.

PS: As all the other thread suggest, be sure that the android.support.v4.jar is included in your ANE file, and the platform.xml explicit declare it as <packagedDependencies>.

2 replies

luca-mooncat
Participant
May 13, 2015

I tried also to embed the classes of android.support.v4 into the my resulting jar extension library, as suggested on some other thread, but doesn't work

Adobe Employee
May 13, 2015

Hi,

We would surely like to help you.

Could you please share some files with us so that we can see what's going on.?

Please share us the following data:

1. Native Android Project which includes android.support.v4.app library.

2. .as file of your Native side Action Script code.

3. extension.xml

luca-mooncat
luca-mooncatAuthorCorrect answer
Participant
May 13, 2015

I just discover the problem...... just crazy!


It was caused by the version of android.support.v4.jar. I made a test now, for some magic reason, using the one i had before (i got it, in Eclipse, with right click on the library project, Android Tools > Add Support Library  it wasn't recognized). Then, i tried with other two different version of android.support.v4.jar , and this magically solved the problem! Just to say, using the Add Support Library method, the android.support.v4 file size was 1.2 MB, the other two versions were respectively 759KB and 628KB, depending on their version. I was expecting that this library was properly added by eclipse, also relying on the androd target in the project.properties, but seems not. Hope this could help someone.

PS: As all the other thread suggest, be sure that the android.support.v4.jar is included in your ANE file, and the platform.xml explicit declare it as <packagedDependencies>.

_maria_
Community Manager
Community Manager
May 12, 2015

moved to AIR Development