How to launch a regular Activity on Google Glass

雨燕双飞 提交于 2020-01-01 13:38:52

问题


I have been looking through the github examples for google glass and my code doesn't really look very different. With the exception of launching a regular TextView, my code should theoretically work. My Activity code is:

package com.helloglass;

import 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);


    }


}

My Layout is

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

And my manifest is

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

Now all I want to do is just see the damn view pop up, but I keep getting this error

[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.

I tested the example projects and they are working, so I doubt its my eclipse installation. I am trying to understand what I am doing wrong here because it isn't very clear in the GDK docs. There are barely any examples doing this. But my assumption is my code above will just be an immersion since the doc says that You create immersions using standard Android activities. Since there is no extra info on setting up anything special in the manifest, I fail to see what I am doing wrong. Any explanation on this would be greatly appreciated.


回答1:


This is not a Glass-specific problem, but an issue with a recent version of the Android build tools. Can you try some of the suggested fixes near the bottom of this thread and see if they fix it?

UPDATE: This seems to have been fixed in version 19.0.1 (December 2013) of the Android Build Tools. If you are experiencing this problem, upgrade using the Android SDK Manager and see if that solves it.




回答2:


edit: this solution ended up not giving me a usable apk

Android dex gives a BufferOverflowException when building

the answer of adding sdk.build.tools=18.1.1 to the project.properties worked for me.



来源:https://stackoverflow.com/questions/20292212/how-to-launch-a-regular-activity-on-google-glass

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!