Unity3d Android主要活动冲突,编辑和重新编译jar

时间:2014-04-02 21:13:16

标签: android unity3d manifest conflict vuforia

我正在尝试使用vuforia和Unity中的一些原生.jar插件。问题一直在清单vuforia是主要的活动和启动器,几乎所有“原生”的android插件也想成为清单中的主要活动。

我明白你不能有两个“第一”,所以一个必须是主要的,当我想使用它时,我必须能够在另一个上启动活动()?

我已经浏览了谷歌文档中的基本教程,用于进行2项活动,并将消息传递给显示活动,但仍然无法弄清楚如何将其应用于我的情况下使用2个现有的第3部分插件。 / p>

我已经获得了eclipse以及所有用于android dev的java必备文件/程序,以及JD-GUI java反编译器以从unity .jar“plugins”获取源代码。

对于Vuforia,我发现了一个源java类,它说你可以编辑它以使用其他本机插件,但我无法弄清楚我需要添加什么,或者用哪种方法...

package com.qualcomm.QCARUnityPlayer;

import android.app.Dialog;
import android.app.NativeActivity;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.unity3d.player.UnityPlayer;

/** This custom NativeActivity shows how to initialize QCAR together with Unity from an         activity.
*   If you need to integrate another native library, you can modifiy this code and 
*   compile it to a JAR file to replace QCARUnityPlayer.jar in Assets/Plugins/Android
* */
public class QCARPlayerNativeActivity extends NativeActivity {

private QCARPlayerSharedActivity mQCARShared;
protected UnityPlayer mUnityPlayer;     // don't change the name of this variable; referenced from native code

// UnityPlayer.init() should be called before attaching the view to a layout - it will load the native code.
// UnityPlayer.quit() should be the last thing called - it will unload the native code.

protected void onCreate (Bundle savedInstanceState){
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    mUnityPlayer = new UnityPlayer(this);       

    super.onCreate(savedInstanceState);

    // initialize QCAR asynchronously
    mQCARShared = new QCARPlayerSharedActivity();
    int gles_mode = mUnityPlayer.getSettings().getInt("gles_mode", 1);
    mQCARShared.onCreate(this, gles_mode, new UnityInitializer());

    getWindow().takeSurface(null);
    setTheme(android.R.style.Theme_NoTitleBar_Fullscreen);
    getWindow().setFormat(PixelFormat.RGB_565);

    if (mUnityPlayer.getSettings ().getBoolean ("hide_status_bar", true))
        getWindow ().setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
                               WindowManager.LayoutParams.FLAG_FULLSCREEN);

}

private class UnityInitializer implements QCARPlayerSharedActivity.IUnityInitializer
{
    public void InitializeUnity()
    {
        int glesMode = mUnityPlayer.getSettings().getInt("gles_mode", 1);
        boolean trueColor8888 = false;
        mUnityPlayer.init(glesMode, trueColor8888);

        View playerView = mUnityPlayer.getView();
        setContentView(playerView);
        playerView.requestFocus();
    }
}

protected void onDestroy ()
{
    mQCARShared.onDestroy();
    mUnityPlayer.quit();
    super.onDestroy();
}

// onPause()/onResume() must be sent to UnityPlayer to enable pause and resource recreation on resume.
protected void onPause()
{
    super.onPause();
    mUnityPlayer.pause();
    mQCARShared.onPause();
}
protected void onResume()
{
    super.onResume();
    mQCARShared.onResume();
    mUnityPlayer.resume();
}
public void onConfigurationChanged(Configuration newConfig)
{
    super.onConfigurationChanged(newConfig);
    mUnityPlayer.configurationChanged(newConfig);
}
public void onWindowFocusChanged(boolean hasFocus)
{
    super.onWindowFocusChanged(hasFocus);
    mUnityPlayer.windowFocusChanged(hasFocus);
}
public boolean dispatchKeyEvent(KeyEvent event)
{
    if (event.getAction() == KeyEvent.ACTION_MULTIPLE)
        return mUnityPlayer.onKeyMultiple(event.getKeyCode(), event.getRepeatCount(), event);
    return super.dispatchKeyEvent(event);
}
}

这是我试图使用vuforia的插件的java代码:

package com.devfo.andutils;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;

public class DevfoSms {
private Context _context;

public DevfoSms(DevfoUnityPlayerActivity context){
    this._context = context;
}

public void launchSmsActivity(){
    launchSmsActivity(null, null);
}

public void launchSmsActivity(String number){
    launchSmsActivity(number, null);
}

public void launchSmsActivity(String number, String body){
    Intent smsIntent = new Intent("android.intent.action.SENDTO");
    smsIntent.setType("vnd.android-dir/mms-sms");
    if (number != null) {
    smsIntent.setData(Uri.parse("sms:" + number));
  }
  if (body != null) {
      smsIntent.putExtra("sms_body", body);
  }
      this._context.startActivity(smsIntent);
  }
}

然后在清单中我有几个问题,包名称是不同的:

package="com.qualcomm.QCARUnityPlayer"
package="com.devfo.andutils"

这些是相互冲突的两项活动..........

<activity android:name="com.qualcomm.QCARUnityPlayer.QCARPlayerNativeActivity"
              android:label="@string/app_name"
              android:screenOrientation="portrait"
              android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
        <meta-data android:name="android.app.lib_name" android:value="unity" />
        <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

和...

<activity
        android:name="com.devfo.andutils.DevfoUnityPlayerActivity"
        android:label="@string/app_name"
        android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
        android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
    </activity>

我可以拥有2个包名,还是省略一个?谁能指出我正确的方向????我试图找人雇用,唯一回复的人想要1800美元然后再回复。我想我有自己需要的东西,但我被卡住了......

1 个答案:

答案 0 :(得分:0)

试试这个:

转到Unity - &gt;档案 - &gt;构建设置 - &gt; Android - &gt;检查Google Android项目 - &gt;出口。

通过Eclipse打开导出的项目。编辑清单文件 - &gt;由Eclipse构建。

祝你好运!