Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoClassDefFoundError: com.facebook.android.R$layout #537

Closed
neuberoliveira opened this issue Jul 2, 2014 · 15 comments
Closed

Comments

@neuberoliveira
Copy link

I getting this error: java.lang.NoClassDefFoundError: com.facebook.android.R$layout

When i call:
facebookConnectPlugin.login(["basic_info"],
function(){ alert("Success") },
function () { alert(":(") }
);

07-02 20:25:53.577: D/HAWAII_EGL(18108): eglMakeCurrent(0x4fced2d0, 0x4fced2f0, 0x4fced2f0) Thread: 18108
07-02 20:25:53.717: V/WebViewInputDispatcher(18108): blockWebkitDraw
07-02 20:25:53.717: V/WebViewInputDispatcher(18108): blockWebkitDraw lockedtrue
07-02 20:25:54.047: D/webview(18108): blockWebkitViewMessage= false
07-02 20:25:54.167: D/ConnectPlugin(18108): login FB
07-02 20:25:54.217: W/dalvikvm(18108): VFY: unable to resolve static field 2311 (com_facebook_internet_permission_error_title) in Lcom/facebook/android/R$string;
07-02 20:25:54.217: D/dalvikvm(18108): VFY: replacing opcode 0x60 at 0x0010
07-02 20:25:54.227: I/dalvikvm(18108): DexOpt: unable to optimize static field ref 0x0906 at 0x18 in Lcom/facebook/AuthorizationClient;.checkInternetPermission
07-02 20:25:54.378: W/dalvikvm(18108): VFY: unable to resolve static field 2301 (com_facebook_login_activity_layout) in Lcom/facebook/android/R$layout;
07-02 20:25:54.378: D/dalvikvm(18108): VFY: replacing opcode 0x60 at 0x0003
07-02 20:25:54.378: W/dalvikvm(18108): VFY: unable to resolve static field 2284 (com_facebook_login_activity_progress_bar) in Lcom/facebook/android/R$id;
07-02 20:25:54.378: D/dalvikvm(18108): VFY: replacing opcode 0x60 at 0x0008
07-02 20:25:54.498: D/dalvikvm(18108): GC_CONCURRENT freed 532K, 18% free 8838K/10748K, paused 4ms+7ms, total 46ms
07-02 20:25:54.588: D/CordovaActivity(18108): Paused the application!
07-02 20:25:54.588: D/CordovaWebView(18108): Handle the pause
07-02 20:25:54.588: D/WebView(18108): loadUrlImpl: called
07-02 20:25:54.648: W/PluginManager(18108): THREAD WARNING: exec() call to FacebookConnectPlugin.login blocked the main thread for 480ms. Plugin should use CordovaInterface.getThreadPool().
07-02 20:25:54.748: D/webcore(18108): CORE loadUrl: called
07-02 20:25:54.748: D/webkit(18108): Firewall not null
07-02 20:25:54.748: D/webkit(18108): euler: isUrlBlocked = false
07-02 20:25:54.908: D/AndroidRuntime(18108): Shutting down VM
07-02 20:25:54.908: W/dalvikvm(18108): threadid=1: thread exiting with uncaught exception (group=0x420af930)
07-02 20:25:54.938: E/AndroidRuntime(18108): FATAL EXCEPTION: main
07-02 20:25:54.938: E/AndroidRuntime(18108): java.lang.NoClassDefFoundError: com.facebook.android.R$layout
07-02 20:25:54.938: E/AndroidRuntime(18108): at com.facebook.LoginActivity.onCreate(LoginActivity.java:57)
07-02 20:25:54.938: E/AndroidRuntime(18108): at android.app.Activity.performCreate(Activity.java:5326)
07-02 20:25:54.938: E/AndroidRuntime(18108): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
07-02 20:25:54.938: E/AndroidRuntime(18108): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2218)
07-02 20:25:54.938: E/AndroidRuntime(18108): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2309)
07-02 20:25:54.938: E/AndroidRuntime(18108): at android.app.ActivityThread.access$700(ActivityThread.java:157)
07-02 20:25:54.938: E/AndroidRuntime(18108): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1289)
07-02 20:25:54.938: E/AndroidRuntime(18108): at android.os.Handler.dispatchMessage(Handler.java:99)
07-02 20:25:54.938: E/AndroidRuntime(18108): at android.os.Looper.loop(Looper.java:176)
07-02 20:25:54.938: E/AndroidRuntime(18108): at android.app.ActivityThread.main(ActivityThread.java:5317)
07-02 20:25:54.938: E/AndroidRuntime(18108): at java.lang.reflect.Method.invokeNative(Native Method)
07-02 20:25:54.938: E/AndroidRuntime(18108): at java.lang.reflect.Method.invoke(Method.java:511)
07-02 20:25:54.938: E/AndroidRuntime(18108): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
07-02 20:25:54.938: E/AndroidRuntime(18108): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
07-02 20:25:54.938: E/AndroidRuntime(18108): at dalvik.system.NativeStart.main(Native Method)

