1

アプリケーションが OpenFeint ダッシュボード メソッドを開くことができません。ネイティブ C++ ライブラリの実装では、cocos2d-x をグラフィック ライブラリとして使用しますが、OpenFeint 関数を使用できるようにするためのハンドラとラッパーがあります。OpenFeint の初期化と非アクティビティ メソッドは正しく機能します。

openLaderBoards や openAchievements などの UI ダッシュボード関数が Jni 呼び出しから、または Java onCreate 初期化で呼び出されると、アプリケーションがクラッシュします。

編集:私はテストしましたが、私が試したアクティビティの変更、さらには自分の新しいクラスでも発生します。

EDIT2:同様の質問で+100の報奨金があります。答えを思いついた人なら誰でも手に入れることができます。

コード

アクティビティ:

public class App extends Cocos2dxActivity{
private Cocos2dxGLSurfaceView mGLView;

OpenFeintX m_kOpenFeintX;

protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);

    // get the packageName,it's used to set the resource path
    String packageName = getApplication().getPackageName();
    super.setPackageName(packageName);

    InternetConnection.setM_kActivity(this);

    m_kOpenFeintX = new OpenFeintX( this);      

    setContentView(R.layout.applayout);
    mGLView = (Cocos2dxGLSurfaceView) findViewById(R.id.game_gl_surfaceview);
    mGLView.setTextField((EditText)findViewById(R.id.textField));                  

// Testspace for new Activities, OpenFeint or self-made
//
// Intent myIntent = new Intent(this, TestActivity.class);
// startActivityForResult(myIntent, 0);
// Dashboard.open();


// Cocos2d-x scene opens after this

}

 static {
     System.loadLibrary("TestProject");
     // Native library loaded for cocos2d-x
 }

ラッパー:

public class OpenFeintX {

private static OpenFeintXHandler ms_kOpenFeintHandler;

public OpenFeintX(Activity kActivity) {
    initializeOpenFeint("TestApp", "derp",
            "hurr", "6546516516541",
            kActivity, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    ms_kOpenFeintHandler = new OpenFeintXHandler();

}

public static void openLeaderBoards() {     
    Message msg = new Message();
    msg.what = OpenFeintXHandler.SHOW_LEADERBOARDS;
    ms_kOpenFeintHandler.sendMessage(msg);
}

ハンドラー openDashboard 関数:

private void openLeaderBoards() {
    System.out.println("Opening Dashboard");
    Dashboard.openLeaderboards();
}

マニフェスト:

<application
    android:debuggable="true"
    android:label="@string/app_name">
    <activity
        android:configChanges="orientation"
        android:label="@string/app_name"
        android:name=".App"
        android:screenOrientation="portrait"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />

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

    <activity android:name="com.openfeint.internal.ui.IntroFlow"
              android:label=".IntroFlow"
              android:configChanges="orientation|keyboardHidden"
              android:theme="@style/OFNestedWindow" />
    <activity android:name="com.openfeint.api.ui.Dashboard"
              android:label=".Dashboard"
              android:configChanges="orientation|keyboardHidden"
              android:theme="@style/OFNestedWindow"/>
    <activity android:name="com.openfeint.internal.ui.Settings"
              android:label=".Settings"
              android:configChanges="orientation|keyboardHidden"
              android:theme="@style/OFNestedWindow"/>
    <activity android:name="com.openfeint.internal.ui.NativeBrowser"
              android:label=".NativeBrowser"
              android:configChanges="orientation|keyboardHidden"
              android:theme="@style/OFNestedWindow"/>
</application>

スタックトレース (SO ではインデントされません):

http://pastebin.com/jsmSbgw4

4

1 に答える 1

2

答えは簡単ですが複雑でした。アプリが新しいアクティビティに変わると、cocos2d-x MessageJNI の nativeOnPause メソッドが呼び出されます。このメソッドは CCApplication::sharedApplication() を呼び出すことになっていますが、私のクラスの 1 つが以前に CCApplication デストラクタを呼び出していたため、共有シングルトンが null にクリアされました。

答えは簡単に修正でき、プロジェクト固有のものですが、なぜそれを見つけたのかについてアドバイスをします。私のツールはすべて windows と cygwin であることを覚えておいてください。

まず、Eclipse にクリーンで ndk-builds を実行させます。

プロジェクトを右クリック -> プロパティ -> C/C++ ビルド。ビルダー設定タブ、コマンド

  C:\NVPACK\cygwin\bin\bash.exe -c "cd /cygdrive/path/to/project && ./build_script.sh"

次に、デバッガーをセットアップします。

このチュートリアルを使用します。そこにたどり着くまでに時間がかかるかもしれませんが、それだけの価値があります。私のadb-server呼び出しスクリプトは

export ANDROID_NDK_ROOT=/cygdrive/c/NVPACK/android-ndk-r6b/
cd $ANDROID_NDK_ROOT
./ndk-gdb-eclipse --adb=/cygdrive/c/NVPACK/android-sdk-windows/platform-tools/adb     --project=/cygdrive/c/project/path --force --verbose

3 番目に、logcat を詳細に設定します。

更新: Logcat の最新バージョンがスタックトレース全体のクラスと行を出力するため、この最後のステップをスキップできるようになりました。

私の質問のような長いスタックトレースが得られます。スタック トレース エラーのポイントを確認するには、この他のチュートリアルに従ってください。ライブラリにアクセスするための私のスクリプトは

C:\NVPACK\android-ndk-r6b\toolchains\x86-4.4.3\prebuilt\windows\bin\i686-android-linux-addr2line.exe -C -f -e c:\path\to\project\libMyLib.so
于 2012-04-26T10:57:23.830 に答える