2

Hello i'm tring to programm an app for android with the Glympse API but every time i try to use the createGlymspe function to create the Glympse instance i get this error

 08-21 11:10:47.014: E/AndroidRuntime(22391): FATAL EXCEPTION: main
08-21 11:10:47.014: E/AndroidRuntime(22391): java.lang.ExceptionInInitializerError
08-21 11:10:47.014: E/AndroidRuntime(22391):    at com.glympse.android.hal.l.<init>(ContextHolder.java:29)
08-21 11:10:47.014: E/AndroidRuntime(22391):    at com.glympse.android.hal.bd.l(HalFactory.java:23)
08-21 11:10:47.014: E/AndroidRuntime(22391):    at com.glympse.android.a.gz.a(LibFactory.java:35)
08-21 11:10:47.014: E/AndroidRuntime(22391):    at com.glympse.android.api.ad.a(GlympseFactory.java:72)
08-21 11:10:47.014: E/AndroidRuntime(22391):    at com.glympse.android.api.ad.a(GlympseFactory.java:54)
08-21 11:10:47.014: E/AndroidRuntime(22391):    at com.glympse.android.lite.LiteFactory.createGlympse(LiteFactory.java:42)
08-21 11:10:47.014: E/AndroidRuntime(22391):    at pcr.test02.MainActivity$1.onClick(MainActivity.java:27)
08-21 11:10:47.014: E/AndroidRuntime(22391):    at android.view.View.performClick(View.java:3558)
08-21 11:10:47.014: E/AndroidRuntime(22391):    at android.view.View$PerformClick.run(View.java:14157)
08-21 11:10:47.014: E/AndroidRuntime(22391):    at android.os.Handler.handleCallback(Handler.java:605)
08-21 11:10:47.014: E/AndroidRuntime(22391):    at android.os.Handler.dispatchMessage(Handler.java:92)
08-21 11:10:47.014: E/AndroidRuntime(22391):    at android.os.Looper.loop(Looper.java:137)
08-21 11:10:47.014: E/AndroidRuntime(22391):    at android.app.ActivityThread.main(ActivityThread.java:4514)
08-21 11:10:47.014: E/AndroidRuntime(22391):    at java.lang.reflect.Method.invokeNative(Native Method)
08-21 11:10:47.014: E/AndroidRuntime(22391):    at java.lang.reflect.Method.invoke(Method.java:511)
08-21 11:10:47.014: E/AndroidRuntime(22391):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
08-21 11:10:47.014: E/AndroidRuntime(22391):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
08-21 11:10:47.014: E/AndroidRuntime(22391):    at dalvik.system.NativeStart.main(Native Method)
08-21 11:10:47.014: E/AndroidRuntime(22391): Caused by: java.lang.NoClassDefFoundError: com.glympse.android.api.R$drawable
08-21 11:10:47.014: E/AndroidRuntime(22391):    at com.glympse.android.hal.db.<clinit>(ResourceGateway.java:13)
08-21 11:10:47.014: E/AndroidRuntime(22391):    ... 18 more

Here is the code:

package pcr.test02;

import com.glympse.android.lite.GGlympseLite;
import com.glympse.android.lite.LiteFactory;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends Activity {
    GGlympseLite glympse;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        glympse = LiteFactory.createGlympse(getBaseContext(), "sandbox.glympse.com", "I will not share my key ;-)");
        Button btn1 = (Button) findViewById(R.id.button1);
        btn1.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
        Toast.makeText(getApplicationContext(), "Glymp",
        Toast.LENGTH_LONG).show();

        }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

i'm not sure if the problem is the context but i've tried to change it with "this" but it did not help

1 Answers1

2

I was able to reproduce the issue and I do not see any problems in your code, but there is very likely a problem with the project setup.

The first thing to check is to make sure you haven't put the GlympseApiLite.jar directly in your project's "libs" folder. Many Android developers started to see this error with the release of Android Developer Tools (ADT) 17 because there was a change in the way Android libraries were supposed to be imported.

Instead (if you are using Eclipse)

  1. Go to File -> Import -> Android -> Existing Android Code Into Workspace
  2. Locate GlympseApiLite project at {wherever you downloaded the library}/lib/GlympseApiLite.
  3. Press Finish in Import Projects dialog.

This will import GlympseApiLite as a project. The next step is to reference that project from your project.

  1. Right click your project
  2. Select Properties
  3. Select Android in the list at the left
  4. In the Library section, select Add...
  5. Select GlympseApi, then OK

Let me know if this fixes the issue for you. Take a look at our setup documentation especially the step by step guide in case you run into any more trouble.

Step by step (PDF): https://developer.glympse.com/Content/client/lite/android/tutorials/Glympse_Api_Lite_Android_StepByStep.pdf

Quick introduction (HTML): https://developer.glympse.com/Content/client/lite/android/guides/Glympse_Api_Lite_Android_QuickIntroduction.html

Edit (responses to replies):

The error "Unable to resolve target 'android-17'" appears because the GlympseApi Project was built against that version of the Android API. You can edit the file "project.properties" for GlympseAPI and change the value of "target" to a version that you have installed. The latest as of this moment would be android-18. Additional information in this thread: Unable to resolve target 'android-16'

For the Jar Mismatch error. See this other StackOverflow thread: Jar Mismatch Found 2 versions of android-support-v4.jar in the dependency list

Community
  • 1
  • 1
  • I alrady tried this but as i import the GlympseApiLite project in the eclipse workbench i get this error in the console:"[2013-08-22 18:44:48 - GlympseApi] Unable to resolve target 'android-17' [2013-08-22 18:44:48 - GlympseApi] Unable to resolve target 'android-17'" – user2702899 Aug 22 '13 at 16:48
  • [2013-08-22 18:45:23 - Test003] Found 2 versions of android-support-v4.jar in the dependency list, [2013-08-22 18:45:23 - Test003] but not all the versions are identical (check is based on SHA-1 only at this time). [2013-08-22 18:45:23 - Test003] All versions of the libraries must be the same at this time. [2013-08-22 18:45:23 - Test003] Versions found are: – user2702899 Aug 22 '13 at 16:50
  • [2013-08-22 18:45:23 - Test003] Path: C:\Users\Gioele\workspace-androidNew\Test003\libs\android-support-v4.jar [2013-08-22 18:45:23 - Test003] Length: 556198 [2013-08-22 18:45:23 - Test003] SHA-1: 4a6be13368bb64c5a0b0460632d228a1a915f58f [2013-08-22 18:45:23 - Test003] Path: C:\Android\Glympse\lib\GlympseApiLite\libs\android-support-v4.jar [2013-08-22 18:45:23 - Test003] Length: 393154 [2013-08-22 18:45:23 - Test003] SHA-1: 307c1cc532eabbf1d135b43e5c983c9da700449d [2013-08-22 18:45:23 - Test003] Jar mismatch! Fix your dependencies – user2702899 Aug 22 '13 at 16:50
  • excuse for this messed up answer – user2702899 Aug 22 '13 at 16:52
  • I have updated my answer for the other errors you are seeing. – Nick Glickenhouse Aug 22 '13 at 22:19
  • what if i use Android Studio? same problem. who still uses eclipse for android development..seriously – philtz Oct 27 '14 at 07:47