ResourceNotFoundException error when accessing image in Android Titanium module - titanium

I'm developing an Android Module for a Titanium app and I have to generate a Notification. Android SDK forces me to do a setSmallIcon() call to include a png asset as icon for the notification. I've put icon_notification.png asset in /platform/android/res/drawable folder of my module and (tryed to) got it in the code calling
TiRHelper.getResource("drawable.icon_notification")
but when I build module calling ant, the following error is raised:
[javac] Note: [KrollBindingGen] Running Kroll binding generator.
[javac] Note: [KrollBindingGen] No binding data found, creating new data file: org.appcelerator.titanium.bindings/connecthings.json
[javac] Note: [KrollBindingGen] Found binding for proxy Beacon
[javac] Note: [KrollBindingGen] Found binding for module Connect
[javac] Note: [KrollBindingGen] Generating JSON: file:/Users/***/Development/***/modules/android/***/android/build/generated/json/org/appcelerator/titanium/bindings/***.json
[javac] warning: The following options were not recognized by any processor: '[kroll.checkTiContext]'
[javac] /Users/***/Development/***/modules/android/***/android/src/***/***/***/***/ConnectModule.java:76: error: unreported exception ResourceNotFoundException; must be caught or declared to be thrown
[javac] .setSmallIcon(TiRHelper.getResource("drawable.icon_notification"))
[javac] ^
[javac] Note: /Users/***/Development/***/modules/android/***/android/src/***/***/ti/***/BeaconProxy.java uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] 1 error
seems that raising a ResourceNotFoundException exception, builder doesn't find the assset
Have I placed the file in the wrong place?

The platform folder also has to sub-folder of android folder.The full directory is "android/platform/android/res/drawable/". You can also check if the resources are created in the build folder.
Documentation Link

