retrofit protobuf-lite converter in Java - retrofit

Does retrofit support protobuf-lite converter in Java? In my case, I have to use both retrofit and protobuf-lite, but if I add dependencies like this:
compile "com.google.protobuf:protobuf-lite:3.0.0"
compile 'com.squareup.retrofit2:converter-protobuf:2.3.0'
then protobuf 3.0.0 will also be download by retrofit, this makes me get
com/a/a/a$a.class == protobuf-java-3.0.0.jar:com/google/protobuf/AbstractMessageLite$Builder.class
error. Is there any solutions to fix this?

Works for me using 2.4.0 and specifying transitive = false so that gradle doesn't pull in protobuf-java.
implementation ('com.squareup.retrofit2:converter-protobuf:2.4.0') {
transitive = false;
}

Related

"TS2729 [ERROR]: Property 'boundary' used before its initialization" in extern library

After updating my deno version to 1.9 today I had started having the following problem when running my tests or my scripts:
TS2729 [ERROR]: Property 'boundary' is used before its initialization.
readonly dashBoundary = encoder.encode(`--${this.boundary}`);
~~~~~~~~
at https://deno.land/std#0.63.0/mime/multipart.ts:266:52
'boundary' is declared here.
constructor(reader: Deno.Reader, private boundary: string) {
~~~~~~~~~~~~~~~~~~~~~~~~
at https://deno.land/std#0.63.0/mime/multipart.ts:269:36
I checked and I am not using the mime repository anywhere in my code, instead some other repositories must use it.
I am using the following repositories:
x/abc
std/uuid
std/fs
std/path
std/fmt
std/testing
I made sure that I am explicitely using the newest version for all of the imports of the std library (std version 0.93.0).
When I am running the files that are importing the std library (instead of running the entire application) no errors occur.
Does anyone have an idea how to resolve the error?
It seems like the repository x/abc was the problem.
I did not add a version when importing it implicitly. When importing implicitly it in the following way it worked:
import abc from "https://deno.land/x/abc#v1.3.1/mod.ts";

How to invoke Annotation Processor from Gradle plugin

I am currently working on a Gradle custon plugin that should analyse my root project for specific configs in every subproject and then generate some kotlin source code in the build dir. I can't figure out a way to invoke my annotation processor from my gradle plugin which has a custom task for this matter.
Any ideas how to achieve this? Any resource/tutorial/documentation is also highly welcomed.
Thanks in advance and be safe.
After a long time of googling and mostly trying and failing, I finally figured out the solution to my question. Here is my task configuration.
Basically we have to provide the annotation processor's classpath as a project configuration. In my case I added this block to the project's build.gradle
allprojects {
configurations {
myProcessor //pick any name!!!
}
}
and then as a dependency in app build.gradle
dependencies {
myProcessor "PATH_TO_MY_PROCESSOR_JAR" //or maven dependency if it's uploaded to maven central
}
tasks.register(
"myTaskName",
JavaCompile::class.java
) {
compiler ->
with(compiler.options) {
isFork = true
isIncremental = true
}
with(compiler) {
group = shuttle.plugin.ShuttlePlugin.TASK_GROUP
destinationDir = outputDir
classpath = variant.getCompileClasspath(null)
options.annotationProcessorPath = configurations.getByName("myProcessor") //this is the missing piece!!
source = files(projectDir.resolve("src/main/java")).asFileTree
}
}
However, this task will only compile Java classes Only and not kotlin.
Any Idea how to fix this behaviour knowing that my plugin targets only android apps so I don't have direct access to kotlinCompile gradle default task?

How to find Libpng library used in android project

When I upload my project to google play store I am getting Libpng library error and app getting rejected. I am not sure where it been used. I been used many library might be among those. How can I find it out exactly where this been used.
Is there any way to force fully by pass this like (Just an example)-
resolutionStrategy {
force 'com.google.android.gms:play-services-vision:11.4.2'
}
To get the list of dependency you can run this from Gradle -> Dependencies
Then you can find out which library causing issue and you can exclude it like this
dependencies
{
compile 'com.android.support:support-v4:xx.0.+'
compile ("com.xxx:xxx-commons:1.+")
{
exclude group: 'junit', module: 'junit'
}
}

ReactJS.NET - Bundles - TinyIoCResolutionException: Unable to resolve type: React.IReactEnvironment

I'm attempting to minify my .JSX files with ASP.NET Minification and Optimization via System.Web.Optimization.React. I've installed the MVC4 React Package as well as the Optimization package, but whenever I try to include a bundle I get the following:
React.TinyIoC.TinyIoCResolutionException: Unable to resolve type: React.IReactEnvironment
The InnerException is always null
My bundles are setup as follows:
bundles.Add(new ScriptBundle("~/Bundle/Scripts/ReactJS").Include(
"~/Scripts/React/react-0.12.2.js",
"~/Scripts/React/react-with-addons-0.12.2.js",
"~/Scripts/React/JSXTransformer-0.12.2.js"
));
bundles.Add(new JsxBundle("~/Bundle/Scripts/ReactCalendar").Include(
"~/Scripts/React/Calendar/Main.react.jsx",
"~/Scripts/React/Calendar/Components/Calendar.react.jsx",
"~/Scripts/React/Calendar/Components/CalendarEvent.react.jsx",
"~/Scripts/React/Calendar/Components/CalendarControls.react.jsx",
"~/Scripts/React/Calendar/Components/CalendarTimeSlots.react.jsx"
));
And included in the view as:
#section scripts{
#Scripts.Render("~/Bundle/Scripts/ReactJS");
#Scripts.Render("~/Bundle/Scripts/ReactCalendar");
}
The error is always thrown on line:
#Scripts.Render("~/Bundle/Scripts/ReactCalendar");
Anyone got any ideas on how to solve / debug this one? Let me know if more info is needed.
I'm not sure if this is the same issue I was facing, but I googled the exact same error, found this SO topic as the first hit, with no definitive answer, so I thought I'd offer my solution.
I'm using .NET 4.5 in an MVC app, and React.Web.Mvc4 v3.0.0.
I managed to work around this issue with the help of this comment on Github.
Here's my entire ReactConfig.cs:
using React;
using React.TinyIoC;
using React.Web.TinyIoC;
namespace NS.Project
{
public static class ReactConfig
{
public static void Configure()
{
Initializer.Initialize(AsPerRequestSingleton);
ReactSiteConfiguration.Configuration
.SetLoadBabel(false)
.AddScriptWithoutTransform("~/React/dist/server.bundle.js");
}
private static TinyIoCContainer.RegisterOptions AsPerRequestSingleton(
TinyIoCContainer.RegisterOptions registerOptions)
{
return TinyIoCContainer.RegisterOptions.ToCustomLifetimeManager(
registerOptions,
new HttpContextLifetimeProvider(),
"per request singleton"
);
}
}
}
Then, I'm callingReactConfig.Configure explicitly from Application_Start.
"Unable to resolve type: React.IReactEnvironment" with no InnerException generally means ReactJS.NET is not initialising properly for some reason. In web apps, ReactJS.NET handles initialisation through the use of WebActivator. Make sure your project is referencing React.Web, React.Web.Mvc4 and WebActivatorEx, and all the corresponding .dll files are ending up in your app's bin directory.
Also, you do not need to (and should not) include JSXTransformer in your JavaScript bundles, as ReactJS.NET does all the JSX compilation server-side.
Something looks like changed from React.Web.MVc4 version 4.0.0. versions before didnt have that problem.
as stated here
Install the React.Web.Mvc4 package through NuGet. You will also need to install a JS engine to use (either V8 or ChakraCore are recommended). See the JSEngineSwitcher docs for more information.
To use V8, add the following packages:
JavaScriptEngineSwitcher.V8
JavaScriptEngineSwitcher.V8.Native.win-x64
ReactConfig.cs will be automatically generated for you. Update it to register a JS engine and your JSX files:
using JavaScriptEngineSwitcher.Core;
using JavaScriptEngineSwitcher.V8;
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(React.Sample.Mvc4.ReactConfig), "Configure")]
namespace React.Sample.Mvc4
{
public static class ReactConfig
{
public static void Configure()
{
ReactSiteConfiguration.Configuration
.AddScript("~/Content/Sample.jsx");
JsEngineSwitcher.Current.DefaultEngineName = V8JsEngine.EngineName;
JsEngineSwitcher.Current.EngineFactories.AddV8();
}
}
}
If anyone needs this, just install this nuget and it will resolve this issue.
System.Web.Optimization.React

