I just want use react-native-camera in my react-native project but has an error, I need help, I don't know what happened about this error. Looking forward to your answer, Thanks.
error info
android/app/build.gradle
There are two main possibilities:
Add below line in build.gradle under compile project(':react-native-camera')
compile (project(':react-native-camera')) {
exclude group: "com.android.support"
}
As Camera module is used same TAG name as default native camera will use it:
--> put code into react-native-camera --> src --> main --> java --> com.lwansbrough.RCTCamera --> RCTCameraModule
1) You need to add RCTCameraModule as a tag:
public class RCTCameraModule extends ReactContextBaseJavaModule
implements MediaRecorder.OnInfoListener, MediaRecorder.OnErrorListener, LifecycleEventListener {
private static final String TAG = "RCTCameraModule";
...
}
2) Add this method
#Override
public String getName() {
return "RCTCameraModule";
}
Hope this will help you :)
Related
I created an IntelliJ plugin using the template https://github.com/JetBrains/intellij-platform-plugin-template. The template comes with a test that runs on an XML file. I want to create a similar test for a Kotlin file. Here's the template test file plus my added test (test2):
package org.jetbrains.plugins.template
import com.intellij.ide.highlighter.XmlFileType
import com.intellij.psi.xml.XmlFile
import com.intellij.testFramework.TestDataPath
import com.intellij.testFramework.fixtures.BasePlatformTestCase
import com.intellij.util.PsiErrorElementUtil
#TestDataPath("\$CONTENT_ROOT/src/test/testData")
class MyPluginTest : BasePlatformTestCase() {
fun testXMLFile() {
val psiFile = myFixture.configureByText(XmlFileType.INSTANCE, "<foo>bar</foo>")
val xmlFile = assertInstanceOf(psiFile, XmlFile::class.java)
assertFalse(PsiErrorElementUtil.hasErrors(project, xmlFile.virtualFile))
assertNotNull(xmlFile.rootTag)
xmlFile.rootTag?.let {
assertEquals("foo", it.name)
assertEquals("bar", it.value.text)
}
}
override fun getTestDataPath() = "src/test/testData/rename"
fun testRename() {
myFixture.testRename("foo.xml", "foo_after.xml", "a2")
}
// Here's my test
fun test2() {
val fileText: String = """
package com.loganmay.test
data class MyClass(val myString: String)
""".trimIndent()
val psiFile = myFixture.configureByText("a.kt", fileText)
val xmlFile = assertInstanceOf(psiFile, XmlFile::class.java)
}
}
Without changing the build.gradle file, that test fails with:
Expected instance of: com.intellij.psi.xml.XmlFile actual: com.intellij.psi.impl.source.PsiPlainTextFileImpl
I want it to parse the text as a PsiFile that's also a KtFile. From various sources, I've been led to believe that the fixture is parsing it as a plain text file because the test project doesn't have access to the Kotlin compiler. So, I added:
dependencies {
testImplementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10")
}
to the build.gradle. Then, when I run the test, configureByText throws an exception with a big trace, the root exception of which is:
Caused by: java.lang.Throwable: 'filetype.archive.display.name' is not found in java.util.PropertyResourceBundle#4ecbb519(messages.CoreBundle)
... 53 more
org.jetbrains.plugins.template.MyPluginTest > test2 FAILED
com.intellij.diagnostic.PluginException at ComponentManagerImpl.kt:511
Caused by: java.util.MissingResourceException at Registry.java:164
Does anyone have any insight into what the issue is or know how to resolve it?
Notes:
I also tried importing the kotlin compiler and casting psiFile as KtFile, which produced the same error, an idea I got from here
This project has a test like this that may be working
This post and this post recommend adding the kotlin gradle plugin, which I did
This question seems similar
Yann Cebron replied on the jetbrains help forum with an answer for Java, which also worked for Kotlin.
The solution is to add a dependency to the IntelliJ gradle plugin. The template comes with these lines in the build.gradle:
intellij {
pluginName.set(properties("pluginName"))
version.set(properties("platformVersion"))
type.set(properties("platformType"))
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty))
}
So, didn't need to do anything there. In my gradle.properties, I added
platformPlugins = com.intellij.java, org.jetbrains.kotlin
To my plugin.xml, I added:
<depends>com.intellij.modules.java</depends>
<depends>org.jetbrains.kotlin</depends>
I was able to remove
dependencies {
testImplementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10")
}
from the build.gradle which I mentioned above.
Now, the test works for Java and Kotlin files.
I'm creating a costum Android Lint Inspection and I need to register the inspection, to be run. Where do I need to register it?
I've already tried to register the inspection which provides the inspection inside plugin.xml file.
The actual inspection:
class HardcodedDimensionsInspection : AndroidLintInspectionBase("Hardcoded dimensions", HardcodedDimensDetector.ISSUE) {
override fun getShortName(): String {
return "AndroidLintHardcodedDimension"
}
}
The entry in plugin.xml file
<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
<!-- <inspectionToolProvider implementation="JavaInspectionProvider"/>-->
<globalInspection shortName="AndroidLintHardcodedDimension" displayName="Hardcoded dimensions"
enabledByDefault="true" level="WARNING"
implementationClass="HardcodedDimensionsInspection"/>
</extensions>
The actual detector
class HardcodedDimensDetector : LayoutDetector() {
override fun getApplicableAttributes(): Collection<String>? {
return Arrays.asList(
// Layouts
ATTR_TEXT
)
}
override fun appliesTo(folderType: ResourceFolderType): Boolean {
return (folderType == ResourceFolderType.LAYOUT ||
folderType == ResourceFolderType.MENU ||
folderType == ResourceFolderType.XML)
}
override fun visitAttribute(context: XmlContext, attribute: Attr) {
val value = attribute.value
}
companion object {
/** The main issue discovered by this detector */
#JvmField
val ISSUE = Issue.create(
id = "HardcodedDimension",
briefDescription = "Hardcoded dimens",
explanation = """
Brief
""",
category = Category.I18N,
priority = 5,
severity = Severity.ERROR,
implementation = Implementation(
HardcodedDimensDetector::class.java,
Scope.RESOURCE_FILE_SCOPE
)
)
}
}
I've expected to hit the breakpoints in any of the functions for Detector but the code is never called. Seems like my detector is not registered. Can you please point me to the missing part, is there a class where I should register my Detector?
Thank you.
The link to the full project: https://github.com/magicbytes/Android-Lint-Inspection
I don't see anything obvious wrong from these snippets. Could you please post on our forum and link to the full sources of your plugin? Thanks. https://intellij-support.jetbrains.com/hc/en-us/community/topics/200366979-IntelliJ-IDEA-Open-API-and-Plugin-Development
I have a workaround for now, not sure it's the official way to do it. Android Lint has a registry with all the Issue classes (built-in), the class is called LintIdeIssueRegistry. When it runs the Android Lint, it's looking in this registry for Issue processors. Since the list is hardcoded, we need to inject ours in the list. I'm using the following code for that:
val registry = LintIdeIssueRegistry()
val issue = registry.getIssue(HardcodedDimensDetector.ISSUE.id)
if (issue == null) {
val list = registry.issues as MutableList<Issue>
list.add(HardcodedDimensDetector.ISSUE)
}
Hopefully in future we will have a method called addIssue inside the LintIdeIssueRegistry.
Can you help me to run the code? I am trying to execute the following:
public class HelloWorld {
public static void main (String[] args) {
System.out.println("Hello,world!");
}
}
To do that I click Run->Run (the second one with Alt+Shift+F10). It outputs a small window where the only available option is Edit configurations, I tried to do that but with no success.
While editing your first configuration.
Clik + button and choose Application template
In Main class: type HelloWorld or pick it from the picker ...
I am trying to bind an Android PDF library in a Xamarin Android Binding project, but a unnecessary "override" modifier is added to a property:
public partial class ReaderView : global::Android.Widget.AdapterView, [...] {
// ...
public override unsafe global::Android.Widget.IAdapter Adapter {
// Metadata.xml XPath method reference: path="/api/package[#name='com.artifex.mupdfdemo']/class[#name='ReaderView']/method[#name='getAdapter' and count(parameter)=0]"
[Register ("getAdapter", "()Landroid/widget/Adapter;", "GetGetAdapterHandler")]
get {
// ...
}
// Metadata.xml XPath method reference: path="/api/package[#name='com.artifex.mupdfdemo']/class[#name='ReaderView']/method[#name='setAdapter' and count(parameter)=1 and parameter[1][#type='android.widget.Adapter']]"
[Register ("setAdapter", "(Landroid/widget/Adapter;)V", "GetSetAdapter_Landroid_widget_Adapter_Handler")]
set {
// ...
}
}
// ...
}
I didn't find anything about adding/removing modifiers like "override", or "virtual" in the documentation.
I tried this without success:
<attr path="/api/package[#name='com.artifex.mupdfdemo']/class[#name='ReaderView']/method[#name='getAdapter' and count(parameter)=0]" name="override">false</attr>
<attr path="/api/package[#name='com.artifex.mupdfdemo']/class[#name='ReaderView']/method[#name='setAdapter' and count(parameter)=1 and parameter[1][#type='android.widget.Adapter']]" name="override">false</attr>
Do you guys have any idea about how to do this?
Edit 1: The Java project is on GitHub: https://github.com/asimmon/MuPDF-for-Android and here is a direct link to the file ReaderView.java.
Edit 2: The Xamarin Binding Project is on GitHub too, you will find the Jar library: https://github.com/asimmon/MuPDF-for-Xamarin-Android
The solution is to modify the visibility of the method in Metadata.xml:
<attr
path="/api/package[#name='com.artifex.mupdfdemo']/class[#name='ReaderView']/method[#name='getAdapter']"
name="visibility">public</attr>
This effectively removes the override keyword from your method's signature.
I have Flex SDK 4.6. I would like to work with library https://github.com/y8/websocket-as. This library needed library as3corelib (https://github.com/mikechambers/as3corelib). The problem is, that I'm not able to use/include this libraries in my HelloWorld project.
package {
import flash.display.Sprite;
import flash.text.TextField;
import y8.net.WebSocket;
public class HelloWorld extends Sprite {
public function HelloWorld() {
var display_txt:TextField = new TextField();
display_txt.text = "Hello World!";
addChild(display_txt);
}
}
}
When I compile it with mxmlc.exe -o HelloWorld.swf tuts\HelloWorld.as, I get error
HelloWorld.as(5): col: 15 Error: Definition y8.net:WebSocket could not be found.
import y8.net.WebSocket;
Please, how can I put it together (directories) and how can I compile this libraries and HelloWordl with mxmlc.exe. Thanks.
You can do it like this
mxmlc -library-path+=/myLibraries/MyRotateEffect.swc;/myLibraries/MyButtonSwc.swc c:/myFiles/app.mxml
ref: http://livedocs.adobe.com/flex/3/html/help.html?content=apparch_08.html