twitter4j
動かん。_stopped unexpectedly_との事。
コードはこんなカンジ。
package com.railsplayground.playthings.helloandroid; import twitter4j.Status; import twitter4j.Twitter; import twitter4j.TwitterException; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class HelloAndroidActivity extends Activity implements OnClickListener { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button = (Button)findViewById(R.id.Button01); button.setOnClickListener(this); } public void onClick(View arg0) { if (arg0.getId() == R.id.Button01) { try { UpdateTwitter(); } catch(TwitterException e) { finish(); } } } private void UpdateTwitter() throws TwitterException { Twitter twitter = new Twitter("id", "pass"); Status status = twitter.updateStatus("good morning(test)"); AlertDialog.Builder b = new AlertDialog.Builder(this); b.setTitle(R.string.update_confirm); b.setMessage(status.getText()); b.setPositiveButton(R.string.confirm_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); b.show(); } }
字下げが微妙。とりあえず github に push してここでもお伺いな方向。
github 方面への出力
上記のナニは github に作った HelloAndroid なリポジトリから import したものなんですが、とりあえずプロジェクトの名前を変えたい。プロジェクトを指して右クリックして Refactor -> Rename で大丈夫な模様。
これ、twitter4j な jar を参照してるんですが、github に push した後にをそれを pull した人がそれなりにハマるんでしょうな。そのあたりはスルーとして github にリポジトリを作って push してみよう。
- github でリポジトリ作成
- git://github.com/yamanetoshi/twitterUpdate.git
- プロジェクト右クリック -> team -> push to
- Custom URI を選択して上記の URI をペーストして Next
- 失敗
- .gitignore を削除して同様の操作でも NG
- git init してないので実施
手動で push してみます?
$ git push origin master Enter passphrase for key '/home/rms/.ssh/id_rsa': Repository not found. If you've just created it, please try again in a few seconds. fatal: The remote end hung up unexpectedly $
むむむ。git status してみたら nothing add to commit との事。このあたりは手動でヤらんと駄目なのか。
$ cat .gitignore *.class $ git add . $ git commit -m 'first commit' Created initial commit 6536a1d: first commit 14 files changed, 176 insertions(+), 0 deletions(-) create mode 100644 .classpath create mode 100644 .gitignore create mode 100644 .project create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 AndroidManifest.xml create mode 100644 bin/classes.dex create mode 100644 bin/resources.ap_ create mode 100644 bin/twitterUpdate.apk create mode 100644 default.properties create mode 100644 gen/com/railsplayground/playthings/helloandroid/R.java create mode 100644 res/drawable/icon.png create mode 100644 res/layout/main.xml create mode 100644 res/values/strings.xml create mode 100644 src/com/railsplayground/playthings/helloandroid/HelloAndroidActivity.java $ git remote add origin git@github.com:yamanetoshi/twitterUpdate.git fatal: remote origin already exist. $
うーん、微妙だけど push してみるか。
$ git push origin master Enter passphrase for key '/home/rms/.ssh/id_rsa': Repository not found. If you've just created it, please try again in a few seconds. fatal: The remote end hung up unexpectedly $
再度イチからリトライ。
$ rm -rf .git $ git init Initialized empty Git repository in /home/rms/eclipse_workspace/twitterUpdate/.git/ $ git add . $ git commit -m 'first commit' 14 files changed, 176 insertions(+), 0 deletions(-) create mode 100644 .classpath create mode 100644 .gitignore create mode 100644 .project create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 AndroidManifest.xml create mode 100644 bin/classes.dex create mode 100644 bin/resources.ap_ create mode 100644 bin/twitterUpdate.apk create mode 100644 default.properties create mode 100644 gen/com/railsplayground/playthings/helloandroid/R.java create mode 100644 res/drawable/icon.png create mode 100644 res/layout/main.xml create mode 100644 res/values/strings.xml create mode 100644 src/com/railsplayground/playthings/helloandroid/HelloAndroidActivity.java $ git remote add origin git@github.com:yamanetoshi/twitterUpdate.git $ git push origin master Enter passphrase for key '/home/rms/.ssh/id_rsa': Repository not found. If you've just created it, please try again in a few seconds. fatal: The remote end hung up unexpectedly $
とほほほ。git ガラみで log 肥大な傾向があるこの週末ですな。とりあえずログ出力抑制気味で色々試してみます。
ってか面倒なので HelloAndroid のバージョンを上げる事にします。そしてハマり中です。どうもイケマセン。
色々ヤッてたんですが
とりあえず HelloAndroid に変更を盛り込んで push する方針ですがどうなる事やら。
とりあえずの気づきとしては、修正が発生したファイルについては Team -> add to version control しないと駄目な模様。
ってか、この plugin 自体の動作が微妙なのかな。だんだん面倒くさいのが嫌になってきました。面倒臭いからディレクトリをコピーして .git を消して git init 以降で github に持ってけば良いのかな。
ってコトでリトライしてみたんですが、上記と同様のメセジで NG。Linux でヤッてるのが微妙な所以なのでしょうか。