本文介绍了Android Studio - 无法打开PNG文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法打开PNG文件...什么?!



代码与指南。这很简单,这是我的MainActivity.java:

  package com.example.aplikacebeta101; 

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.widget.TextView;
import com.facebook。*;
import com.facebook.model。*;

public class MainActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

//开始Facebook登录
Session.openActiveSession(this,true,new Session.StatusCallback(){

//当会话更改状态$ b $时回调b @Override
public void call(Session session,SessionState state,Exception exception){
if(session.isOpened()){

//向/ me发出请求API
Request.executeMeRequestAsync(session,new Request.GraphUserCallback(){

//在用户对象的Graph API响应后回调
@Override
public void onCompleted GraphUser user,Response response){
if(user!= null){
TextView welcome =(TextView)findViewById(R.id.welcome);
welcome.setText(Hello+ user.getName()+!);
}
}
});
}
}
});
}

@Override
public void onActivityResult(int requestCode,int resultCode,Intent data){
super.onActivityResult(requestCode,resultCode,data);
Session.getActiveSession()。onActivityResult(this,requestCode,resultCode,data);
}

}

任何想法?我知道,Android Studio仍然是EAP,但我认为这不是由Android Studio引起的。

解决方案

您是否使用Windows?如果生成的构建文件路径超过了 260 的Windows(不是NTFS )最大路径长度,则可能会发生此错误。确保您的项目路径不要太长,也可以使用短名称。

另请参见 / p>

I'm trying to integrate Facebook into my app, but while running it in Android Studio, I get this:

Unable to open PNG file... what?!

Code is totally the same as in "Getting Started with the Facebook SDK for Android (Android Studio)" guide. It's really simple, this is my MainActivity.java:

package com.example.aplikacebeta101;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.widget.TextView;
import com.facebook.*;
import com.facebook.model.*;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // start Facebook Login
        Session.openActiveSession(this, true, new Session.StatusCallback() {

            // callback when session changes state
            @Override
            public void call(Session session, SessionState state, Exception exception)             {
            if (session.isOpened()) {

                // make request to the /me API
                Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {

                    // callback after Graph API response with user object
                    @Override
                    public void onCompleted(GraphUser user, Response response) {
                        if (user != null) {
                            TextView welcome = (TextView) findViewById(R.id.welcome);
                            welcome.setText("Hello " + user.getName() + "!");
                        }
                    }
                });
            }
        }
    });
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}

}

Any ideas? I know, Android Studio is still EAP, but I think this is not caused by Android Studio.

解决方案

Are you using Windows? This error could happen if the generated build file path exceeds the Windows (not NTFS) max path length of 260 characters. Make sure your project path is not too long, use short names as well. More info from MS:

Also see discussion why the limitation Windows exists.

这篇关于Android Studio - 无法打开PNG文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 17:03