Error accessing method in a class

Asked

Viewed 224 times

0

Within src I have a package called meus_utils and in this package I have the class utillog. In this class I have the method

public static boolean gerouLog(Context context){
    return true;
}

When I access this method by the Mainactivity class, it gives the following error:

the source Attachment does not contain the source for the file classloader.class android

Code that is accessing the method in the Mainactivity class:

import meus_utils.UtilLog;

public static boolean retornaGerouLog()
{
    boolean b = utillogs.gerouLog(this);

    return b;
}

o meu Properties

my Activity:

<activity
        android:name=".MainActivity"
        android:label="@string/app_name" >

and the java -version and javac -version are at the same values

  • Could include hierarchy from src folder?

  • myLocal -> com.example.mylocal -> MainActivity.java ---------- myLocal -> meus_utils -> utillog.java -> gerouLog()

  • Why do you pass on utillogs.gerouLog(this); an Activity as a parameter?

  • in the gerouLog method I use context.clearWallpaper();

1 answer

1

First check that your Activity is being configured correctly on Androidmanifest.xml. ex:

     <activity
        android:name="com.example.task.secondActivity"
        android:label="@string/app_name" />

If it doesn’t work, make sure your JDK and JRE versions are compatible with the commands:

javac -version

java - version

If it doesn’t work, try to see your Build Path if it is pointing to the correct location of your JDK in the eclipse settings itself on the path: Project > Properties > Java Build Path > Libraries.

If none of this picks up, try doing a test by instantiating Mainactivity in another class creating it as an input with the code:

Intent intent = new Intent(this, secondactivity.class);
startActivity(intent);

ps: Don’t forget to register on Androidmanifest.xml

And in case none of the options work, put here what’s coming out in Logcat for us to analyze better!

  • <Activity android:name=". Mainactivity" android:label="@string/app_name" >

  • Post the bug exactly as it is going on Logcat

  • does not leave in Logcat it opens a tab with the title Classloader.class, it contains a button that opens the explorer Change Attached Source and below the following code: // Compiled from ClassLoader.java (version 1.5 : 49.0, super bit)&#xA;public abstract class java.lang.ClassLoader {&#xA; &#xA; // Method descriptor #8 ()V&#xA; // Stack: 3, Locals: 1&#xA; protected ClassLoader();&#xA; 0 aload_0 [this]&#xA; 1 invokespecial java.lang.Object() [1]...

  • It may be that the two classes ". class" was compiled in the version of java 1.5 and your project is running with a lower version...download java 6, and modify the path (PATH in environment variables) of your java to point pro 1.6 and test. Also check the eclipse if it is pointing to the right java 1.6 folder at: window --> preferences ---> java ---> installed jre’s ---> click add and select there.

  • I did a test with the Connectivitymanager class within the Mainactivity class and qnd will instantiate the method gives the same error !!

  • Do what I said above, update the java versions and modify the system PATH and Android as well.

  • Got guy?

  • It did not solve, I did the java update and nothing. I downloaded the version of Android Studio, but to make the updates of SDK Manager is very slow. :(

  • Tricky...try changing the development and testing IDE, if it works, goodbye to Eclipse. :P

Show 4 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.