Including external jar files to resource path in Rhino shell

I am using javascript on a Rhino Shell. I need to add the com.sun.jna.jar to the classpath. Now when I type - js:> Packages.com.sun.jna.NativeLibrary
[JavaClass com.sun.jna.NativeLibrary]
This shows that the jna library is accessible by the Rhino Shell? But when I try to use the library: js:> var c=Packages.com.sun.jna.NativeLibrary.getInstance("c");
java.lang.UnsatisfiedLinkError: Unable to load library '2': JNA native support (win32-x86/2.dll) not found in resource path (C:\ti\ccsv5\eclipse\plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar)
The resource path(C:\ti\ccsv5......launcher_1.3.0.v20120522-1813.jar) is the path it shows when I type - js:> print(System.getProperty("java.class.path"));
I donot understand how to add the jar files to the resource path.I tried to do it by the Command prompt: java -cp "path of jar" .name of class containing main ---> How do I understand what is the name of the class containing main since Rhino does the conversion from javascripts to classes?
Thanks in Advance.
Sohini.
I don't believe that the issue is specifically related to Rhino. Rather, it is a difference between the Linux and Windows system libraries.
The getting started document for JNA, at
https://github.com/twall/jna/blob/master/www/GettingStarted.md provides the following example:
package com.sun.jna.examples;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Platform;
/** Simple example of JNA interface mapping and usage. */
public class HelloWorld {
// This is the standard, stable way of mapping, which supports extensive
// customization and mapping of Java to native types.
public interface CLibrary extends Library {
CLibrary INSTANCE = (CLibrary)
Native.loadLibrary((Platform.isWindows() ? "msvcrt" : "c"),
CLibrary.class);
void printf(String format, Object... args);
}
public static void main(String[] args) {
CLibrary.INSTANCE.printf("Hello, World\n");
for (int i=0;i < args.length;i++) {
CLibrary.INSTANCE.printf("Argument %d: %s\n", i, args[i]);
}
}
}
The native library loaded depends on the platform you are running the program on: For Windows you will need to use the 'msvcrt' (Microsoft Visual C Run Time) library; for others, use the 'c' library.
I ran a test case to confirm:
Running on Windows fails if I try to load the "c" library.
PS C:\Users\jharig\workspace\JNATest> java -cp ".\jna-3.5.2.jar;.\platform-3.5.2.jar;.\js.jar;.\js-14.jar" org.mozilla.javascript.tools.shell.Main
Rhino 1.7 release 4 2012 06 18
js> var c = Packages.com.sun.jna.NativeLibrary.getInstance("c");
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'c': JNA native support (win32-amd64/c
.dll) not found in resource path (.\jna-3.5.2.jar;.\platform-3.5.2.jar;.\js.jar;.\js-14.jar)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:220)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:322)
Running on Windows succeeds if I use the 'msvcrt' library.
PS C:\Users\jharig\workspace\JNATest> java -cp ".\jna-3.5.2.jar;.\platform-3.5.2.jar;.\js.jar;.\js-14.jar" org.mozilla.javascript.tools.shell.Main
Rhino 1.7 release 4 2012 06 18
js> var c = Packages.com.sun.jna.NativeLibrary.getInstance("msvcrt");
js> var f = c.getFunction("printf");
js> f.invoke(["Hello World\n"]);
Hello World
js>

Resources