2012-04-17 4 views
0

ここにコードがあります。キー、シークレット、コールバック変数が定義されています。私はこれらのライブラリバージョンを使用しています:SocialLibBeta2_2.jar、signpost-core-1.2.1.2.jar、signpost-commonshttp4-1.2.1.2.jar、scribe-0.6.7-SNAPSHOT.jar。ここでTwitterConnectorを作成中のSocialLibエラー

import com.expertiseandroid.lib.sociallib.connectors.SocialNetworkHelper; 
import com.expertiseandroid.lib.sociallib.connectors.TwitterConnector; 
import com.expertiseandroid.lib.sociallib.exceptions.NotAuthentifiedException; 
import com.expertiseandroid.lib.sociallib.model.twitter.TwitterUser; 

import java.io.IOException; 

import javax.xml.parsers.ParserConfigurationException; 

import org.scribe.oauth.Token; 
import org.xml.sax.SAXException; 

import oauth.signpost.exception.OAuthCommunicationException; 
import oauth.signpost.exception.OAuthExpectationFailedException; 
import oauth.signpost.exception.OAuthMessageSignerException; 
import oauth.signpost.exception.OAuthNotAuthorizedException; 

public void SendTweet() 
{ 
TwitterConnector twitter = SocialNetworkHelper.createTwitterConnector(CONS_KEY, CONS_SEC, CALLBACK); 

try { 
     twitter.requestAuthorization(this); 
    } catch (OAuthMessageSignerException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (OAuthNotAuthorizedException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (OAuthExpectationFailedException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (OAuthCommunicationException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
    try { 
     twitter.authorize(this); 
    } catch (OAuthMessageSignerException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (OAuthNotAuthorizedException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (OAuthExpectationFailedException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (OAuthCommunicationException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
    Token at = twitter.getAccessToken(); 
    String token = at.getToken(); 
    String secret = at.getSecret(); 

    Token myAccessToken = new Token(token, secret); 
    twitter.authentify(myAccessToken); 

    try { 
     twitter.tweet("Test tweet"); 
    } catch (OAuthMessageSignerException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (OAuthExpectationFailedException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (OAuthCommunicationException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (SAXException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (ParserConfigurationException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (NotAuthentifiedException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
} 

は誤りである。このようなルックス吹いています

04-17 19:05:18.958: E/AndroidRuntime(932): FATAL EXCEPTION: main 
04-17 19:05:18.958: E/AndroidRuntime(932): java.lang.NoSuchMethodError: oauth.signpost.commonshttp.CommonsHttpOAuthProvider.retrieveRequestToken 
04-17 19:05:18.958: E/AndroidRuntime(932): at com.expertiseandroid.lib.sociallib.connectors.TwitterConnector.requestAuthorization(TwitterConnector.java:287) 
04-17 19:05:18.958: E/AndroidRuntime(932): at com.sirva.mymc.JournalActivity.SendTweet(JournalActivity.java:247) 
04-17 19:05:18.958: E/AndroidRuntime(932): at com.sirva.mymc.JournalActivity$1$1.onClick(JournalActivity.java:135) 
04-17 19:05:18.958: E/AndroidRuntime(932): at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:873) 
04-17 19:05:18.958: E/AndroidRuntime(932): at android.widget.AdapterView.performItemClick(AdapterView.java:284) 
04-17 19:05:18.958: E/AndroidRuntime(932): at android.widget.ListView.performItemClick(ListView.java:3513) 
04-17 19:05:18.958: E/AndroidRuntime(932): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1812) 
04-17 19:05:18.958: E/AndroidRuntime(932): at android.os.Handler.handleCallback(Handler.java:587) 
04-17 19:05:18.958: E/AndroidRuntime(932): at android.os.Handler.dispatchMessage(Handler.java:92) 
04-17 19:05:18.958: E/AndroidRuntime(932): at android.os.Looper.loop(Looper.java:130) 
04-17 19:05:18.958: E/AndroidRuntime(932): at android.app.ActivityThread.main(ActivityThread.java:3683) 
04-17 19:05:18.958: E/AndroidRuntime(932): at java.lang.reflect.Method.invokeNative(Native Method) 
04-17 19:05:18.958: E/AndroidRuntime(932): at java.lang.reflect.Method.invoke(Method.java:507) 
04-17 19:05:18.958: E/AndroidRuntime(932): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 
04-17 19:05:18.958: E/AndroidRuntime(932): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 
04-17 19:05:18.958: E/AndroidRuntime(932): at dalvik.system.NativeStart.main(Native Method) 

TwitterConnector機能:ここで

public void requestAuthorization(Context ctx) throws OAuthMessageSignerException, OAuthNotAuthorizedException, OAuthExpectationFailedException, OAuthCommunicationException 
{ 
    String authUrl = httpOauthprovider.retrieveRequestToken(httpOauthConsumer, callback); 
    ctx.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl))); 
} 

protected TwitterConnector(String consumerKey, String consumerSecret, String callback){ 
    this(consumerKey, consumerSecret, callback, ""); 
} 

protected TwitterConnector(String consumerKey, String consumerSecret, String callback, String twitPicKey){ 
    this.authentified = false; 
    this.reader = new TwitterReader(); 
    this.twitPicKey = twitPicKey; 
    this.callback = callback; 
    httpOauthConsumer = new CommonsHttpOAuthConsumer(consumerKey, consumerSecret); 
    httpOauthprovider = new CommonsHttpOAuthProvider(TWITTER_REQUEST, TWITTER_ACCESS, AUTHORIZE); 

} 

は、他のライブラリがされていないことを確認する簡単なテストアプリですそれに問題がある

package com.test; 

import android.app.Activity; 
import android.os.Bundle; 
import com.expertiseandroid.lib.sociallib.connectors.SocialNetworkHelper; 
import com.expertiseandroid.lib.sociallib.connectors.TwitterConnector; 
import com.expertiseandroid.lib.sociallib.exceptions.NotAuthentifiedException; 
import com.expertiseandroid.lib.sociallib.model.twitter.TwitterUser; 

import java.io.IOException; 

import javax.xml.parsers.ParserConfigurationException; 

import org.scribe.oauth.Token; 
import org.xml.sax.SAXException; 

import oauth.signpost.exception.OAuthCommunicationException; 
import oauth.signpost.exception.OAuthExpectationFailedException; 
import oauth.signpost.exception.OAuthMessageSignerException; 
import oauth.signpost.exception.OAuthNotAuthorizedException; 

public class TestActivity extends Activity { 
/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    String CONS_KEY = "xxxxxxxxxxxxxxxxxxx"; 
    String CONS_SEC = "xxxxxxxxxxxxxxxxxxxxxxxxxx"; 
    String CALLBACK = "http://xxxx.com"; 

    TwitterConnector twitter = SocialNetworkHelper.createTwitterConnector(CONS_KEY, CONS_SEC, CALLBACK); 

    try { 
     twitter.requestAuthorization(TestActivity.this); 
    } catch (OAuthMessageSignerException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (OAuthNotAuthorizedException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (OAuthExpectationFailedException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (OAuthCommunicationException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
    try { 
     twitter.authorize(this); 
    } catch (OAuthMessageSignerException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (OAuthNotAuthorizedException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (OAuthExpectationFailedException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (OAuthCommunicationException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
    Token at = twitter.getAccessToken(); 
    String token = at.getToken(); 
    String secret = at.getSecret(); 

    Token myAccessToken = new Token(token, secret); 
    twitter.authentify(myAccessToken); 

    try { 
     twitter.tweet("Test tweet"); 
    } catch (OAuthMessageSignerException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (OAuthExpectationFailedException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (OAuthCommunicationException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (SAXException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (ParserConfigurationException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (NotAuthentifiedException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
} 

} 

これを実行すると同じエラーが発生します。 TestActivity.thisは有効なコンテキストです。メソッドrequestAuthorizationへのアクセス権がありますが、NoSuchMethodErrorが再び表示されます。テストプロジェクトに含まれるライブラリ:commons-codec-1.6.jar、scribe-0.6.6.jar(0.6.7も試しました)、signpost-commonshttp4-1.2.1.2.jar、signpost-core-1.2.1.2.jar、 signpost-jetty6-1.2.1.2.jar、SocialLibBeta2_2.jar。

はここでもマニフェストです:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.test" 
android:versionCode="1" 
android:versionName="1.0" > 

<uses-sdk android:minSdkVersion="10" /> 

<uses-permission android:name="android.permission.INTERNET"></uses-permission> 

<application 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" > 
    <activity 
     android:name=".TestActivity" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
</application> 

</manifest> 
+0

私はlibを見逃していたので、前にこの問題がありますが、プロジェクトにそれらを含めるのが分かりました。何が問題なのですか? – Weloo

+0

私はoauth-signpostとscribeから3つのライブラリをすべて試しました。私は看板1.2.1.1と1.2.1.2の両方のバージョンとスクライブ0.6.6と0.6.7-SNAPSHOTの両方を試しました。私はまだこのエラーが発生しています。私はapache commonのコーデック1.6を使用していますが、まだretrieveRequestTokenにNoSuchMethodErrorを取得しています。別のクリーンなプロジェクトを試してみましょう。ちょうどそれを直接呼び出すと、別のライブラリが競合するかどうかを確認できます。 –

+0

テストプロジェクトが失敗しました。テストプロジェクトのアクティビティ/マニフェストとライブラリの追加を追加しました。私はこの1つに困惑しています... –

答えて

0

私はあなたがプロジェクトに含まれている必要がありlibに欠場だと思いますが、このエラーを得ている理由です、あなたがhereからこれら3つのLIBSをダウンロードしてもthis LIBをダウンロードしたり、あなたがする必要がありますもう一度別の例外を取得してください

+0

私はscribe-0.6.6-javadoc.jarを使用しなければならないのですか?また、標識から、私は最新の2を使っていますが、看板ではありません - jetty6-1.2.1.2.jar ...私は桟橋の必要性を見ませんでした。なぜ私はTwitterConnectorのrequestAuthorizationでエラーが発生しているのか分かりません。標識から桟橋のファイルを追加し、ライブラリを再びドロップ/追加します。私は再びエラーが表示されたら、ライブラリーが実際にそこにあることを示すスクリーンショットを取得します。 –

0

私はScribeと一緒に行こうと決めました。 SocialLibは私にあまりにも多くの問題を与えていました。

関連する問題