@aogilvie
Copy link
Collaborator

aogilvie commented Jul 8, 2014

Your application does not have Android Internet Permissions setup. http://developer.android.com/reference/android/Manifest.permission.html#INTERNET
This is required by Facebook SDK
https://developers.facebook.com/docs/android/getting-started/

@perilousleigh
Copy link

To make the CLI installation more automatic, couldn't something like the following be added to plugin.xml:

    <config-file target="AndroidManifest.xml" parent="/manifest">
        <uses-permission android:name="android.permission.INTERNET" />
    </config-file>

@rlau1115
Copy link

I'm actually having this issue as well, but I have the INTERNET permissions defined in my manifest. Any thoughts?

@perilousleigh
Copy link

Adding the INTERNET permission was not enough to work for me either. My project for some reason was not including the FacebookLib library project when building but I couldn't clearly see why. I would think that if using the CLI to build all that would be needed is to list the FacebookLib as an android.library.reference in the root project.properties file. Just in case that wasn't enough I messed around with my IDE build settings and set the FacebookLib dependency to Compile scope and to Export. Eventually this error went away but I can't way with 100% certainty what change I made that actually fixed it. I'm not building using my IDE really, I'm running "cordova build" so I wouldn't think my dependencies and build settings in the IDE would have any bearing on the CLI process, but I could be wrong...

@aogilvie
Copy link
Collaborator

@perilousleigh Thanks for the feedback, perhaps we should add internet permissions.

Regarding non-IDE use; we recently added that to the docs on develop branch: https://github.com/Wizcorp/phonegap-facebook-plugin/blob/develop/platforms/android/README.md#setup-without-eclipse-just-cli

@inakie
Copy link

inakie commented Jul 22, 2014

I was having the same problem, was able to build correctly but at runtime I got the error java.lang.NoClassDefFoundError: com.facebook.android.R$layout

The last link by @aogilvie solved the issue and now it's working perfectly, thanks!

@brugnara
Copy link

@aogilvie THANKS! That doc solved my problem.

@ghost
Copy link

ghost commented Oct 23, 2014

sorry but i followed the new docs on develop branch and i've got the same issue :
Facebook plugin version 0.8.1
android sdk : 19
cordova : 3.6.3

