Custom Capacitor Plugin - add Android dependencies - java

How can I add an Android build dependency to my custom capacitor plugin for app rate based on
https://developer.android.com/guide/playcore/in-app-review/kotlin-java#java
It fails the build with not finding com.google.android.play.core so I wonder how can I add it as a dependency to the component build?
Below is the error
/AppRate.java:9: error: package com.google.android.play.core.review does not exist
import com.google.android.play.core.review.ReviewInfo;
^
/AppRate.java:10: error: package com.google.android.play.core.review does not exist
import com.google.android.play.core.review.ReviewManager;
^
/AppRate.java:11: error: package com.google.android.play.core.review does not exist
import com.google.android.play.core.review.ReviewManagerFactory;
^
/AppRate.java:12: error: package com.google.android.play.core.tasks does not exist
import com.google.android.play.core.tasks.Task;
^
/AppRate.java:17: error: class AppRate clashes with package of same name
public class AppRate extends Plugin {
^
/AppRate/BuildConfig.java:4: error: package me.url.AppRate clashes with class of same name
package me.url.AppRate;
^
/AppRate.java:21: error: cannot find symbol
Activity activity = this.cordova.getActivity();
I am also not sure about the clash error, but that is a separate topic I guess.
Note - I tried integrating the ionic native plugins but had weird build issues. iOS now works with my custom plugin, fixing Android now.

Try these steps to see:
Delete the Buildconfig.java
Refactor -> Rename, error class.
Build -> Rebuild Project!
--
And if not, share what you have in the file: build.gradle in the defaultConfig section and AndroidManifest from the manifest section.

I had to add
implementation "com.google.android.play:core:1.10.2"
to my build.grade file.

Related

error: cannot find symbol - when new class is added tand imported in an existing gradle project in IntelliJ IDEA

I got to work with an existing java code base which uses gradle. I had to create a new class and import it in an existing class. When I run gradle build or gradle bootRun it gives the following error and build fails.
error: cannot find symbol
import com.someservice.generic.model.SomeNewClass;
^
symbol: class SomeNewClass
location: package com.someservice.generic.model
Note: Some input files
use unchecked or unsafe operations. Note: Recompile with
-Xlint:unchecked for details. 1 error FAILED
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':compileJava'.
Compilation failed; see the compiler error output for details.
My new class looks like as follow,
package com.someservice.generic.model;
public class SomeNewClass {
}
And I import it as
import com.someservice.generic.model.RUnregPatient;
I have referred following questions
Getting "cannot find Symbol" in Java project in Intellij
Can't compile java class in Intellij Idea due to "cannot find symbol class X" error
and tried reimporting, invalidatite cache and restarting, rebuilding as suggested. None of them worked for me.
Deleting the new class file and creating another one solved the issue somehow.

Compilation error: Android libraries are not being included in the intellij plugin project (java)?

I want to access the hardware features of android device in intellij idea through folllowing code.
import android.os.Build;
import android.util.Log;
Log.i("ManuFacturer :", Build.MANUFACTURER);
Log.i("Display : ", Build.DISPLAY);
When I include this in my action class this gives me an compilatrion error like:
I have also include android sdk in the project structure of intellij-plugin-project...
Compilation failed; see the compiler error output for details.
error: package android.os does not exist
error: package android.util does not exist
error: cannot find symbol variable Build
error: cannot find symbol variable Log

xamarin android nuggetPackage dependencies monoAndroid

I'm developping a Xamarin Android app and i'm facing a problem which seems to be a problem of nugget package dependencies :
Microsoft.Office365.OAuth.Xamarin V1.0.21
Dependencies :
MonoAndroid, Version v2.2
Xamarin.Android.Support.V4 V23.3
Dependencies :
MonoAndroid, Version v7.0
Whenever I try to build my project :
error: cannot find symbol android.support.v4.content.Loader.OnLoadCanceledListener
This error come from this java file
<%Project%>\obj\Release\android\src\mono\android\support\v4\content\Loader_OnLoadCanceledListenerImplementor.java
package mono.android.support.v4.content;
public class Loader_OnLoadCanceledListenerImplementor
extends java.lang.Object
implements
mono.android.IGCUserPeer,
// this line is making the build fails
android.support.v4.content.Loader.OnLoadCanceledListener
...
...
Morever, these packages work perfectly when they aren't added together.
Am I doing something wrong ?

Project in multi project can't find specific project dependency

I have a Multi Project wich has the following structure:
core
pluginApi
plugins/globalOptions
plugins/commandPlugin
Where "plugins" is just a directory.
Now I have a couple classes inside "globalOptions":
at.lyze.plugin.globalOptions.extensionpoint.OptionExtension
at.lyze.plugin.globalOptions.extensionpoint.OptionHandlerExtension
And one class inside "commandPlugin":
at.lyze.plugin.commandPlugin.CommandPluginTest
The "CommandPluginTest" class uses"OptionExtension" and "OptionHandlerExtension" from the other project:
import at.lyze.plugin.globalOptions.extensionpoint.OptionExtension;
import at.lyze.plugin.globalOptions.extensionpoint.OptionHandlerExtension;
List<OptionHandlerExtension> optionHandlers = wrapper.getPluginManager().getExtensions(OptionHandlerExtension.class);
for (OptionHandlerExtension optionHandler : optionHandlers) {
logger.warn(optionHandler.getOption(getClass(), "TestOption"));
}
My gradle build files look like:
"globalOptions":
dependencies {
compile project(':pluginApi')
}
"commandPlugin":
dependencies {
compile project(':plugins/globalOptions')
compile project(':pluginApi')
}
When trying to run the "jar" task on every project I get the following error:
Note: Extension found in at.lyze.plugin.globalOptions.GlobalOptions$TestExtension
:plugins/globalOptions:compileJava
:plugins/globalOptions:processResources UP-TO-DATE
:plugins/globalOptions:classes
:plugins/globalOptions:jar
Note: Extension found in at.lyze.plugin.commandPlugin.CommandPluginTest$BlarghExtension
C:\Users\wml\Desktop\LocalRepos\darkowlbot\plugins\commandPlugin\src\main\java\at\lyze\plugin\commandPlugin\Co mmandPluginTest.java:3: error: package at.lyze.plugin.globalOptions.extensionpoint does not exist
import at.lyze.plugin.globalOptions.extensionpoint.OptionExtension;
^
C:\Users\wml\Desktop\LocalRepos\darkowlbot\plugins\commandPlugin\src\main\java\at\lyze\plugin\commandPlugin\Co mmandPluginTest.java:4: error: package at.lyze.plugin.globalOptions.extensionpoint does not exist
import at.lyze.plugin.globalOptions.extensionpoint.OptionHandlerExtension;
^
C:\Users\wml\Desktop\LocalRepos\darkowlbot\plugins\commandPlugin\src\main\java\at\lyze\plugin\commandPlugin\Co mmandPluginTest.java:52: error: cannot find symbol
public static class BlarghExtension implements EventProcessorExtension, OptionExtension {
^
symbol: class OptionExtension
location: class CommandPluginTest
C:\Users\wml\Desktop\LocalRepos\darkowlbot\plugins\commandPlugin\src\main\java\at\lyze\plugin\commandPlugin\CommandPluginTest.java:76: error: cannot find symbol
public void initializeOptions(OptionHandlerExtension optionHandlerExtension) {
^
symbol: class OptionHandlerExtension
location: class CommandPluginExtensionClass
4 errors
:plugins/commandPlugin:compileJava FAILED
FAILURE: Build failed with an exception.
Have I done something wrong here or why does this fail?
I can provide additional information if needed.
Running gradle 2.9
Edit:
Settings.gradle (Global project with every include)
rootProject.name = 'DarkOwlBot'
include 'pluginApi'
include 'core'
include 'plugins/globalOptions'
include 'plugins/commandPlugin'
include 'plugins/guiFeederService'
Most likely, gradle has problems with the '/' in project names. By default the project name is also used to create the jar for the project. This likely results in wrong file paths.
I think your best options to solve this are:
Change the include statements in your settings.gradle file to be
include ':plugins:globalOptions' and reference globalOptions by
compile project(':plugins:globalOptions')
Change the include statement in your settings.gradle file to be
include ':globalOptions' and configure the project directory explicit via project(':globalOptions').projectDir = file('plugins/globalOptions')
and reference it in your dependency block via compile project(':globalOptions')
In addition to what #ReneGroeschke said, you should leave out the into ('classes') line here. You're altering the structure of the produced artifact.

How to resolve unknown class and can not resolve symbol in Android Studio java library module

Using Android Studio and creating a java library module as part of a sub project I get an error on the following java statement:
javaFile.writeTo(System.out);
and it complains of can not resolve symbol 'writeTo' and unknown class 'System.out'.
Here's the gist of the source code class
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeSpec;
import javax.lang.model.element.Modifier;
public class MyClass {
...
JavaFile javaFile = JavaFile.builder("com.foobar.helloworld", helloWorld)
.build();
javaFile.writeTo(System.out);
}
A bit hard to say without knowing exactly what your exception was, but I had something similar pop up when I was testing out a sub-module annotation processor. When linking the processor to my main module, I was getting a java.lang.NoClassDefFoundError: com/squareup/javapoet/MethodSpec. I was using android-apt to get the annotation processor working, so in my build.config my dependencies had the apt configuration definition:
dependencies {
...
apt 'com.squareup:javapoet:1.7.0' // <- Note that since my Processor used javapoet, I had to include Javapoet in the main module's apt dependency as well as my processor jar
apt files('../processor/build/libs/processor.jar')
}
Once i included the above noted dependency, then all worked fine. Not sure if this applies to your situation without more details, but this got me back on track.

Categories

Resources