2013-01-14 2 views
0

편집 2013년 1월 14일를 호출 - 나는 페이스 북 SDK ... 여전히 같은 오류가 다시 다운로드 시도했다.android.view.InflateException facebook.authorize


내가 루퍼와 함께 facebook.authorize를 호출 할 때 android.view.InflateException이 OutOfMemoryException이 발생 얻고있다.

는 facebook.authorize의 호출이 완료되고 내 코드의 조각입니다 :

public void promptLogin(){ 
    if (! facebook.isSessionValid()) { 
     loginAndContinue(); 
    } 
    else { 
     Continue(); 
    } 
} 
public void loginAndContinue(){ 
    new Thread(new Runnable() { 

     public void run() { 
      // TODO Auto-generated method stub 
      Looper.prepare(); 
      openLoginDialog(); 
      Looper.loop(); // This is line 248 
     } 
    }).start(); 
} 
public void openLoginDialog(){ 
    facebook.authorize(this, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH, new LoginDialogListener()); 
} 
public void Continue(){ 
    AsyncFacebookRunner myAsyncRunner = new AsyncFacebookRunner(facebook); 
    myAsyncRunner.request("me", new meRequestListener(this)); 
} 

그리고 여기 로그 오류 : 그것은처럼 일

>  01-14 19:42:04.551: E/AndroidRuntime(890): FATAL EXCEPTION: Thread-105 
>  01-14 19:42:04.551: E/AndroidRuntime(890): android.view.InflateException: Binary XML file line #107: Error 
> inflating class <unknown> 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.view.LayoutInflater.createView(LayoutInflater.java:606) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at com.android.internal.app.AlertController.installContent(AlertController.java:240) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.app.AlertDialog.onCreate(AlertDialog.java:336) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.app.ProgressDialog.onCreate(ProgressDialog.java:198) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.app.Dialog.dispatchOnCreate(Dialog.java:353) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.app.Dialog.show(Dialog.java:257) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at com.facebook.widget.WebDialog$DialogWebViewClient.onPageStarted(WebDialog.java:364) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:267) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.os.Handler.dispatchMessage(Handler.java:99) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.os.Looper.loop(Looper.java:137) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at com.COMPANYNAME.framework.impl.AndroidGame$6.run(AndroidGame.java:248) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at java.lang.Thread.run(Thread.java:856) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): Caused by: java.lang.reflect.InvocationTargetException 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at java.lang.reflect.Constructor.constructNative(Native Method) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.view.LayoutInflater.createView(LayoutInflater.java:586) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): ... 20 more 
>  01-14 19:42:04.551: E/AndroidRuntime(890): Caused by: java.lang.OutOfMemoryError 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:483) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.content.res.Resources.loadDrawable(Resources.java:1935) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.view.View.<init>(View.java:2785) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.view.ViewGroup.<init>(ViewGroup.java:385) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.widget.LinearLayout.<init>(LinearLayout.java:174) 
>  01-14 19:42:04.551: E/AndroidRuntime(890): at android.widget.LinearLayout.<init>(LinearLayout.java:170) 

이전에는 매력 이었지만 버튼을 추가 한 후에 (프로그래밍 방식으로) 더 이상 작동하지 않습니다.

JAVA :

setContentView(gameLayout); 
    View.inflate(this, R.layout.facebook, gameLayout); 
    facebookLayout = (LinearLayout)findViewById(R.id.facebookLayout); 
    facebookName = (TextView)findViewById(R.id.facebookName); 
    profilePicture = (ProfilePictureView)findViewById(R.id.profile_pic); 
    profilePicture.setCropped(true); 
    getNameAndId(); 
    facebookName.setText("Welcome, " + name + "!"); 
    showFacebook(false); 
    checkState(); 
} 

public void checkState() { 
    if (! facebook.isSessionValid()) { 
     facebookName.setVisibility(View.GONE); 
     profilePicture.setVisibility(View.GONE); 
    } 
} 
당신이 나를 도울하는 데 도움이 그냥 경우

, 여기에 내가 이름에 대한 페이스 북의 사진과 텍스트 뷰를 저장있는 LinearLayout 팽창 코드입니다

XML :

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:facebook="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/facebookLayout" 
    android:orientation="vertical" 
    android:layout_width="match_parent" android:layout_height="match_parent" 
    android:layout_gravity="center" 
    android:padding="100dp" 
    android:layout_alignParentTop="true"> 
    <com.facebook.widget.ProfilePictureView 
     android:id="@+id/profile_pic" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:layout_gravity="center" 
     android:gravity="center_horizontal" 
     facebook:preset_size="small" /> 
    <TextView android:id="@+id/facebookName" 
     android:text="Welcome!" 
     android:textColor="#0000FF" 
     android:padding="5dp" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:gravity="center"/> 
</LinearLayout> 

여기에서 진행하는 방법에 대한 단서가 없기 때문에 당신이 나를 도울 수 있기를 바랍니다.

+0

당신의 drawable 자원. 큰 배경 이미지 또는 그와 유사한 것을 포함하도록 다른 레이아웃 파일을 수정 했습니까? – iagreen

+0

드로어 블 리소스에서 아무 것도로드하지 않기 때문에 이상합니다. 모든 이미지는 애셋에 저장되고 시작시로드됩니다. 드로어 블에서 이미지가로드되는 facebook 라이브러리를 제외하고 ... 아, 그런데 내가 가지고있는 레이아웃 파일은 질문에 포함 된 xml 파일뿐입니다. –

+0

은 Facebook이어야합니다. 하지만, 왜 백그라운드 스레드에서'권한 부여 '를 실행하고 있습니까? UI에 닿는 경우 주 스레드에 있어야합니다. – iagreen

답변

0

나는 지금 그것을 작동시킬 수 있었다! 같은 시간에 너무 많은 이미지가 메모리에로드 된 것처럼 보였습니다. 나는 커다란 이미지들과 짜증나게하는 것들에 대해서 주석을 달기를 시도했다. 그것은 효과가있다!

해결 방법은 필요하지 않은 화면을 전환 할 때 이미지를 재활용해야한다는 것입니다. 그렇게하면 많은 메모리를 절약 할 수 있고 내가했던 것처럼 똑같은 문제에 직면 할 필요가 없습니다. 더 이상 이미지를 필요로하지 않을 때

은이 작업을 수행 :

bitmap.recycle(); 
    bitmap = null; 
이 선`android.graphics.drawable.Drawable.createFromResourceStream (Drawable.java:773)는`당신이에서 이미지를로드하는 의미
관련 문제