Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.IllegalAccessError class ref in preverified class resolved to unexpected implementation

Im getting an "java.lang.IllegalAccessError class ref in preverified class resolved to unexpected implementation" error when I push a button that starts a method in MainActivity which is supposed to start a new Activity. What can I do to fix this? This is my first attempt to make an android application, so ill need step by step instructions :)

Also I havent been able to test if it works yet, but if you notice anything wrong with my AugiActivity service implementation or the local broadcast implementation feel free to let me know.

Thanks!

fyi: MainActivity starts Navigation Activity, which starts Service AugiActivity

Augi activity sends local broadcast messages to Navigation

LogCat:

03-24 20:01:56.632: E/AndroidRuntime(11183): FATAL EXCEPTION: main
03-24 20:01:56.632: E/AndroidRuntime(11183): java.lang.IllegalStateException: Could not     
execute method of the activity
03-24 20:01:56.632: E/AndroidRuntime(11183): at 
android.view.View$1.onClick(View.java:2154)
03-24 20:01:56.632: E/AndroidRuntime(11183):    at 
android.view.View.performClick(View.java:2537)
03-24 20:01:56.632: E/AndroidRuntime(11183):    at 
android.view.View$PerformClick.run(View.java:9157)
03-24 20:01:56.632: E/AndroidRuntime(11183):    at 
android.os.Handler.handleCallback(Handler.java:587)
03-24 20:01:56.632: E/AndroidRuntime(11183):    at 
android.os.Handler.dispatchMessage(Handler.java:92)
03-24 20:01:56.632: E/AndroidRuntime(11183):    at 
android.os.Looper.loop(Looper.java:130)
03-24 20:01:56.632: E/AndroidRuntime(11183):    at   
android.app.ActivityThread.main(ActivityThread.java:3687)
03-24 20:01:56.632: E/AndroidRuntime(11183):    at   
java.lang.reflect.Method.invokeNative(Native Method)
03-24 20:01:56.632: E/AndroidRuntime(11183):    at   
java.lang.reflect.Method.invoke(Method.java:507)
03-24 20:01:56.632: E/AndroidRuntime(11183):    at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
03-24 20:01:56.632: E/AndroidRuntime(11183):    at   
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
03-24 20:01:56.632: E/AndroidRuntime(11183):    at   
dalvik.system.NativeStart.main(Native Method)
03-24 20:01:56.632: E/AndroidRuntime(11183): Caused by:   
java.lang.reflect.InvocationTargetException
03-24 20:01:56.632: E/AndroidRuntime(11183):    at 
java.lang.reflect.Method.invokeNative(Native Method)
03-24 20:01:56.632: E/AndroidRuntime(11183):    at 
java.lang.reflect.Method.invoke(Method.java:507)
03-24 20:01:56.632: E/AndroidRuntime(11183):    at 
android.view.View$1.onClick(View.java:2149)
03-24 20:01:56.632: E/AndroidRuntime(11183):    ... 11 more
03-24 20:01:56.632: E/AndroidRuntime(11183): Caused by: java.lang.NoClassDefFoundError: 
com.example.augi_practice.Navigation
03-24 20:01:56.632: E/AndroidRuntime(11183):    at 
com.example.augi_practice.MainActivity.navigation(MainActivity.java:33)
03-24 20:01:56.632: E/AndroidRuntime(11183):    ... 14 more
03-24 20:01:56.632: E/AndroidRuntime(11183): Caused by: java.lang.IllegalAccessError: 
Class ref in pre-verified class resolved to unexpected implementation
03-24 20:01:56.632: E/AndroidRuntime(11183):    at 
dalvik.system.DexFile.defineClass(Native Method)
03-24 20:01:56.632: E/AndroidRuntime(11183):    at 
dalvik.system.DexFile.loadClassBinaryName(DexFile.java:207)
03-24 20:01:56.632: E/AndroidRuntime(11183):    at 
dalvik.system.PathClassLoader.findClass(PathClassLoader.java:200)
03-24 20:01:56.632: E/AndroidRuntime(11183):    at 
java.lang.ClassLoader.loadClass(ClassLoader.java:551)
03-24 20:01:56.632: E/AndroidRuntime(11183):    at 
java.lang.ClassLoader.loadClass(ClassLoader.java:511)
03-24 20:01:56.632: E/AndroidRuntime(11183):    ... 15 more

XML File:

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

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

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 


<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.augi_practice.MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="landscape" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"   
/>
        </intent-filter>
    </activity>
     <activity
        android:name="com.example.augi_practice.Navigation"
        android:label="@string/title_activity_navigation" 
        android:screenOrientation="landscape" >
    </activity>
    <service
        android:name="com.example.augi_practice.AugiActivity"
        android:label="@string/title_activity_augi"
        android:parentActivityName="com.example.augi_practice.Navigation"
        android:screenOrientation="landscape" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.augi_practice.Navigation" />            
    </service>       
    <uses-library android:name="com.google.android.maps" />    
</application>

</manifest>

Main Activity:

package com.example.augi_practice;

import ioio.lib.util.android.IOIOActivity;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;