D/ConnectPlugin( 2538): login FB
W/dalvikvm( 2538): VFY: unable to resolve static field 2634 (com_facebook_internet_permission_error_title) in Lcom/facebook/android/R$string;
D/dalvikvm( 2538): VFY: replacing opcode 0x60 at 0x0010
W/dalvikvm( 2538): VFY: unable to resolve static field 2623 (com_facebook_login_activity_layout) in Lcom/facebook/android/R$layout;
D/dalvikvm( 2538): VFY: replacing opcode 0x60 at 0x0003
W/dalvikvm( 2538): VFY: unable to resolve static field 2603 (com_facebook_login_activity_progress_bar) in Lcom/facebook/android/R$id;
D/dalvikvm( 2538): VFY: replacing opcode 0x60 at 0x0008
W/PluginManager( 2538): THREAD WARNING: exec() call to FacebookConnectPlugin.login blocked the main thread for 33ms. Plugin should use CordovaInterface.getThreadPool().
I/ActivityManager( 1276): START u0 {act=SSO_WITH_FALLBACK cmp=com.mobvino.mobvino/com.facebook.LoginActivity (has extras)} from pid 2538
E/eglCodecCommon( 2538): **** ERROR unknown type 0x0 (glSizeof,72)
E/eglCodecCommon( 2538): **** ERROR unknown type 0x0 (glSizeof,72)
D/dalvikvm( 2538): GC_CONCURRENT freed 403K, 23% free 3111K/3992K, paused 1ms+0ms, total 30ms
D/CordovaLog( 2538): file:///android_asset/www/lib/angular/angular.js: Line 10072 : Start Facebook Login
I/chromium( 2538): [INFO:CONSOLE(10072)] "Start Facebook Login", source: file:///android_asset/www/lib/angular/angular.js (10072)
D/CordovaActivity( 2538): Paused the application!
D/CordovaWebView( 2538): Handle the pause
D/AndroidRuntime( 2538): Shutting down VM
W/dalvikvm( 2538): threadid=1: thread exiting with uncaught exception (group=0xb2d5cb20)
E/AndroidRuntime( 2538): FATAL EXCEPTION: main
E/AndroidRuntime( 2538): Process: com.mobvino.mobvino, PID: 2538
E/AndroidRuntime( 2538): java.lang.NoClassDefFoundError: com.facebook.android.R$layout
E/AndroidRuntime( 2538):    at com.facebook.LoginActivity.onCreate(LoginActivity.java:57)
E/AndroidRuntime( 2538):    at android.app.Activity.performCreate(Activity.java:5231)
E/AndroidRuntime( 2538):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
E/AndroidRuntime( 2538):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
E/AndroidRuntime( 2538):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
E/AndroidRuntime( 2538):    at android.app.ActivityThread.access$800(ActivityThread.java:135)
E/AndroidRuntime( 2538):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
E/AndroidRuntime( 2538):    at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 2538):    at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime( 2538):    at android.app.ActivityThread.main(ActivityThread.java:5017)
E/AndroidRuntime( 2538):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2538):    at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime( 2538):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
E/AndroidRuntime( 2538):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
E/AndroidRuntime( 2538):    at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 1276):   Force finishing activity com.mobvino.mobvino/com.facebook.LoginActivity
W/ActivityManager( 1276):   Force finishing activity com.mobvino.mobvino/.Mobvino

@fredgalvao
Copy link

Well, I had this issue and the ant release inside facebook libProject solved the issue, but is this really a solution?

I mean, my project is gonna work for me now, until I have to reinstall a new version of the plugin, or until I have to update cordova and rebuild the whole platforms folder, or until a new member of my team has to checkout the project or switch branches, and so on. I'll have to do ant release manually at those times, and I don't really think that's a good thing.

Maybe this is a cordova issue, seeing that cordova build isn't actually building the libProjects properly for android, but maybe this plugin can do something to prevent the dev having to run ant release by himself.

Please let me know if it's not at this plugin's reach to solve this, and I'll gladly take this up to the cordova ML or jira.

@aogilvie
Copy link
Collaborator

@fredgalvao
Copy link

Was waiting on an answer about whether this plugin could solve it or not before taking it up, but I created this issue anyway.

Please add to it if you have anything to add.

@aogilvie
Copy link
Collaborator

@fredgalvao That does sound like a bug with cordova build. You could add some extra commands for cd into the lib project and ant release using a "Cordova hook" - maybe the after_prepare ?

@fredgalvao
Copy link

It is indeed: this one right here

I'll switch from ant to gradle soon, and the issue should be gone.

However, using hooks would solve the issue indeed, but I'd suggest using the before_compile step instead.

@hejie
Copy link

hejie commented Dec 9, 2015

Caused by: java.lang.NoClassDefFoundError: com.facebook.drawee.R$styleable
at com.facebook.drawee.view.GenericDraweeView.inflateHierarchy(GenericDraweeView.java:128)
at com.facebook.drawee.view.GenericDraweeView.(GenericDraweeView.java:77)
at com.facebook.drawee.view.SimpleDraweeView.(SimpleDraweeView.java:60)
at java.lang.reflect.Constructor.constructNative(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
at android.view.LayoutInflater.createView(LayoutInflater.java:600) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:354) 

@HildaChen
Copy link

I meet the same problem

 <com.facebook.drawee.view.SimpleDraweeView
    android:id="@+id/baseline_jpeg"
    android:layout_width="400dp"
    android:layout_height="400dp" />
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Fresco.initialize(this);
    com.facebook.drawee.view.SimpleDraweeView view = (SimpleDraweeView) findViewById(R.id.baseline_jpeg);
    view.setImageURI(Uri.parse("http://pic9.qiyipic.com/common/20160104/90df5a9aa2804057be1a7f3df5e31825.jpg"));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants