I'm new to Android Studio and is trying to create a app for recording invoice relative information.
Currently I'm trying to use "EInvoice" API shared in Github but stuck in object declaration.
Refer to author's advice, I succeeded to add dependency to Android Studio, but always failed in object declaration:
val invSdk = EInvoice("API_KEY")
It seems that Android Studio can't recognize "val" and "EInvoice".
Then I try to declare it with common method:
private EInvoice Invoice=new EInvoice();
Unfortunately Android Studio always failed to compile with error "cannot resolve symbol 'EInvoice' even if I try to add below import code:
import com.github.kevinchung0921:einvoice_sdk:v1.3
Can you please be kind to suggest correct method to declare the external-imported-API object and use functions such as:
val detail = invSdk.getCarrierDetail(header, USER_BARCODE, USER_PASS)
Thanks a lot for your reading and further help.
cannot resolve Error
Related
In my android project, I have a kotlin object AssetValidator which does some validation over the asset files.
object AssetValidator {
fun validate(assetsDir: File) {
...
}
...
}
Until now, I was calling this function at the startup of my application. But now, I am thinking of calling it from build script instead. But, I am unable to import this package into my gradle file. Android studio is showing Unresolved reference in the import statement. Someone please tell me how to do this.
I'm trying to use this package in my react native project.
So far I've followed all the steps in their installation guide and I made it work on iOS.
However, on Android, every time I try to import Batch or BatchPush in my code like this:
import { BatchPush, Batch } from "#bam.tech/react-native-batch";
I get an error on Android only:
null is not an object (evaluating 'RNBatch.NOTIFICATION_TYPES')
So when I go to node_modules/#bam.tech/react-native-batch/dist/BatchPush.js I see this
const RNBatch = react_native_1.NativeModules.RNBatch;
exports.AndroidNotificationTypes = RNBatch.NOTIFICATION_TYPES;
So somehow the native module is not being imported correctly. Do I need to follow extra steps for this to work?
#bam.tech/react-native-batch is being used with version 5.2.1
npm version 6.14.7
react-native version 0.60.5
Update: it turns out that the package was not linked correctly and that I had to manually add the package in MainApplication.java (I don't know why react-native link did not add this automatically)
Add the import:
import tech.bam.RNBatchPush.RNBatchPackage;
And then add
new RNBatchPackage(), in the getPackages() method.
While upgrading a Xamarin app that leverages Splat's bitmap functionality we are getting errors around the use of the methods mentioned in the title:
'IBitmap' does not contain a definition for 'ToNative' and no accessible extension method 'ToNative' accepting a first argument of type 'IBitmap' could be found (are you missing a using directive or an assembly reference?)
In an effort to troubleshoot the problem we have created a new sample Android-only Xamarin app and referenced Splat and Splat.Drawing via NuGet. We then added calls to these methods and have reproduced the error:
public void Bar(IBitmap source)
{
Bitmap native = source.ToNative();
IBitmap bitmap = native.FromNative();
}
It seems as though the Andriod app may not be referencing the proper build of the Splat libraries. When I monitor paths containing %USERPROFILE%\.nuget\packages\splat in ProcMon I don't see any attempt by Visual Studio to open/read anything other than files in the .\netstandard2.0 directories during the build process.
When I open the netstandard2.0 libraries in DotPeek I can see that the class BitmapMixins is not included, but it is included in the monoandroid90 builds.
How do I get the reference to Splat in the Android project to pull in the proper build of Splat?
Example project can be found here: https://github.com/jctlp/SplatBitmap
The error caused by that you did not have the extension methods to assist with dealing with Bitmaps of ToNative and FromNative.
Please do not add reference by installing the Splat from NuGet directly. Add reference to the whole project of Splat would be okay.
Download the whole Splat project from the link below.
https://github.com/reactiveui/splat.git
I create a Xamarin.forms app named App1. And create a class Class2.cs in App1.Android. When I add reference to Splat from the project. It works well with ToNative and FromNative extension method.
Please note: Do not use the Bitmap, use Android.Graphics.Drawables.Drawable or var instead.
public void Bar(IBitmap source)
{
Android.Graphics.Drawables.Drawable native = source.ToNative();//var
IBitmap bitmap = native.FromNative();
}
I'm trying to integrate a chatbot on my Pepper robot using Kotlin on Android Studio. I just follow this tutorial step by step.
Testing your Dialogflow agent in standalone
But when I execute this in Kotlin REPL(in module data):
import com.softbankrobotics.chatwithdialogflow.data.DialogflowDataSource
import java.io.File
val stream = File("C:/Users/yuhliu/ChatWithDialogflow/app/src/main/res/raw/credentials.json").inputStream()
val dataSource = DialogflowDataSource(stream)
dataSource.detectIntentTexts("sois intelligent", "my-test-session", "fr")
I got this error
error: unresolved reference: softbankrobotics
import com.softbankrobotics.chatwithdialogflow.data.DialogflowDataSource
My project directory is something like this:
I'm new to Kotlin. Do you have any idea what's going wrong here?
On first opening the Kotlin REPL, you might get:
You’re running the REPL with outdated classes: Build module 'data' and restart
... clicking on that will reload the REPL and the import should work.
(I tried the same as you and had the same error, and the import worked after reload)
I have created a Xamarin Android project that is using F# and ReactiveUI.
When loading my Dashboard, I encounter a runtime exception (of type MissingMethodException) on the inherit line of this code snippet:
type DashboardViewModel(?host: IScreen) =
inherit ReactiveViewModel()
let host = LocateIfNone host
member __.Title with get() = "Dashboard"
interface IRoutableViewModel with
member __.HostScreen = host
member __.UrlPathSegment = "Dashboard"
The error message reads
Method 'Microsoft.FSharp.Quotations.FSharpExpr.Deserialize40' not found.
The ReactiveViewModel type is a thin wrapper around ReactiveObject:
type ReactiveViewModel() as this =
inherit ReactiveObject()
let mutable message = noMessage
let uiContext = SynchronizationContext.Current
member __.SyncContext with get() = uiContext
member this.Message
with get() = message
and set(value) =
this.RaiseAndSetIfChanged(&message, value, "Message") |> ignore
if message <> noMessage then this.RaiseAndSetIfChanged(&message, noMessage, "Message") |> ignore
member val MessageSent =
this.WhenAnyValue(toLinq <# fun vm -> vm.Message #>).ObserveOn(RxApp.MainThreadScheduler).Where(fun m -> m <> noMessage) with get
The project is open source: at the moment, it contains very little content. It can be found at https://github.com/SpiegelSoft/Astrid.
I have submitted a bug on the Xamarin bug tracker: https://bugzilla.xamarin.com/show_bug.cgi?id=51000
Are there any known fixes I can implement myself, so that I can close the bug of my own accord?
UPDATE 1
I've been investigating this issue this weekend.
The FSharp.Core version that is loaded is stuck on the obsolete version 2.3.98.1. This corresponds to the FSharp.Core.dll file in
C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework\MonoAndroid\v1.0
I have tried to remove this version and load the NuGet package FSharp.Core; however, when I build the Android project, the path always reverts to the obsolete file in the Reference Assemblies path.
Is there a way to override this behaviour?
UPDATE 2
Replacing the FSharp.Core.dll file in the Reference Assemblies path fixes the issue, but this is a very unsatisfactory sticking plaster, which I can't ask my users to apply. Ideally, I would like to find a way to prevent the .Droid project from loading FSharp.Core from the GAC rather than the NuGet package.
I just ran into a very similar issue the other day. My android app had a reference to a Profile7 F# PCL library, which made use of List.unfold, which I believe was introduced in F# 4. When I used the library in my app, I saw a MissingMethodException similar to what you are seeing. The version of FSharp.Core that Xamarin references by default when creating a new Android app didn't have this newer method. I got around it by editing the .fsproj file for the app to remove the original reference to FSharp.Core, and replaced it with a reference to the newer version ( I copy/pasted the tag from the PCL .fsproj file). It looks something like this:
<Reference Include="FSharp.Core">
<Name>FSharp.Core</Name>
<Private>True</Private>
<AssemblyName>FSharp.Core.dll</AssemblyName>
<HintPath>$(MSBuildExtensionsPath32)\..\Reference Assemblies\Microsoft\FSharp\.NETCore\$(TargetFSharpCoreVersion)\FSharp.Core.dll</HintPath>
</Reference>
I was suprised to find that this seems to have fixed the problem for me. I'm not sure if I'll run into other issues down the line, but it may be worth trying this if you havent already.
UPDATE If this doesn't work immediately, follow the sequence of steps in Rob Lyndon's answer.
It appears that this has been fixed by the GitHub commit
https://github.com/xamarin/xamarin-android/commit/df41af046000556ed82f638e8041b7f718966a92
which removes FSharp.Core from the list of framework assemblies, and allows the project to be built without the NuGet FSharp.Core assembly being replaced.
Until this fix is released into the SDK, there is a workaround. The answer submitted by user3850711 works, but you need to apply the changes in a specific sequence, because otherwise the reference will be overwritten during the build.
Delete the existing reference to FSharp.Core.
Install or reinstall the FSharp.Core NuGet package.
Unload the project and add <HintPath>packages\FSharp.Core.4.0.0.1\lib\portable-net45+monoandroid10+monotouch10+xamarinios10\FSharp.Core.dll</HintPath> to the FSharp.Core project reference.