My app is using the pdftron lib (PDFViewCtrlTools). Here there is the class Utils.java and following methods:
public static void debugLogD(String tag, String msg) {
if (BuildConfig.DEBUG) {
Log.d(tag, msg);
}
}
public static void debugLogV(String tag, String msg) {
if (BuildConfig.DEBUG) {
Log.v(tag, msg);
}
}
I am getting following error when release building the app:
[proguard] Initializing...
[proguard] Warning: pdftron.PDF.Utils.Utils: can't find referenced class com.pdftron.pdf.tools.BuildConfig
[proguard] Note: android.support.v4.text.ICUCompatIcs: can't find dynamically referenced class libcore.icu.ICU
[proguard] Note: com.google.android.gms.internal.av calls '(com.google.ads.mediation.MediationAdapter)Class.forName(variable).newInstance()'
[proguard] Note: com.google.android.gms.maps.internal.q: can't find dynamically referenced class com.google.android.gms.maps.internal.CreatorImpl
[proguard] Note: com.google.api.client.util.IOUtils: can't find dynamically referenced class java.nio.file.Files
[proguard] Note: com.google.api.client.util.IOUtils: can't find dynamically referenced class java.nio.file.Path
[proguard] Note: com.google.gson.internal.UnsafeAllocator: can't find dynamically referenced class sun.misc.Unsafe
[proguard] Note: com.sophos.jbase.JBKeyStore: can't find dynamically referenced class android.os.ServiceManager
[proguard] Note: com.sophos.jbase.PRNGFixes: can't find dynamically referenced class org.apache.harmony.xnet.provider.jsse.NativeCrypto
[proguard] Note: com.sophos.jbase.PRNGFixes: can't find dynamically referenced class org.apache.harmony.xnet.provider.jsse.NativeCrypto
[proguard] Note: com.squareup.okhttp.internal.Platform: can't find dynamically referenced class com.android.org.conscrypt.OpenSSLSocketImpl
[proguard] Note: com.squareup.okhttp.internal.Platform: can't find dynamically referenced class org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl
[proguard] Note: the configuration refers to the unknown class 'com.google.vending.licensing.ILicensingService'
[proguard] Note: the configuration refers to the unknown class 'com.android.vending.licensing.ILicensingService'
[proguard] Note: the configuration refers to the unknown class 'com.pdftron.pdf.tools.BuildConfig'
[proguard] Maybe you meant the fully qualified name 'com.company.product.BuildConfig'?
There are more people having problems when in a project library BuildConfig.DEBUG is used, but I could not find any solution yet for this.
The problem appears only when using tools/proguard/proguard-android-optimize.txt instead of tools/proguard/proguard-android.txt
Have you tried adding the following?
-keep class com.pdftron.pdf.tools.BuildConfig { *; }
Related
I have project structure like
app :
InstantApp :
library:
dynamic-feature1 :
dynamic-feature2 :
dynamic-feature3 :
Now there is some dependency between dynamic-feature1 and dynamic-feature2. Now if i add it as dependency in dynamic-feature2 build.gradle then it will cause cyclic dependency.
Above is just one example there are many other cases too. How to handle such dependency conflicts properly or any suggestion ?
Communicate from the main app module to a dynamic feature module
You can do this by reflection in Java. Make sure your class and method names are not obfuscated in the dynamic modules.
Get a Fragment/Activity or other class from module:
Class class = Class.forName("your.dynamic.module.package.name.classname");
Get a method from your class:
Method method = class.getMethod("GenerateQuestion");
Invoke the method:
method.invoke(objectYouWantToInvokeTheMethodOn);
Communicate from dynamic feature module to main module
To get a parent activity of a dynamic feature module's fragment you can do:
#Override
public void onAttach(Context context) {
super.onAttach(context);
activity = (Activity) context;
}
Then you can call a method on that activity.
I've a class created in a DLL (which uses /clr runtime, ManagedC++) and a constructor defined in that class. Code as follows:
//Following is defined in something.h//
namespace ABC
{
public ref Class XYZ
{
public: int a;
public: XYZ();
};
//In something.cpp, I've the below code to define the constructor of the class created//
#include something.h
namespace ABC
{
XYZ::XYZ()
{
a = 100;
}
}
Above project is built into a DLL
In another project, I try to use the Class XYZ as follows:
#include something.h
using namespace ABC;
//inside main, I've following code
{
ABC::XYZ^ prq = gcnew ABC:XYZ();
prq->a=200;
......
...
}
In this, I get the an error saying -
unresolved token (06000001) ABC.XYZ::.ctor
Could you please help what's the problem here?
The problem is that the linker can't find the definition of the constructor. It is located in another DLL. In a managed project, you solve that by adding a reference to the assembly. Right-click your project, Properties, Common Properties, Framework and References. Click the Add New Reference button. Use the Project tab if the project is located in the same solution. The Browse tab otherwise.
Also note that you now no longer need the .h file anymore. Declarations are imported from the metadata in the assembly.
public class Font : SDLTTF.Font {
public Font (string _filename, int _size) {
}
public void draw () {
}
}
That's my code. When I try to build it, I get:
Font.vala:4.5-4.15: error: unable to chain up to base constructor requiring arguments
public Font (string _filename, int _size) {
^^^^^^^^^^^
Compilation failed: 1 error(s), 0 warning(s)
I thought I needed to override the constructor, so I tried to public override it, but now I get:
Font.vala:4.5-4.24: error: abstract, virtual, and override modifiers are not applicable to creation methods
public override Font (string _filename, int _size) {
^^^^^^^^^^^^^^^^^^^^
Compilation failed: 1 error(s), 0 warning(s)
Any ideas on how to fix this? I'm trying to inherit the SDLTTF.Font class.
Have you tried putting
base(_filename, _size);
in your constructor?
EDIT:
This worked for me. Note however that SDLTTF.Font is defined in the vapi as a compact class, meaning that when you derive it, you're only allowed to define new functions for your subclass, but no instance data (member variables, etc.). If you require this, I'd recommend you go with apmasell's suggestion and create a wrapper class deriving from (G)Object.
SDLTTF is not managed by GObject, so Vala cannot create a derived class. Vala can only create derived classes if they make use of GObject, as is typical in GLib, GTK+, Pango, ATK, and many GNOME libraries.
Depending on what you want to do, you could create a new class that contains an instance of SDLTFF.Font and proxy the appropriate requests.
I have a javascript Windows Store application that I'm working on, and I needed to create a WinRT component for some processing. As soon as I add the reference to that component, I get a javascript error:
0x800a01bd - Javascript runtime error: Object doesn't support this action.
This occurs on a line w/ the following:
engine = new MyApp.Engine();
Which is defined:
WinJS.Namespace.define("MyApp", {
Engine: WinJS.Class.define(function() {
//constructor stuff
//other stuff snipped for brevity
}
});
I'm not even accessing any code in my custom component, simply adding the reference causes it to break. Anyone run into this? Googling/Binging has been no help.
I found the answer.
So in my Javascript code, I had the declaration for a namespace.
In my WinRT C# component, I was using the same namespace. That namespace apparently stomps out my JS namespace declartion. I changed my WinRT component from this:
namespace MyApp
{
public sealed class SomeClass
{
}
}
to:
namespace MyAppUtils
{
public sealed class SomeClass
{
}
}
And now everything is good..so, Lesson: If you're using JS and a custom WinRT component, you (apparently) can't use the same namespace in both.
This question already has answers here:
Can a java file have more than one class?
(18 answers)
Closed 8 years ago.
Here's the code :
public class EmployeeTest
{
public static void main(String args[]){
//System.out.println("hello world");
Employee aEmployee = new Employee("David",1000);
System.out.println(aEmployee.getName() + aEmployee.getSalary());
}
}
class Employee // **why can't I put a "public" here**
{
// Constructor
public Employee(String name, double salary)
{
this.name = name;
this.salary = salary;
}
// Methods
public String getName()
{
return this.name;
}
public double getSalary()
{
return this.salary;
}
// instance field
private String name;
private double salary;
}
My question is : in the second class definition's first line, why can't I put a "public" to define it ?
What's the exactly meaning of "public" when using it defines a class ?
This is language feature. There must be only one top-level public class per .java file and public class name must match the source java file name.
Basically, non-public types are not accessible outside the package so if you wish to allow type to be used anywhere then make it public.
Never create a type in default package. (Always use package)
Employee.java
package com.abc.model;
public class Employee{..}
EmployeeTest.java
package com.abc.test;
public class EmployeeTest{ ... }
Because a Java source file can have at most one top-level public class or interface, and the name of the source file must be the same as the name of that class or interface.
That's a rule that the Java compiler of Oracle's JDK imposes.
In Java, there can only be a single public top level class per source file and it needs to be named the same as the file.
This is useful for the compiler when it needs to locate a class definition from outside the package, since it knows the type name, it knows which class file to find the class in. For example. since a jar file is in essence a zip file with class files, this prevents the compiler from having to unzip the entire jar to find a class definition.
The Java language specification §7.6 specifies this as an optional restriction;
If and only if packages are stored in a file system (§7.2), the host
system may choose to enforce the restriction that it is a compile-time
error if a type is not found in a file under a name composed of the
type name plus an extension (such as .java or .jav) if either of the
following is true:
The type is referred to by code in other compilation units of the
package in which the type is declared.
The type is declared public (and therefore is potentially accessible
from code in other packages).
you can define a public class inside a public class which is legal.
public class EmployeeTest
{
public class Employee {
}
}