I tried to build Android ICS on Ubuntu 10.04 LTS. All was fine, until ubuntu installed next update for Java.
After this, build fails with error 41:
out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/java/util/PropertyPermission.java:2: java.util.PropertyPermission is not abstract and does not override abstract method hashCode() in java.security.Permission
public final class PropertyPermission
^
out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/java/util/logging/LoggingPermission.java:2: java.util.logging.LoggingPermission is not abstract and does not override abstract method hashCode() in java.security.Permission
public final class LoggingPermission
^
out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/javax/net/ssl/SSLPermission.java:2: javax.net.ssl.SSLPermission is not abstract and does not override abstract method hashCode() in java.security.Permission
public final class SSLPermission
^
out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/javax/security/auth/AuthPermission.java:2: javax.security.auth.AuthPermission is not abstract and does not override abstract method hashCode() in java.security.Permission
public final class AuthPermission
^
out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/javax/security/auth/PrivateCredentialPermission.java:2: javax.security.auth.PrivateCredentialPermission is not abstract and does not override abstract method hashCode() in java.security.Permission
public final class PrivateCredentialPermission
^
out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/org/apache/http/impl/conn/tsccm/BasicPoolEntryRef.java:5: warning: [unchecked] unchecked conversion
found : java.lang.ref.ReferenceQueue
required: java.lang.ref.ReferenceQueue<? super org.apache.http.impl.conn.tsccm.BasicPoolEntry>
public BasicPoolEntryRef(org.apache.http.impl.conn.tsccm.BasicPoolEntry entry, java.lang.ref.ReferenceQueue<java.lang.Object> queue) { super(null,(java.lang.ref.ReferenceQueue)null); throw new RuntimeException("Stub!"); }
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
111 errors
6 warnings
make: *** [out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/classes.jar] Error 41
I searched through net, but found only this tip: http://kimoto.tistory.com/26 and some questions (unanswered) in mailing lists.
Unfortunately, it didn't help for me.
My JAVA_HOME points to /usr/lib/jvm/java-6-sun which is symlink to jdk1.6.0_30.
So looks like I now used latest version of Java.
Ok, resolution was to use open-jdk instead of jdk. It helped to me.
Related
I am trying to interface with native Android methods from C# in Unity using AndroidJNI, however I can only resolve classes, not methods.
I have also used the 'simpler variants', meaning AndroidJavaClass interface, but the error says its trying to resolve the methods from java.lang.Object, therefore I moved onto using AndroidJNI, but am stuck resolving the methods.
I have the following java method
public static String getParamsString2() {
return "asd";
}
and the following c# code trying to resolve the method id
AndroidJNI.GetStaticMethodID(activityClass, "getParamsString2", "()Ljava/lang/String;");
I have verified from the decompiler that the signature is correct, however I end up receiving the following error
java.lang.NoSuchMethodError: no static method "Lfi/matalamaki/plugin/UnityPlayerActivity;.getParamsString2()Ljava/lang/String;
When I decompile the class there actually is the class which contains the method
public static getParamsString2() { //()Ljava/lang/String;
L1 {
ldc "asd" (java.lang.String)
areturn
}
}
The class is also correct, fi/matalamaki/plugin/UnityPlayerActivity
when using the AndroidJavaClass interface with code
string referrer3 = new AndroidJavaClass("fi.matalamaki.plugin.UnityPlayerActivity").CallStatic<string>("getParamsString2", new object[0]);
I get the following error AndroidJavaException: java.lang.NoSuchMethodError: no static method with name='getParamsString2' signature='()Ljava/lang/String;' in class Ljava.lang.Object;
java.lang.NoSuchMethodError: no static method with name='getParamsString2' signature='()Ljava/lang/String;' in class Ljava.lang.Object;
which seems to indicate that its trying to resolve the method from java.lang.Object instead of my own class..
I've tried different parameter and return type combinations but no luck..
I've also verified the built APK dex by decompiling it..
Apparently it was Proguard that by minifying or by obfuscating removed the method or renamed it. I have no idea how after verifying I saw the method there, but maybe I wasn't paying enough attention, and it had its name changed or so.
After adding a proguard exclusion on my package and its fields and methods the problem is now solved.
We are having an interface with default methods and we implemented that interface in both Java and Kotlin classes and we provided the implementation for the non default methods.
When we run in debug mode (which doesn't have testCoverageEnabled = true) and the app works as expected. But when we run in different config with testCoverageEnabled = true, the app is crashing with below error
java.lang.NoSuchMethodError: No static method $$triggerInterfaceInit()V in class Lcom/ui/viewholders/CAViewContract$$CC; or its super classes (declaration of 'ui.viewholders.CAViewContract$$CC' appears in /data/app/SMCXbiLYvHb1Kk08Kee__g==/base.apk)
at home.c.CCFragment.<clinit>(Unknown Source:0)
at home.HomePageCardProvider.getFragment(HomePageCardProvider.java:17)
at home.HomeFragment.handleCardFragment(HomeFragment.java:172)
Note:
1. JaCoCo version: "0.8.0"
2. Operating system: Android with minSdk 21
If we change the minSdk to 24, with testCoverageEnabled = true itself, it is working. We are not able to figure out the exact problem.
This problem can occur if you want to invoke the default implementation of a method that hasn't a default implementation in the interface that your class explicitly implements it. (But has a default implementation in a base (parent, super) interface of that interface).
Example: Suppose these defenitions:
class A implements DerivedInterface /*, ...*/ {
#Override public void methodFromBaseInterface() {
DerivedInterface.super.methodFromBaseInterface(); // Error:
// NoSuchMethodError: No static method methodFromBaseInterface
}
// ...
}
interface DerivedInterface extends BaseInterface {
// ...
// `methodFromBaseInterface` hasn't overriden here.
}
interface BaseInterface {
default void methodFromBaseInterface() { /* ...*/ }
// ...
}
Then execute:
A a = new A();
a.methodFromBaseInterface(); // This cause above error!
And you get an error at mentioned point!
(Marginal note: You may need to define at least one method in DerivedInterface to avoid getting NoClassDefFoundError at runtime!)
This is similar to a bug! We used super keyword. Why expected static method?!! Another point is that the above code hasn't any problem and you can run it in any Java 8 compatible environment without any problem!
I think the problem is related to incomplete support of Java 8 language APIs in Android platform:
Android Studio 3.0 and later supports all Java 7 language features and a subset of Java 8 language features that vary by platform version.
Specially see Java 8 Language API and Compatible minSdkVersion table in that page:
java.lang.FunctionalInterface : API level 24 or higher.
Workarounds I found:
If you have access to the definition of DerivedInterface simply override methodFromBaseInterface and explicitly delegates it to its super interface:
interface DerivedInterface extends BaseInterface {
#Override default void methodFromBaseInterface() {
BaseInterface.super.methodFromBaseInterface();
}
// ...
}
Define a middle class that implements BaseInterface and derive A from it. Then run methodFromBaseInterface indirectly throw the middle class:
class MiddleClass /*extends B*/ implements BaseInterface {}
class A extends MiddleClass implements DerivedInterface {
#Override public void methodFromBaseInterface() {
super.methodFromBaseInterface(); // Indirectly from `MiddleClass`
}
// ...
}
Note: Uncomment /*extends B*/ if your A class previously has a super named B.
I have two inner classes and a method:
protected <A extends Obj1> void a(P<A> p)
{}
private static class P<Z extends Obj1>
{}
private static class Obj1
{}
It's compiling fine, but when I try in Eclipse Mars to change the method a's signature by giving it a second attribute this way
gives the following error:
Bound mismatch: The type A is not a valid substitute for the bounded
parameter <Z extends Test.Obj1> of the type Test.P<Z>
Now actually I have two questions about this. Why is this behavioural difference and what did I do wrong?
Strangely when I modify manually a to this:
protected <A extends Obj1> void a(P<? extends A> p)
{}
and try to change the signature the previously decribed manner I don't get that error. I have a feeling that this may be a bug either in Java or Eclipse, but don't really know where to start seaching. so I give you their versions too if it helps:
Eclipse Mars.2 (4.5.2)
Java 1.8.0.77
UPDATE:
So I've tried more different versions of Eclipse and Java 8, but the result is the same.
Salve...
some Problem for me in Java. I have generated an Interface and an Class implements this Interface. In the Interface i have declared one Method... and in the Class i will Override this. But not works! But don`t why....
See my example Interface:
public interface IMyClass extends IInterfaceA<IInterfaceB> {
public List<IInterfaceB> getMethod(Integer id);
}
See now my Class File:
public class MyClass implements IMyClass {
#Override
public List<IInterfaceB> getMethod(Integer id) {
return anything;
}
}
Problem is... i think i make no mistake. And next - i surprise that i have another Interfaces and Classes with the same Logic - and it will work and make no Problems!
In my another Interfaces & Classes i don`t need to make the Class with implements the Interface an Abstract Class.
When i make an build... Jenkins will surprise me with this Message:
[ERROR] COMPILATION ERROR :
error: MyClass is not abstract and does not override abstract method getMethode() in IMyClass [ERROR]
error: method does not override or implement a method from a supertype [INFO] 2 errors [INFO]
Solved . The " solution " - was a build problem . After tens of Maven Clean Installs and re- builds he has the connection interface and class savvy and it goes... oh men ;)
I have following code:
class Key{
--Some Implementation
}
class A{
public void grpMap(ConcurrentMap<Key,List<Key> keyList){
--Some Implementation
}
}
public class B extends A{
--Edited
#Override -- [Made "O" capital case after kocko's reply]
public void grpMap(ConcurrentMap<Key,List<Key> keyList){
--Some Implementation
}
}
With above code i get following error in class B
The method grpMap(ConcurrentMap) of type B must override
or implement a supertype method
My problem is i can't change the way classes key, B and C are declared as these are legacy classes.
Any suggestion on how to get rid of this error?
EDIT---
JDK version used is 1.6.43
I am using eclipse which will auto generate annotations.
The annotation
#override
should be
#Override
↑
Also, check you Java version in the IDE - it should be 1.6, or newer, in order to get rid of the error.
Open Project properties -> Java compiler -> Set compliance level to 1.6 -> OK.