Error posted is trowed during build step of the module.
In this step I think that resources are not already put in place, so, wrapping the TiRHelper method in a try...catch statement as written in the wiki suggested by #Saeed Sharman resolve the problem.
So, the working version is simply:
try {
TiRHelper.getResource("drawable.icon_notification");
catch (ResourceNotFoundException e) {
...
}

Related

Pytorch runtime not included when project is built as a jar

We have our ONNX model, and we're trying to use it in our app. Running the project from the IDE works just fine, but running the jar file produces this error. We debugged this issue and found that the supportedEngines in IDE runtime includes ONNXRuntime and PyTorch, but the JAR file includes ONNXRuntime only. The issue happens when we reach StackBatchifier.batchify(), on String inputName = ((NDArray)inputs[0].get(i)).getName();
We have the following dependencies in our gradle file:
api("org.apache.logging.log4j:log4j-slf4j-impl:2.18.0") api("ai.djl:model-zoo:0.21.0-SNAPSHOT") api("ai.djl.huggingface:tokenizers:0.21.0-SNAPSHOT") api("ai.djl.pytorch:pytorch-model-zoo:0.21.0-SNAPSHOT") api("ai.djl.onnxruntime:onnxruntime-engine:0.19.0") api("org.jetbrains.kotlin:kotlin-stdlib:1.7.20")
Do we need to put any jar configurations for it to work?
Error Message
Exception in thread "main" ai.djl.translate.TranslateException: java.lang.UnsupportedOperationException: This NDArray implementation does not currently support this operation
at ai.djl.inference.Predictor.batchPredict(Predictor.java:189)
at ai.djl.inference.Predictor.predict(Predictor.java:126)
at ProfanityPredictionModel.predict(ProfanityPredictionModel.kt:30)
at TestModel.main(TestModel.kt:18)
Caused by: java.lang.UnsupportedOperationException: This NDArray implementation does not currently support this operation
at ai.djl.ndarray.NDArrayAdapter.getAlternativeArray(NDArrayAdapter.java:1225)
at ai.djl.ndarray.NDArrayAdapter.getNDArrayInternal(NDArrayAdapter.java:1173)
at ai.djl.ndarray.NDArrays.stack(NDArrays.java:1825)
at ai.djl.ndarray.NDArrays.stack(NDArrays.java:1785)
at ai.djl.translate.StackBatchifier.batchify(StackBatchifier.java:52)
at ai.djl.inference.Predictor.processInputs(Predictor.java:217)
at ai.djl.inference.Predictor.batchPredict(Predictor.java:177)
... 3 more

module can't find package com.google.gson.stream

a project i'm working with has a dependency on kotlin.jvm.internal.Intrinsics. so i added kotlin-gradle-plugin-1.5.0.jar. now i'm getting an error that it can't find gson.streams. any idea what this is all about?
Error occurred during initialization of boot layer
java.lang.module.FindException: Error reading module: E:\jars\kotlin-gradle-plugin-1.5.0.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Package com.google.gson.stream not found in module
i already have gson-2.8,6.jar in my classpath.
The Jar kotlin-gradle-plugin version 1.5.0 seems to have runtime dependency with com.google.code.gson ยป gson
you can see that in the Runtime Dependencies section from here
In order to rectify this, you have to add it as a plugin
like below
plugins {
id 'org.jetbrains.kotlin.<...>' version '1.5.0'
}
This is the recommended way from here

Exception occurred applying plugin request[id:'org.jetbrains.kotlin.jvm', version:'1.3.40-eap-40']

An exception occurred applying plugin request [id: 'org.jetbrains.kotlin.jvm', version: '1.3.40-eap-40']
> Failed to apply plugin [id 'org.jetbrains.kotlin.jvm']
> Cannot add extension with name 'kotlin', as there is an extension already registered with that name.
This error occurs in my build.gradle.kts file
Did you happen to see this error in a Kotlin Cocoapods project built from the samples provided on Kotlin/Native GitHub?
This error occurs because in the build.gradle.kts, there are conflicting plugin imports. Like seen below:
You can't have kotlin 'Jim' plugin and 'multi-platform plugin' together, so remove the kotlin("jvm") version "1.3.31" and build your gradle project.
Also, when you remove this will be accompanied by few more errors in the dependencies section. So comment out everything from dependencies and the two compile tasks below as well and build it. It should work!

Adding sub module to project causing gradle build failures in Android studio 3.0 with gradle version 4.1

I added sub module library vertical-stepper-form version 0.9.8, while I set dependency of this library on my app module. I was able to do it successfully.
I am using Android Studio 3.0 with gradle version 4.1, few of the classes in project are in kotlin and others in java
When I started gradle sync it gave me this error. The gradle is not building and showing below issues :
/*********************************/
Information:Gradle tasks [:vertical-stepper-form:generateDebugSources,
:vertical-stepper-form:generateDebugAndroidTestSources,
:vertical-stepper-form:mockableAndroidJar,
:app:generateInstallDebugSources,
:app:generateInstallDebugAndroidTestSources, :app:mockableAndroidJar]
D:\Devavrata\project/package/src/main/res/abc.xml Error:error:
attribute 'com.spireon.install:src' not found.
D:\Devavrata\AbcProject\abc-Android\app\build\intermediates\incremental\mergeInstallDebugResources\stripped.dir\layout\activity_main.xml
Error:attribute 'com.spireon.install:src' not found. Error:failed
linking file resources. Error:java.util.concurrent.ExecutionException:
java.util.concurrent.ExecutionException:
com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for
details Error:java.util.concurrent.ExecutionException:
com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for
details Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error:
check logs for details Error:Execution failed for task
':app:processInstallDebugResources'.
Failed to execute aapt Information:BUILD FAILED in 24s Information:7 errors Information:0 warnings Information:See complete output in
console
/********************************/
What I have already tried :
I tried with changing import lines in xml also changing the android:src and srcCompat properties. Along with build/project cleaning and invalidating the cache.
Changing this line in gradle.properties
android.enableAapt2=false
Let me know if anyone has faced this issue

MainActivity error while importing package: `react-native-google-vr-panorama`

I am getting an error when I import a package into my JS file:
import GoogleVRPanorama, { PanoramaView } from 'react-native-google-vr-panorama'
Error:
This error I get with all the VR 360 components I try to import.
Edit-1:
I did follow the installation steps but I didn't rebuild the app
MainApplication.java: MainApplication
So when I rebuild the app, getting the following error:
C:\Users\cherry\Test03\node_modules\react-native-google-vr-panorama\android\src\main\java\com\xebia\googlevrpanorama\RNGoogleVRPanoramaPackage.java:14:
error: method does not override or implement a method from a supertype
#Override
^ Note: C:\Users\cherry\Test03\node_modules\react-native-google-vr-panorama\android\src\main\java\com\xebia\googlevrpanorama\RNGoogleVRPanoramaView.java
uses unchecked or unsafe operations. Note: Recompile with
-Xlint:unchecked for details. 1 error :react-native-google-vr-panorama:compileReleaseJavaWithJavac FAILED
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':react-native-google-vr-panorama:compileReleaseJavaWithJavac'.
Compilation failed; see the compiler error output for details.
Sounds like you either
1. Did not finish the install steps, i.e. adding lines to MainApplication etc., see https://github.com/XebiaStudio/react-native-google-vr-panorama/blob/master/README.md#installation for details
or
2. Did not rebuild the app with react-native run-android.