I am now writing a test case under "app/src/androidTest", which need to involve OpenCV lib.
I've tried :
1. Import OpenCV 3.2.0 as a module.
2. Import OpenCV lib as suggested , Here is the link.
But anyway the import seems to fail,
```
static {
if (!OpenCVLoader.initDebug()){
Log.w(TAG, "static initializer: Load opencv failed !!!");
} else {
Log.i(TAG, "static initializer: Load opencv succeed .");
}
}
```
Any comment would by helpful.
I had the same problem.
To load OpenCV for android test (on Windows)
Download the OpenCV version for Windows and unzip it.
Copy the following file inside your android project (I putted it inside /app/src/main/jniLibs/win/) :
"yourunzipath" + opencv\build\java\x64\opencv_java331.dll
Then, inside your Android test folder, create the following class :
public class OpenCVTestInitializer {
#Before
public void initOpenCV() {
String projectPath = System.getProperty("user.dir");
String opencvpath = projectPath + "/app/src/main/jniLibs/win/";
System.load(opencvpath + Core.NATIVE_LIBRARY_NAME + ".dll");
}
}
To finish, each test class you want to use with OpenCV must extend the previous class.
Related
I've been trying to write a library in kotlin and once the library build is generated as aar file when opening it in Android Studio it is not showing me how my class exactly looks and how the methods are implemented in that.
// IntelliJ API Decompiler stub source generated from a class file
// Implementation of methods is not available
package com.mypackage.dexter
public final class Test private constructor() {
public final fun testMethod(): kotlin.Unit { /* compiled code */ }
}
I've tried Java decompiler plugin in android studio, Kotlin Byte code (This also doesn't show it in the same format that we get if the same code is written in Java). The ultimate thing that I wanted to achieve by looking at the code is that I want to use debugger in the library and evaluate things while running my application where this library is integrated.
I am written a very simple plugin which get all the messages from android device and pack it to response. When I am using npm install ionic-capacitor-sms-access and trying to access messages it just call web method but not the android method. So its not working can someone help me here and tell me what went wrong?
Here is my plugin https://www.npmjs.com/package/ionic-capacitor-sms-access
(Note: only the android folder)
It works, there are two ways to achieve this.
Method 1 (from the official tutorial)
What you need to do is just to keep following that tutorial to the section of 'Custom JavaScript', where shows demonstrates how to use your plugin within your ionic/typescripts codes.
such as:
import { Plugins } from '#capacitor/core';
const { SuperGreatPlugin } = Plugins;
export class CustomSuperPlugin {
constructor() {
}
customAwesomeness() {
SuperGreatPlugin.awesome();
}
}
Notes:
the name of the plugin class, i.e. 'SuperGreatPlugin' must be same with your java class for the plugin.
Method 2 (javascript way)
You can also import your plugin from the npm package you published. But be aware of the first line of the generated definitions.ts, declare module "#capacitor/core". This means you have to find your plugin from the specific module, here it is 'Plugins' as other plugins usage.
The following is the method 2:
import { SuperGreatPlugin } from 'YOUR_PLUGIN_NPM_PACKAGE';
async pluginEcho() {
await Plugins.SuperGreatPlugin.echo({value: 'bla bla bla'})
}
call the function pluginEcho() in your ionic page.
When I started I head really trouble distinguishing the web and native plugin but finally I understand that they are completely separated.
I recommend to rename the exported web plugin object in your web.ts file and add Web in the name. For me this was also necessary in order to not have compile errors.
TS2308: Module './definitions' has already exported a member named 'YourPlugin'. Consider explicitly re-exporting to resolve the ambiguity.
If you want to use your web plugin you import and use it like:
import { YourWebPlugin } from 'YOUR_PLUGIN_NPM_PACKAGE';
YourWebPlugin.callSomething();
If you want to use the native plugin you import and use it like:
import { Plugins } from '#capacitor/core';
const { YourPlugin } = Plugins;
YourPlugin.callSomething();
Don't forget to expose your native plugin to your android app project where you use your custom plugin
https://capacitor.ionicframework.com/docs/plugins/android#export-to-capacitor
I wrote a library which has been uploaded to a private server. When I include the library as a dependency in my app project, and view the source code from one of the library classes, the source code isn't actually decompiled. It only shows the class name and methods. For example:
package com.example.library.ui
public final class RoundedDrawable public constructor() : android.graphics.drawable.Drawable {
public final var backgroundColor: kotlin.Int /* compiled code */
// ... other similar fields
public open fun draw(canvas: android.graphics.Canvas): kotlin.Unit { /* compiled code */ }
// ... other similar functions
}
As you can see, it only displays /* compiled code */ comments, and not the full source code. There is an option presented to "Decompile to Java"; which works, but I would much rather see the Kotlin source. Is this possible?
I found similar question that explains how to show the original Java code, but nothing for Kotlin.
Are you using Gradle?
You need to download sources for the library:
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
If attached sources/documentation are found, IntelliJ will use these when viewing .class files.
With Maven, you can do this from the tool window with Right click -> Download Sources
Other than that, decompiling a .class file to Kotlin is not possible with good results. Despector has a very rough Kotlin "decompiler".
When Releasing the library with maven publish, you can specify the source jar.
In this example, if your library is in Kotlin and Java, to add both source codes.
task androidSourcesJar(type: Jar) {
archiveClassifier = 'sources'
from (android.sourceSets.main.java.sourceFiles, android.sourceSets.main.kotlin.sourceFiles)
}
my question is simple enough. I am using Gluon's plugin for Eclipse and developing an application in JavaFX to run on Android. However, I need to use an Android library (.aar format) and after a while of trying, cannot. Does anybody know how I can do this? I have already tried just using the classes.jar inside the .aar, while this has sort of worked, there are a few resources and things I believe the library is missing that is essential to its function. Thank you.
Edit: The library I'm trying to use is CloudRail, the download is here (Direct download)
Currently, using the classes from the extracted classes.jar it is somewhat functional but when the activity from their library is launched (com.cloudrail.si.servicecode.commands.awaitCodeRedirect.AuthenticationActivity) it is displayed however it is blank and there is nothing in it. I am currently under the assumption that this is incorrect and that the missing resources/files are the cause of this.
I've managed to extract the classes.jar from the aar file and add it to a Gluon project as dependency.
Next, I added the activity to the AndroidManifest.xml file, after the main FXActivity:
<activity android:name="com.cloudrail.si.servicecode.commands.awaitCodeRedirect.AuthenticationActivity" />
Then I created a class in the Android package, provided the required credentials to access to Google Drive.
public AndroidTestAar() {
GoogleDrive cs = new GoogleDrive(FXActivity.getInstance(), "****","****");
new Thread() {
#Override
public void run() {
List<CloudMetaData> metas = cs.getChildren("/");
Log.i("info", "Folder has " + metas.size() + " children");
for (CloudMetaData meta : metas) {
Log.i("info", "Child: " + meta.getName());
}
}
}.start();
}
This class is called from the View:
public BasicView(String name) {
...
button.setOnAction(e -> {
try {
Class c = Class.forName("com.testaar.AndroidTestAar");
c.newInstance();
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) {}
});
}
I could deploy the apk and run it.
The activity runs outside the JavaFX app, in an Android WebView.
First it asked me to sign in with my user/password, then it asked me about allowing offline access, and finally on the console it successfully listed all my files.
I'm currently trying to implement a browser with pipelining feature in it. The problem is in order to code the HTTP pipeline, i need the support of a library. I tried to import it to my workspace by using Project - > properties -> Java build path ->addJar. And I was able to add it successfully. But now my problem is, even though it is added to my workspace it doesnt let me run this code. It gives me errors as if I have not imported the library:
package com.test.download;
import java.util.Collections;
import org.factor45.*;
public class Example {
// Execute the request
HttpRequestFuture<String> future = client.execute("hotpotato.factor45.org", 80, request,
new BodyAsStringProcessor());
future.addListener(new HttpRequestFutureListener<String>() {
#Override
public void operationComplete(HttpRequestFuture<String> future) throws Exception {
System.out.println(future);
if (future.isSuccessfulResponse()) {
System.out.println(future.getProcessedResult());
}
client.terminate();
}
});
}
This is available in the same website which provided me the library for the above code. "Here" is the website for your reference. Also you can find the JAR file inside this website.
Please help me to figure out the problem. If you solve this you are a life saver! Thanks in advance!
Try this:
Properties >> Java Build Path >> Libraries >> Add External JARs... Then select the library