openRawResource() throws always a NotFoundException - java

I want to load a keystore in my Android application. I have copied the key (truststore.bks) into the folder res/raw. The SDK from Android generate the R.java with a entry for trustsotre. In the App in try to use:
Resources.getSystem().openRawResource(R.raw.truststore);
But I get always a exception:
android.content.res.Resources$NotFoundException: Resource ID #0x7f040000
I look into the apk File und saw the truststore.bks file is in the folderres/raw/.
What is my misstake?

The problem is that you are using the system level resources with the call to Resources.getSystem. Specifically the documentation states that this does not provide access to application resources. You need to call getResources on a Context object in your application - all your activities are a Context object since they inherit from Context.

does your R.java contains corresponding entry for it.....
try deleting R.java and building again....
though I am not completely aware of ur problem....
And this isnt a proper solution as well....

Related

Could not load wrapper properties in android studio

please help me, when i create a new project in android studio there is an error
Could not load wrapper properties from Could not load wrapper properties from 'C:\Users\baren\AndroidStudioProjects\ToyaGarage\gradle\wrapper\gradle-wrapper.properties'.
1
enter image description here
In my case, I have a blank space at the end of "distributionUrl" row
I Searched for your problem and i found this,maybe this solution can help you https://stackoverflow.com/a/64439711/15805169
Delete the wrapper properties file in your app that is having the problem and copy the wrapper property file from your working apps to the same place where you deleted that file.
this is like the basic path to get to that file
C:\Users\TT Virtual\AndroidStudioProjects\KotlinFirebaseAuth\gradle\wrapper
remember this here is my path to that file

Tibco-java Custom function error

I created one custom java function in TIBCO designer. I loaded class file from my desktop. It was working fine. But, now I did some changes in that function and then created and loaded class file, but this time class file location is different(from clearcase). This cause an error where I used this function earlier and the error is :
"No function in namespace:java://xyz"(xyz is class file name which I not changed).
Please help me to resolve this error without changing previous code.
Please check your package hierarchy in the Java file, if there is no change, looks like your Designer did not pick up the latest .class file from the new location.
1. Retry by completely closing your designer instances in your machine.
2. Reload by browsing the new .class file and save your project.
3. Check by validating this particular process only.
Hope you are out of this issue already.

IntelliJ- Android Schema URI not registered

I'm programming an Android app that uses Gradle. However, in the .xml files and Android Manifest, the URL for Android Schemas are "Not registered".
This problem has been a nuisance and have spent hours trying to get it fixed. I have looked through:
1: Intellij Android project schema URI not registered?
2: If I change an external library: AndroidManifest, cannot parse file
I cannot just create a new project because this application is not only developed only by me but a small team. The code is also on GitHub as well. Secondly, even if I try to create a new project, the Schemas are still not registered.
Eclipse is not an option because they do not officially support Gradle integration. (unless you have found a Gradle plugin that is SPECIFIC to android applications). I also have installed Android Studio, but I still get the same errors, if not more errors.
Edit: I am currently using Intelli-J community edition
I had almost the same problem, 2 different flavors and that URI error in the xml files inside one of the flavors. I've solved by placing a copy of the Android Manifest inside the folder of the flavor that was giving me trouble, build project and error gone
For me the only thing worked was add mock Activity with right click on the Flavour package, choose "new->activity>empty activity", choose the fit source set and package name in the dialog, and after the Activity created the problem solved. I deleted the mock activity later and it not brought any problem.
Combining both Hernan Romero's answer and yshahak's answer, create an Android Manifest file inside each flavor's root folder.
For example, if you have a flavor called "pro", right-click on the pro folder then choose new * other * Android Manifest File.
(I did it the "long way": for each flavor, I set that flavor to be the active variant and then created a dummy empty activity with no layout file. I then removed the activity and unneeded xmlns: from the manifest and then deleted the activity and now-empty java folder in the flavor's folder. Rinse-repeat for the other flavor(s). That left me with an almost empty manifest, for each flavor, as follows:)
My "dummy" AndroidManifest.xml file in each flavor contains only:
<manifest>
<application/>
</manifest>

Using R.Java in Titanium module

I need to start an activity in my titanium module.Then I have to setContent of my Layout in my pure java code, But I cannot locate the layout file in Titanium module.
I used below code but i get error that file not found.
int id = TiRHelper.getApplicationResource("layout.activity_main");
If i put my layout files inside "platform/android/res" i get error,any idea to help me?
invalid resource directory name:
[ERROR] Error generating R.java from manifest
Regards
Might have nothing to do with it but I once ran across this problem and solved by putting the application id in the com.company.app format
If your XML's contain errors your generated file might not build try erasing most of their content and making sure id's and file names are not duplicated and no capitals and spaces are used. If it works you can start adding stuff.
(or)
You're importing invalid R class I Think,
import yourpackage.R class
for example
com.example.R
what actully happends that u import android.R class not yourpackages.R

Get Android application lib directory

I need to specify the location of some native libraries in my Android application. I was accomplishing this with a hard-coded string:
public static final String DLL_DIR_STR = "/data/data/my.application.package/lib";
but wanted to get the path from Android instead. Following posts like this, I used getDir() to find the lib directory, changing
superCollider = new SCAudio(DLL_DIR_STR);
to
superCollider = new SCAudio(container.$context().getDir("lib", 0).getAbsolutePath());
Oddly, the initial libraries seem to load correctly
Trying to load lib /data/data/my.application.package/lib/libsndfile.so 0x42718d80
Added shared lib /data/data/my.application.package/lib/libsndfile.so 0x42718d80
No JNI_OnLoad found in /data/data/my.application.package/lib/libsndfile.so 0x42718d80, skipping init
Trying to load lib /data/data/my.application.package/lib/libscsynth.so 0x42718d80
Added shared lib /data/data/my.application.package/lib/libscsynth.so 0x42718d80
But when libscsynth tries to load some additional code, it's using the wrong path:
OK, listing opendir(/data/data/my.application.package/app_lib)
Any ideas where the "app_" comes from? I thought I must be using getDir() wrong, but the initial files load fine. Could it be something in the native code? Thanks for your help.
I found the answer, quite by accident, in this post. ApplicationInfo.dataDir holds the location of the data directory, and "lib" is easily navigated to from there:
superCollider = new SCAudio(container.$context().getApplicationInfo().dataDir + "/lib");
Alternatively, nativeLibraryDir takes you directly to the lib directory, but requires API level 9.
Thanks for your help!
getDir will always prepend app_ to the directory name so it is very odd that it is working the first time. I would either just expect the app_ to be there or try using getFilesDir, at least you always know what it will return. Does SuperCollider have a restriction on what the directory name is?
I found another SuperCollider Project that seems to be doing the same thing you did initially with the comment "// TODO: not very extensible,".. I found that funny :)

Categories

Resources