I'm building a Xamarin android app.
After xamarin update I get a build error. I can't tell if that is related at all but what worked before now throws an exception: ClassNotFoundException. The class exists and is a proper activity. There was no change in that area at all.
I've seen many SO threads in that regard but they all suggest to clean solution, delete build folder etc. And that doesn't help me unfortunately.
What I realise is that in the exception message
W/monodroid( 4201): JNIEnv.FindClass(Type) caught unexpected exception: Java.Lang.ClassNotFoundException: md56629fa8edd4a41a77563f74c5f9a5f792.MainActivity the md5 part is not the same as the folder where the MainActivity.class resides in (md56b5cfc81a7b5c4227a0c9a4dcb7dab856). When I delete that folder a new one is generated during a build. Its md5 is different again. But the exception reappears, asking for the same old md5 as before.
My questions:
1.) What can I do to make JNIEnv look for the right md5?
2.) How are those md5 generated and why
Thanks.
Xamarin generates an MD5 sum for all types that have a Android Callable Wrapper (ACW), unless you explicitly give it a name. I guess this is done to avoid collisions with other types, which could live in the same package name. These are generated at build time.
In order to set your own name on a type inheriting from Java.Lang.Object, these are types like Activity, Adapter, View and many more. You simply add a Register attribute to your class:
[Register("my.cool.package.MyTypeName")]
public class MyTypeName : SomeJavaType
{
}
For classes such as Activity you can alternatively use the Name property in the Activity attribute:
[Activity(Label = "MyActivity", Name = "my.cool.package.MyActivity")]
public class MyActivity : Activity
{
}
Related
Class referenced in the manifest, se.linerotech.myapplication.RepositoryActivity, was not found in the project or the libraries
this is my first app ever (github browser),am copying the steps from a video and when i tried to debugg my app to see if i was getting the data for user it crashed
i tried to redo the steps and go over everything i did but it didnt work
Just to be clear, you have two different errors in those screenshots.
The one in the manifest is saying it can't find the Activity class with that name, for the reason outlined in CommonsWare's answer - it's looking for se.linerotech.myapplication.RepositoryActivity, and that's not where your class is. It's in red because it's an unrecognised name/not found.
The other error is in the output window - it's saying you have an Activity class at se.linerotech.myapplication.acitvity.RepositoryActivity which hasn't been added to the manifest. This is true (you tried adding it, but didn't do it right) and every Activity needs to be included in the manifest, which is why it's complaining.
The two errors stem from the same issue, I just wanted to make it clear what each one means, since if you just looked at the error log you might think you've used the correct fully-qualified name for the class (it's right there in the output!). But it's two different sides complaining about the same thing for different reasons.
Class referenced in the manifest, se.linerotech.myapplication.RepositoryActivity, was not found in the project or the libraries
That is because you do not have a class with that fully-qualified class name.
Your class is se.linerotech.myapplication.activity.RepositoryActivity, because it resides in the se.linerotech.myapplication.activity package. Use se.linerotech.myapplication.activity.RepositoryActivity instead of .RepositoryActivity in your manifest.
I have Unable to create application im.app.android.core.AppDemoApplication: e3.b: com.pushserver.android.huaweiPushClient cant cast com.myApp.android.push_lib.huawei.HcmPushClient to PushClient error
What proguard rule should I add? I have tried -keep class com.myApp.android.push_lib.** { *; } but after that I just see the blank screen - no crash, just stuck when trying to start.
Not really an answer, but too long for a comment. I'll update this answer in case we make progress.
1. What is the "normal bug"?
can't cast com.myApp.android.push_lib.huawei.HcmPushClient to PushClient
This means that somewhere in your code you are assigning/passing an instance of HcmPushClient to something that is expecting it to be a PushClient. I would assume that PushClient is some class that you defined in your project, but is does not extend from HcmPushClient. Try to find this piece of code and fix it or add it here to your question.
2. What does ProGuard have to do with this?
Actually, I think not much. If ProGuard would create this error, the message would look more like
can't cast com.myApp.android.push_lib.a.b to c
But since all class names in the error message are the original ones, it does not seem like ProGuard is making issues here. BUT: You can still decypher the message a little bit, because this part is obfuscated:
Unable to create application im.app.android.core.AppDemoApplication: e3.b:
e3.b refers to a class that was obfuscated by ProGuard. To find out what class it is, you can check the file /build/outputs/mapping/release/mapping.txt in your project folder. This is a simple text file that stores the information what class name was renamed to what obfuscated name. In this file search for -> e3 to find the class that was renamed to e3. Somewhere close to this line, you should also be able to find out what exactly e3.b is. Could be a method, could also be a member variable or an inner class.
I hope these two points will bring you closer to make the app run.
When I use the option "Build APK" in Android Studio 2.3.3 it generates a debug APK without issue, but when I try to generate a signed APK, an error appears:
Generate Signed APK: Errors while building APK. You can find the
errors in the 'Messages' view.
And in the 'Messages" view:
Error: Expected resource of type string [ResourceType]
It's doesn't seem to be a problem of the keystore or the signature, because it leads me to a line of the code, which is:
String color = getResources().getString(VarGlobales.color4).substring(3);
VarGlobales is just a class I created to define global variables, and of course it's imported correctly. VarGlobales.color4 is underlined, and when I hover, it says:
Expected resource of type string [less...] (Ctrl+F1) This inspection
looks at Android API calls that have been annotated with various
support annotations (such as RequiresPermission or UiThread) and flags
any calls that are not using the API correctly as specified by the
annotations. Examples of errors flagged by this inspection: Passing
the wrong type of resource integer (such as R.string) to an API that
expects a different type (such as R.dimen). Forgetting to invoke the
overridden method (via super) in methods that require it Calling a
method that requires a permission without having declared that
permission in the manifest Passing a resource color reference to a
method which expects an RGB integer value. ...and many more. For more
information, see the documentation at
http://developer.android.com/tools/debugging/annotations.html
VarGlobales.color4 is an Integer so, as far as I know, it should not give any error because getString() needs an Integer ID as a parameter. Doesn't the definition have the value I expected? It's like this:
// In VarGlobales class
public static int color4 = R.color.teal4;
R.color.teal4 was defined in colors.xml this way:
// In colors.xml
<color name="teal4">#00796B</color>
What's odd is that it doesn't give any error when building a debug APK so at first it shouldn't be a code problem.
I'm trying to bind an android SDK for voice chat (zoom sdk).
They have two .aar files (zoomcoomonlib.aar and zoomsdk.aar)
I know I have to create separate binding project for each .aar and then reference them.
While binding zoomsdk.aar I'm getting the below error
The type `Com.Zipow.Videobox.Onedrive.ErrorEventArgs' already contains a definition for `P0' (CS0102) (B14)
In the .aar file I navigated to the package com.zipow.videobox.onedrive; to the interface IODFoldLoaderListener
And below are the contents of it
So it seems parameter String var1 of method onError is causing the issue.
And xamarin studio generated obj/debug/api.xml confirms it (below screenshot) that onError will have first parameter named p0:
So in this scenario I change the metadata.xml to give this parameter a meaningful name.
Like below screenshot:
But even after doing that I am getting same error. That error didn't resolve.
Moreover now if I see the obj/debug/api/.xml file I see the contents for the class IODFoldLoaderListener remains the same.
So changing the metadata.xml has no effect it seems.
Your definition needs to be changed quite a bit. Here is an example that solves the same problem:
<attr path="/api/package[#name='com.emarsys.mobileengage.inbox']/interface[#name='ResetBadgeCountResultListener']/method[#name='onError' and count(parameter)=1 and parameter[1][#type='java.lang.Exception']]" name="argsType">ResetBadgeCountResultListenerOnErrorArgs</attr>
Please note the /interface and argsType items here as your initial definition is incorrect. You would then change the parameters to strings instead of java.lang.Exception from my example.
I'm using AndroidAnnotations in an Android Studio gradle project. I currently get error output from AA during compilation that says:
cannot find symbol class MyActivity_
The error output does not prevent building the application - its not really a compile error because the class is there, it seems that it is just an unfortunate timing issue with the compilation process.
Is there anything I can do to avoid these false-positive errors from AA? When there are "fake" errors shown every time I compile, its very easy to miss the real errors.
I had same error. To solve it I have revert my last changes and it has worked again.
I think it was either wrong optimized import(you must import generated classes eg. xxx_) or I injected layout by id what was not existed in the layout xml
Update
I figured it. My problem was what I had use private mofidier instead of proteced in
#ViewById(R.id.list)
private ListView list;
Try to see if you missed to fix some errors in the class MainActivity or in someone of his Bean member that you have annoted.
The problem doesn't have to be in MainActivty, but it is probably because of a private modifier which is used with Android Anotations (in injection, method declaration etc) somewhere in your code