Twitter4j 2.2.2 Serialized 的问题无法解决

发布于 2024-11-02 01:01:53 字数 3237 浏览 3 评论 0原文

我试图在黑莓 SO 5.0.0 上使用 twitter4j,我确实将 Twitter4j 2.2.2 导入到项目中。

导入所需的类后,错误出现在 twitter.setOAuthConsumer("Consumer Key","Secret Key"); 行。

错误:无法解析类型 java.io.Serializable。这是 从所需的 .class 文件间接引用

我可以毫无问题地从库导入所有类,看来问题不存在。

public class HelloWorld extends UiApplication 
{
public static void main(String[] args) 
{
    HelloWorld theApp = new HelloWorld();
    theApp.enterEventDispatcher();
}


public HelloWorld() 
{

    //MessengerContact contact =  BlackBerryMessenger.getInstance().chooseContact();
    //if(contact!=null)
    //contact.getContactId();

    HelloWorldScreen h = new HelloWorldScreen();
    pushScreen(h);
}

}

我的主屏幕是这样的

class HelloWorldScreen extends MainScreen 
{

public static int level=0;
public HelloWorldScreen() 
{
    super();
    LabelField title = new LabelField("BBM", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
    setTitle(title);

    addMenuItem(new MenuItem("BBM", 10, 10) {  
        public void run() {  
          //
            try{
                BrowserField bf = new BrowserField();
                UiApplication.getUiApplication().getActiveScreen().add(bf);

                Twitter twitter = new TwitterFactory().getInstance();
                twitter.setOAuthConsumer("XvQQ1trJYrSddj5bxp8mBg", "QrE6kZRtaz3xedH4KhP1c210hVjMDZknyjAgh0Q9w");

                RequestToken requestToken = twitter.getOAuthRequestToken();
                AccessToken accessToken = null;
                //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                while (null == accessToken) {
                System.out.println("Open the following URL and grant access to your account:");

                //bf.requestContent(new StringBuffer().append(requestToken.getAuthorizationURL()));
                System.out.print("Enter the PIN(if available) or just hit enter.[PIN]:");
                AutoTextEditField pin = new AutoTextEditField("Ingrese PIN(*)", "");
                /**
                try{
                if(pin.length() > 0){
                accessToken = twitter.getOAuthAccessToken(requestToken, pin);
                }else{
                accessToken = twitter.getOAuthAccessToken();
                }
                } catch (TwitterException te) {
                if(401 == te.getStatusCode()){
                System.out.println("Unable to get the access token.");
                }else{
                te.printStackTrace();
                }
                }
                **/
                }
                //persist to the accessToken for future reference.
                //storeAccessToken((int) twitter.verifyCredentials().getId() , accessToken);
                Status status = twitter.updateStatus("prueba");
                //System.out.println("Successfully updated the status to [" + status.getText() + "].");

            }catch(Exception e){
                UiApplication.getUiApplication().getActiveScreen().add(new RichTextField(e.getMessage()));
            }
        }  
    }); 


 }

public boolean onClose() 
{

    Dialog.alert("Goodbye!");
    System.exit(0);
    return true;
}



// ...  


}

I'm trying to use twitter4j on blackberry SO 5.0.0, I did import the Twitter4j 2.2.2 to the project.

After importing the needed classes, the error appear at line twitter.setOAuthConsumer("Consumer Key","Secret Key");.

Error: The type java.io.Serializable cannot be resolved. It is
indirectly referenced from required .class files

I can import all classes from the lib without problem, it seems the problem is not there.

public class HelloWorld extends UiApplication 
{
public static void main(String[] args) 
{
    HelloWorld theApp = new HelloWorld();
    theApp.enterEventDispatcher();
}


public HelloWorld() 
{

    //MessengerContact contact =  BlackBerryMessenger.getInstance().chooseContact();
    //if(contact!=null)
    //contact.getContactId();

    HelloWorldScreen h = new HelloWorldScreen();
    pushScreen(h);
}

}

And My main screen is like this

class HelloWorldScreen extends MainScreen 
{

public static int level=0;
public HelloWorldScreen() 
{
    super();
    LabelField title = new LabelField("BBM", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
    setTitle(title);

    addMenuItem(new MenuItem("BBM", 10, 10) {  
        public void run() {  
          //
            try{
                BrowserField bf = new BrowserField();
                UiApplication.getUiApplication().getActiveScreen().add(bf);

                Twitter twitter = new TwitterFactory().getInstance();
                twitter.setOAuthConsumer("XvQQ1trJYrSddj5bxp8mBg", "QrE6kZRtaz3xedH4KhP1c210hVjMDZknyjAgh0Q9w");

                RequestToken requestToken = twitter.getOAuthRequestToken();
                AccessToken accessToken = null;
                //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                while (null == accessToken) {
                System.out.println("Open the following URL and grant access to your account:");

                //bf.requestContent(new StringBuffer().append(requestToken.getAuthorizationURL()));
                System.out.print("Enter the PIN(if available) or just hit enter.[PIN]:");
                AutoTextEditField pin = new AutoTextEditField("Ingrese PIN(*)", "");
                /**
                try{
                if(pin.length() > 0){
                accessToken = twitter.getOAuthAccessToken(requestToken, pin);
                }else{
                accessToken = twitter.getOAuthAccessToken();
                }
                } catch (TwitterException te) {
                if(401 == te.getStatusCode()){
                System.out.println("Unable to get the access token.");
                }else{
                te.printStackTrace();
                }
                }
                **/
                }
                //persist to the accessToken for future reference.
                //storeAccessToken((int) twitter.verifyCredentials().getId() , accessToken);
                Status status = twitter.updateStatus("prueba");
                //System.out.println("Successfully updated the status to [" + status.getText() + "].");

            }catch(Exception e){
                UiApplication.getUiApplication().getActiveScreen().add(new RichTextField(e.getMessage()));
            }
        }  
    }); 


 }

public boolean onClose() 
{

    Dialog.alert("Goodbye!");
    System.exit(0);
    return true;
}



// ...  


}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

非要怀念 2024-11-09 01:01:53

这表明该包是为 Java SE 开发的,不能在 Blackberry(即 JME)上运行。

每当您看到引用 java.something 中的类的错误消息时,这都应该是您的结论。

This indicates that the package has been developed for Java SE, and won't work on Blackberry, which is JME.

Any time you see that error message referring to a class in java.something, this should be your conclusion.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文