I created a small Cordova Plugin added it to my test app.
In plugin.xml I set min cordova version to 3.4.0:
<engines>
<engine name="cordova" version=">=3.4.0"/>
</engines>
In my plugin JAVA class I import the PluginResult package:
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
And I create a "PluginResult" object:
PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
When I build the app I get the error that not found symbol:
error: cannot find symbol PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
error: package PluginResult does not exist
Can anyone help me?
It will be hard to locate the error when you don't post the full source code.
Anyway, the plugin structure requires so many files that your best approach to create a plugin is to use a sample plugin as base.
Check out the cordova-plugin-hello sample, you can download it and start editing everything accordingly to your needs.
After installing the sample plugin, test it by adding this code to your app:
var success = function(message) {
alert(message);
}
var failure = function() {
alert("Error calling Hello Plugin");
}
hello.greet("World", success, failure);
Then, everytime you make a change to the plugin, uninstall and reinstall it into your app to ensure your changes have worked.
I found my mistake ... It's missing an import line:
import org.apache.cordova.PluginResult;
Related
I am trying to use HdmiCecMessage class in my android app, so I installed this dependency in my gradlef file:
dependencies {
implementation 'androidx.hardware:hardware-hdmi:1.0.0'
}
but when I try to import:
import android.hardware.hdmi.HdmiCecMessage;
I get an error I get an error "cannot find symbol HdmiCecMessage".
I saw in google open source that it exsists:
https://android.googlesource.com/platform/frameworks/base/+/9302a73/core/java/android/hardware/hdmi/
any ideas?
thanks
I'm practicing Java JSON programming using JSON-Simple on this site which says:
All the jars available in maven repo is supported.
UPDATE:
So I've now added the external maven library to project.
But I still can't get it work.
I tried
import com.googlecode.json-simple.JSONObject;
but got:
error: ';' expected
import com.googlecode.json-simple.JSONObject;
^
Then I tried
import com.googlecode.json_simple.JSONObject;
but got:
error: package com.googlecode.json_simple.parser does not exist
import com.googlecode.json_simple.parser.JSONParser;
^
How to make it works?
I'm pretty sure you forgot to add external maven library to project. Check this out:
...and enter: org.apache.clerezza.ext:org.json.simple:0.4
I downloaded breeze jar files from the link, then I went to Project Structure->Modules->Dependencies and added downloaded jar files.
I made a new project->Scala class and wrote the following code:
import breeze.linalg_
object Scrpting extends App{
println("hello")
}
I get the following error.
Error:(4, 8) not found: object breeze
import breeze.linalg_
I tried to search online, but was unable to find any clear useful resource on how to use breeze with IntelliJ. Can someone please help me with this? I am using Mac OS.
In your build.sbt file, make sure you add all the dependencies listed under "libraryDependencies" at
https://github.com/scalanlp/breeze
I need to create an Android app that uses the OpenCV library, and I would like to do this using the command line (linux) only. Before I start I wanted to get a feel for creating projects that use libraries, but I am having trouble referencing a sample library I created. I can build the default Android HelloWorld project and run it on my device witout a problem, I just need help with the library.
I created a root directory and folders for the app and library:
mkdir TestProject mkdir TestProject/TestApp mkdir TestProject/TestLib
Then I created the project and library:
android create project --target 1 --gradle --gradle-version 2.4 --name TestApp --path ~/Projects/TestProject/TestApp/ --activity MyActivity --package com.example.testapp
android create lib-project --target 1 --gradle --gradle-version 2.4 --name TestLib --path ~/Projects/TestProject/TestLib --package com.example.testlib
I added 'settings.gradle' to the root directory, and in 'settings.gradle' I have include 'TestApp', 'TestLib' I wasn't sure if I needed a build.gradle file here or not. I also added the 'TestLib' dependency to the 'TestApp/build.gradle' file:
dependencies {
compile project(':TestLib')
}
If I try using ./TestApp/gradlew assembleDebug and adb install /TestApp/build/output/apk/TestApp-debug.apk my project builds and I can run the app on my phone (although there are two activities, one of which doesn't work), but I don't think this setup is correct.
If I try to import the library in MyActivity.java for the TestApp...
package com.example.testapp;
import android.app.Activity;
import android.os.Bundle;
import com.example.TestLib;
public class MyActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
I get this error:
/TestProject/TestApp/src/main/java/com/example/testapp/
MyActivity.java:5: error: cannot find symbol
import com.example.TestLib;
^
symbol: class TestLib
location: package com.example
1 error
:TestApp:compileDebugJava FAILED
I'm guessing I didn't set up something that is required to recognize the library. Or maybe I didn't create the library correctly. I tried following the Google Android tutorials for adding a library from command line, but it looks like they use Ant instead of Gradle. I might try doing that instead, but I heard Gradle was supposed to make my life easier somehow..
Edit:
I have tried using Ant but I can't even get the project to build. I receive the following error after running ant debug install in my project directory:
BUILD FAILED
/home/steven/Libraries/android-sdk-linux/tools/ant/build.xml:649: The
following error occurred while executing this line:
/home/steven/Libraries/android-sdk-linux/tools/ant/build.xml:694:
Execute failed: java.io.IOException: Cannot run program
"/home/steven/Projects/WorkPlz/${aapt}": error=2, No such file or
directory
I was finally able to create a library and use it in my Android project! The following links were helpful:
http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Dependencies-Android-Libraries-and-Multi-project-setup
https://docs.gradle.org/current/userguide/multi_project_builds.html
http://www.petrikainulainen.net/programming/gradle/getting-started-with-gradle-creating-a-multi-project-build/
This whole process made me understand why most people just use Ecipse or Adnroid Studio. But if anyone else wants to try this, I will include a link to my sample project. It should clarify how everything works.
Sample project: https://drive.google.com/folderview?id=0B2nWL2e8v6g-fnVuaEJHMWYyeGd5RXBIT0M5bjc5M3hPaHdnalJpNXVhVXRQVkVHZ2JtOEU&usp=sharing
Now I can finally get to work!
I'm currently learning Android and Java and I am having some issues with importing.
Actually I have downloaded tutorial videos for Android. In them the person declare this:
Task t = new Task(taskname);
in java.class file ...
So eclipse gives him the error and then a red line occurs below Task and then when he hover on the task this line comes up :
import Task (with his package name)
but in my eclipse when I hover on this line this library or import line is not coming up .Where is the problem? I think there is may be some file that I haven't downloaded.
I think no Task class in SDK...see in the example it might be the task name he gave.U try manually writing it! And check whether the error goes!
You need to add a new package under src say for example com.glen.tasks_manager.tasks and add a java class inside named Task.java, so that when you hover to the task code it will provide an import for the package name you just have created including the new java class name.