public class MainActivity extends Activity {

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

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

public void call_ioio(View v)
{   
    Intent intent = new Intent(this, AugiActivity.class);
    startActivity(intent);
}

public void navigation(View v)
{   
    Intent intent = new Intent(this, Navigation.class);
    startActivity(intent);
}

}

Navigation Activity:

package com.example.augi_practice;

// Lots of imports here


public class Navigation extends MapActivity implements Runnable,   
SurfaceHolder.Callback{

String LED = null;
String MAG = null;
String BAR = null;
String GYRO = null;
String EULER = null;    
String GGA = null;

private BroadcastReceiver MessageReceiver = new BroadcastReceiver()
{
    @Override
    public void onReceive(Context context, Intent intent)
    {
        LED = intent.getStringExtra("LED");
        MAG = intent.getStringExtra("MAG");
        BAR = intent.getStringExtra("BAR");
        GYRO = intent.getStringExtra("GYRO");
        EULER = intent.getStringExtra("EULER");
        GGA = intent.getStringExtra("GGA");         
    }
};

// More global variables

// Lots of gui variables here

// More global variables

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_navigation);
    MapView mapview = (MapView) findViewById(R.id.mapview);
    mapview.setBuiltInZoomControls(true);   

    getWindow().setFormat(PixelFormat.UNKNOWN);

    // Camera configuration settings

    LocalBroadcastManager.getInstance(this).registerReceiver(MessageReceiver, 
new IntentFilter("IOIOData"));

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

            // Lots of links from acivity to gui 

    startService( new Intent(this, AugiActivity.class));        
}

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

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
        int height) {
    // TODO Auto-generated method stub

}

@Override
public void surfaceCreated(SurfaceHolder holder) {
    // TODO Auto-generated method stub

}

@Override
public void surfaceDestroyed(SurfaceHolder holder) {
    // TODO Auto-generated method stub

}

public void sensorLayer(View v)
{
    // Executes some code
}

public void mapLayer(View v)
{
    // Executes some code
}

public void cameraLayer(View v)
{
    // Executes some code
}   

@Override
public void run() {
    //Executes some code
}   
}

Part of AugiActivity:

package com.example.augi_practice;

//lots of imports here


public class AugiActivity extends Service { 

public Activity activity_name;

class IOIO extends IOIOActivity {   


// Lots of global variables

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState); 
    activity_name = this.getParent();
}

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

class Looper extends BaseIOIOLooper {
    /** The on-board LED. */
    // Class variables

    public Activity activity_name;

    Looper(Activity x)
    {
        this.activity_name = x;
    }       

    // More class variables

    /**
    * Called every time a connection with IOIO has been established.
    * Typically used to open pins.
    *   
    * @throws ConnectionLostException
    *             When IOIO connection is lost.
     * @throws InterruptedException 
    * 
    * @see ioio.lib.util.AbstractIOIOActivity.IOIOThread#setup()
    */
        @Override
        protected void setup() throws ConnectionLostException, 
InterruptedException 
        {
            // establish various connections here

            bar_calibration();      
            mag_setup();
            imu_setup();    
            try {
                gps_setup();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        // Various setup methods here

    /**
    * Called repetitively while the IOIO is connected.
    * 
    * @throws ConnectionLostException
    *             When IOIO connection is lost.
     * @throws InterruptedException 
    * 
    * @see ioio.lib.util.AbstractIOIOActivity.IOIOThread#loop()
    */


    @Override
        public void loop() throws ConnectionLostException, 
InterruptedException 
        {           
            get_light();

            get_temp();

            get_pressure();

            get_north();

            get_imu();

            try {
                get_gps();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            led_.write(true);   

            sendMessage();
        }

        // Various methodes to get data

        private void sendMessage()
        {
            Intent intent = new Intent("IOIOData");     

            intent.putExtra("LED", get_LED());

LocalBroadcastManager.getInstance(activity_name).sendBroadcast(intent);

            intent.putExtra("MAG", get_MAG());

LocalBroadcastManager.getInstance(activity_name).sendBroadcast(intent);

            intent.putExtra("BAR", get_BAR());

LocalBroadcastManager.getInstance(activity_name).sendBroadcast(intent);

            intent.putExtra("GYRO", get_GYRO());

LocalBroadcastManager.getInstance(activity_name).sendBroadcast(intent);

            intent.putExtra("EULER", get_EULER());

LocalBroadcastManager.getInstance(activity_name).sendBroadcast(intent);

            intent.putExtra("GGA", gps_GGA);

LocalBroadcastManager.getInstance(activity_name).sendBroadcast(intent);
        }
    }
like image 944
The Starfox Avatar asked Dec 21 '22 08:12

The Starfox


2 Answers

In my case I changed project setting in Intelij Idea. Go to modules -> dependencies, then set scope of the lib to 'Provided'.

like image 133
Paweł Byszewski Avatar answered Dec 22 '22 20:12

Paweł Byszewski


in Open Module Settings->dependencies

setting the scope for the line

{include=[*.jar], dir=libs}

to provided

worked for me

like image 32
user330844 Avatar answered Dec 22 '22 21:12

user330844