4

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.

Andy
  • 10,553
  • 21
  • 75
  • 125
  • Did you check the stack trace? – keyser Nov 29 '13 at 19:23
  • @ᴋᴇʏsᴇʀ The 2 lines I showed above is exactly what shows. But it never actually runs on glass. It just tells me there is an error in my code. Nothing screams out wrong, and there is no red anywhere. I just get that error. – Andy Nov 29 '13 at 19:25
  • I was referring to the `Check the Eclipse log for stack trace.` part. There's no such log? – keyser Nov 29 '13 at 19:27
  • I am not sure where that log would go actually. – Andy Nov 29 '13 at 19:33
  • Post your stack trace. – Subramanian Ramsundaram Nov 29 '13 at 19:50
  • I have no idea how to access the eclipse stack trace. I did a google search but its not in my perspective @Homosapiens I am using Kepler. In fact this Dex issue didm;t exist until recently. I upgraded because my previous eclipse installation was causing me issues. – Andy Nov 29 '13 at 19:51
  • go to DEBUG or DDMS perspective and find (or show) the LogCat view, therein lies the logs. – straya Nov 30 '13 at 12:53
  • @straya I know where that is located. I do not know where the eclipse specific error log is. Because the logcat won't show anything if it won't let me even push the apk to it. So that log does not matter. Like the error I posted above is literally what shows. – Andy Nov 30 '13 at 23:44
  • Window -> Show Perspective -> Error Log -> Double click the message of interest and a window with your stack trace should pop up. – Submersed Dec 04 '13 at 15:51
  • @Andy I guess you have resolved this issue.This app has only one screen so can you please share the screenshot. I want to know how your view(FrameLayout with TextView) looks in Google Glass. Thanks – ravi Dec 27 '13 at 11:35

2 Answers2

7

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.

Tony Allevato
  • 6,429
  • 1
  • 29
  • 34
  • Thanks for the input. I am noticing people are having issues with the latest android build. I think the issue in this case lies with my installation. I've had problems with other programs recently. I think I will just take this opportunity to clean install mavericks and go from there. Thanks though. – Andy Nov 30 '13 at 23:48
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.

Community
  • 1
  • 1
yincrash
  • 6,394
  • 1
  • 39
  • 41