Unity ScriptableObject is missing on mobile build - android

I have a MonoBehaviour class that has a property referencing another class which is ScriptableObject.
I've created several prefabs of my first class and created several ScriptableObjects of my second class, I've referenced them in the first class respectively.
In the editor everything works fine, except sometimes my so are shown in the Inspector as Missing Script and in property reference as NameOfSO (), don't know what causing this, but again, Play in the Editor is working just fine.
If build my game for Android and connect to the Debug, to see what's going on, I can clearly see, that's ScriptableObject reference is null. Why? Don't know, came here to ask a question.
Thanks!

I figured it out, turns out this was happening because of the weird thing with namings.
Allow me to explain, when I first created a class from ScriptableObject I used, lets say, MyClas name, I've created several instances of that class, but then I saw the error in the name of the class, I've changed it to the MyClass but only in the file itself, not the actual .cs file, so, this was happening. All I had to do is to ensure that my class and my file names are the same, delete old instances of ScriptableObject and create new ones from scratch and... Voila!
Sorry.

Related

how to declared an activity in AndroidManifest.xml?

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.

Proguard rule for Huawei push client

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.

'this#ActivityName' is not captured error Android/Kotlin

I'm repairing my friend's code and got confused.
My friend wants to fetch entered text (in EditText). Seems easy, right? Well, it is but instead of user input, he gets this warning/error:
To be honest I'm not sure how to fix it. He is coding in Kotlin (Android 10).
Activity that contains EditText:
And XML:
This is how it looks when debugging:
The app started working just fine after running "File -> invalidate Cashes/Restart" option, I just don't understand where this warning came from and how to fix it because the error remained unchanged (even though the app works). Do you have an idea how to solve it?
All the best!
fyi lambda expression like setOnClickListener from kotlin is not debuggable, see here.
if you want to debug variables inside setOnClickListener you should use the normal one e.g. setOnClickListener(object: View.OnClickListener {..})
sometimes there will be problem in auto generated binding files, if so it will be solved after invalidate cache and restart ide. sometimes the warning/error show but the project and complied without errors. so no need to worry about that. for next time post the code as code not screen shots.
I understand that the question is regarding evaluating expression, but there is a way you can read variables from your debugger console, even if you're inside an anonymous callback. I found it helpful sometimes. Here are the steps:
First enter debugger mode inside of your anonymous callback,
In your debugger console, look at the right side for "Frames"
Within Frames under , you'll see stack of function execution first top one on the list is the latest:
Click on row(s) below the latest function, until you find an instance of your activity AddInformationActivity. You will see the activity instance on the right side window under Variables. Don't go as far as selecting functions browned out, because those are from internal libraries.
When you see you AddInformationActivity instance, you can expand it and see its variables.
Hope that helps!
It's not a beautiful way, but if you create a method like this:
private fun debug() {
println()
}
and add a breakpoint on the println() it'll capture the activity.
(Don't use TODO as it'll crash the app with a NotImplementedError once called.)
I have this method now in my code all the time to call it whenever I need it.
I know, that question is old, but I just stumbled over it and needed a way.

How to make a small change to Android source code, and incorporate into your own project

I want to make a small change to the Android standard TimePicker class. Specifically, I'm trying to change it so it works in 15 minute increments, rather than 1 minute increments.
This post helped me constrain the range of minute values to {0, 15, 30, 45}, as required in my app. But as I pointed out in a follow up comment, the minute spinner still shows previous minute as current value - 1, and the next minute as current value + 1, which creates a sloppy-feeling user interface.
I looked into the relevant Android source code, and it appears that the changes I would need to make are pretty simple. But when I tried copying the source code into my project I got about a zillion errors relating to the package declaration, where to find Widget, how to resolve R.id variables, etc.
So my question is:
What's the best way to make a small change to a given class from Android source code, and incorporate it into your own project?
In my case, I just need to make a few small changes to TimePicker and NumberPicker, but I'm not sure how to properly set this up in my project.
Thanks for any suggestions.
But when I tried copying the source code into my project I got about a zillion errors relating to the package declaration
Your source file's directory needs to match the package name. And since you cannot overwrite android.widget.TimePicker, you will either need to move that class to a new package or give it a new name.
where to find Widget
That implies that you copied TimePicker into one of your packages. That is fine, but then you need to add in the appropriate import statements for classes that TimePicker referred to from its original package. Or, you need to keep your (renamed) TimePicker in android.widget, adding this package to your project. This is rudimentary Java.
how to resolve R.id variables
If TimePicker relies upon resources that are not part of the Android SDK, you will need to copy those resources from the AOSP into your project as well.
What's the best way to make a small change to a given class from Android source code, and incorporate it into your own project?
IMHO, that cannot be answered readily in the abstract. Generally speaking, you do the sorts of things that I listed above.
You are best off subclassing the relevant classes and overriding the methods you would like to change.
In Java, you can do the following in a subclass:
The inherited fields can be used directly, just like any other
fields.
You can declare a field in the subclass with the same name as
the one in the superclass, thus hiding it (not recommended).
You can
declare new fields in the subclass that are not in the superclass.
The inherited methods can be used directly as they are.
You can write a new instance method in the subclass that has the same signature as the one in the superclass, thus overriding it.
You can write a new static method in the subclass that has the same signature as the one in the superclass, thus hiding it.
You can declare new methods in the subclass that are not in the superclass.
You can write a subclass constructor that invokes the constructor of the superclass, either implicitly or by using the keyword super.
More info on subclassing in Java

Using map created in res folder

This is probably realy noobish question but, i am unable to solve it. I dont know what i am doing wrong or what should i do, i checked some tuts but i wasnt able to solve it. So i created new folder in res called menu and created new file there called xyz.xml. Now i want to call it in activity with following R.menu.item ... But when i just write R. it doesnt show menu as option. I can call any map which are default here like layout etc, but maps which i created i cant call them. What should i do to solve this?
If the menu file you create is called xyz.xml, then in your code you should use it as:
R.menu.xyz
Also, are you referring to the correct R? There's one R class used for the Android framework resources (android.R) and then there's one specific R class for your projects resources. To ensure you're using the right one you can use the fully qualified namespace, e.g. yourprojectsnamespace.R.
See http://developer.android.com/guide/topics/ui/menus.html for more information about Android menus.

Categories

Resources