android - 如何在 Google Glass 上启动常规 Activity

标签 android google-glass

我一直在查看 google glass 的 github 示例,我的代码看起来并没有太大不同。除了启动常规 TextView 之外,我的代码理论上应该可以工作。我的 Activity 代码是:

包 com.helloglass;

导入android.os.Bundle; 导入 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>

我的 list 是

<?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>

现在我只想看到该死的 View 弹出,但我一直收到这个错误

[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 activity。由于 list 中没有关于设置任何特殊内容的额外信息,所以我看不出我做错了什么。对此的任何解释将不胜感激。

最佳答案

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

更新:这似乎已在 version 19.0.1 (December 2013) 中修复的 Android 构建工具。如果您遇到此问题,请使用 Android SDK 管理器升级并查看是否可以解决问题。

关于android - 如何在 Google Glass 上启动常规 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20292212/

相关文章:

android - 如何在 Android 上创建本地化的时间前字符串

android - 从服务调用接收异步数据时如何更新谷歌眼镜菜单

google-glass - 发布使用 GDK 开发的应用程序/玻璃器具

google-glass - 找不到任何玻璃 API 的类错误

android - 如何使给定的颜色变暗(int)

android - task.getResult() 抛出 java.lang.ClassCastException

android - 为什么使用隐式 Intent 启动服务不安全?

破坏 WebView 后,Android HTML5 视频不会关闭

google-glass - 无法在时间轴中插入卡片

安卓/玻璃 : How to trigger surfaceDestroyed