NoClassDefFoundError: android/support/v4/content/LocalBroadcastManager

前端 未结 7 1704
甜味超标
甜味超标 2020-12-18 17:37
  • Platform: MonoDroid v4.2.4
  • IDE: Visual Studio 2012
  • Minimum SDK version: API 12

I\'m having runtime issues when trying to utilize th

相关标签:
7条回答
  • 2020-12-18 17:39

    This problem was hounding me for almost six months now and no solution was helping me but today I have managed to find the correct solution on my own.

    When you select your project target version to be greater than or equal to Android 4.0, Android SDK includes "android-support-v4.jar" file in your projects "libs" folder. This jar contains all the classes and methods related Android 4.0 or later.

    Android is trying to find the class definition which is in "android-support-v4.jar" so that means you have not configured the build path to the "android-support-v4.jar" file. To do this, follow these steps:

    1. Open your project properties
    2. Select "Java Build Path" from left side menu
    3. Select "Libraries" tab
    4. Press "Add External Jar"
    5. (Most important step) Select "android-support-v4" jar file of "libs" folder from your CURRENT PROJECT LOCATION (path should be on your project folder and not the android sdk).
    6. Select "Order and Export" tab and "TICK" the checkbox of "android-support-v4.jar"

    That's it, you're done!

    0 讨论(0)
  • 2020-12-18 17:41

    in Android Studio 0.8.2

    Android Studio 0.8.2

    Press the green "+" in tab Dependencies of Project-Structure, then the keyboard key "1" (for libs) and choose the v4+ lib

    0 讨论(0)
  • 2020-12-18 17:42

    Just replace the android-support-v4.jar of your project that is in>libs folder with android-support-v4.jar present in FacebookSDK>libs folder

    0 讨论(0)
  • 2020-12-18 17:48

    If you have proguard enabled, try adding

    # Local Broadcast Manager
    -keep public class android.support.v4.content.LocalBroadcastManager
    

    This fixed it for me.

    0 讨论(0)
  • 2020-12-18 17:48

    The problem seems to be related to the "properties" of the android-support-v4.jar library.

    By default, the "Build Action" listed in the Advanced Properties in Visual Studio had a value of Content. I switched the value to AndroidJavaLibrary and the runtime error has disappeared.

    However, the BroadcastReceiver isn't receiving the USB disconnect intent, hmm... Will update this answer accordingly.

    Edit: I could never get a LocalBroadcastReceiver to work, so I had to use a regular one.

    0 讨论(0)
  • 2020-12-18 17:51

    You need to add the support library .jar file to the /libs directory in your IDE if it is Eclipse so that when the apk is made the Android packager will include that in your apk.

    0 讨论(0)
提交回复
热议问题