如何在Google Glass上启动常规活动

时间:2013-11-29 19:21:07

标签: android google-glass

我一直在浏览谷歌眼镜的github示例,我的代码看起来并没有太大的不同。除了启动常规TextView之外,我的代码在理论上应该可行。我的活动代码是:

package com.helloglass;

导入android.os.Bundle; import android.app.Activity;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


    }


}

我的布局是

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin" >

    <TextView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World"/>


</FrameLayout>

我的清单是

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

    <uses-sdk
        android:minSdkVersion="15"
        android:targetSdkVersion="15" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name="com.helloglass.MainActivity"
            android:label="@string/app_name_hello"
            android:enabled="true" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>
        </activity>
    </application>

</manifest>

现在我想做的只是看到该死的视图弹出,但我一直收到此错误

[2013-11-29 14:04:49 - Dex Loader] Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace.
[2013-11-29 14:04:49 - HelloGlass] Conversion to Dalvik format failed: Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace.

我测试了示例项目并且它们正在工作,所以我怀疑它是我的eclipse安装。我试图理解我在这里做错了什么因为在GDK文档中不是很清楚。这样做几乎没有任何例子。但我的假设是上面的代码只是沉浸,因为文档说You create immersions using standard Android activities。由于没有关于在清单中设置任何特殊内容的额外信息,我无法看到我做错了什么。对此的任何解释都将非常感激。

2 个答案:

答案 0 :(得分:7)

这不是特定于Glass的问题,而是最近版本的Android构建工具的问题。您可以尝试this thread底部附近的一些建议修补程序,看看他们是否修复了它?

更新:这似乎已在Android Build Tools的version 19.0.1 (December 2013)中得到修复。如果您遇到此问题,请使用Android SDK Manager进行升级,看看是否能解决问题。

答案 1 :(得分:2)

编辑:此解决方案最终没有给我一个可用的apk

Android dex gives a BufferOverflowException when building

补充的答案 sdk.build.tools=18.1.1项目.properties为我工作。

相关问题