I'm trying to port Apache Flink to Android. One of the biggest problem is that some java tools doesn't exist for Android, but these conflict are not detected at compile time and the errors (NoClassDefFoundError excpetion) are detected only at runtime.
For example, Java's ManagementFactory doesn't exists for android, BUT no compile error is thrown even if in this class there are unresolved symbols/libraries, in particular:
import javax.management.MBeanServer;
import java.lang.management.BufferPoolMXBean;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryPoolMXBean;
import java.lang.management.MemoryType;
import java.lang.management.MemoryUsage;
Now, I included the Flink's jars (flink-clients, flink-java, flink-runtime and flink-streaming) in my Android Studio project and I would like to search all these kind of unresolved dependencies to avoid these kind of exception at runtime. There is any Android Studio tool for this purpose?
I think including jar dependencies in the project will not make Android Studio and a compiler to search for missing classes in already built jars. Try to include src of flink into your project. I tried that and I had all unresolved imports being red.
Related
I am trying to setup the apk expansion setup. I added the SampleDownloaderActivity.java but I am getting these errors once I rebuild the project
import com.google.android.vending.expansion.zipfile.ZipResourceFile; does not exist
import com.google.android.vending.expansion.zipfile.ZipResourceFile.ZipEntryRO; does not exist
What is the alternative to correct this?
you have to include the expansion library separately as the code dependency, you can get the relevant code at location <sdk>/extras/google/google_market_apk_expansion/zip_file/
I'm trying to use a Tika class.
I am Following the instructions here: https://tika.apache.org/1.6/gettingstarted.html
I'm on OS X, and I'm using Eclipse 4.5.1 Mars 1.
The jar files have been built, and I don't understand how to make those classes available in my class. I don't know what they mean by 'as a Maven dependency' vs 'in an Ant project'
I've added tika-core-1.11.jar tika-parsers-1.11.jar in Project Properties / Build Path / Libraries
The code is:
import org.apache.tika.exception.TikaException;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.mime.MediaType;
import org.apache.tika.parser.ParseContext;
import org.apache.tika.parser.AbstractParser;
import org.apache.tika.sax.XHTMLContentHandler;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
...
{... AutoDetectParser parser = new AutoDetectParser(); ... }
but
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
AutoDetectParser cannot be resolved to a type
How to make those classes known to the compiler ?
You should add both tika-core-{version}.jar and tika-parsers-{version}.jar to your build path. You should be able to do this by right clicking your project name and choosing Build Path->Add External Archives. (Note: these directions work in Eclipse Kepler with Tika 1.11, but other versions should be similar.)
Also make sure that you import org.apache.tika.parser.AutoDetectParser before referencing it in your code.
If you want full functionality, make sure you have added all the jars listed under Build Artifacts on the Tika Getting Started page (https://tika.apache.org/1.6/gettingstarted.html).
I'm trying to add the JCodec library to my android studio project. I followed the steps listed here. I import these four lines:
import org.jcodec.codecs.h264.H264Decoder;
import org.jcodec.common.AndroidUtil;
import org.jcodec.common.model.ColorSpace;
import org.jcodec.common.model.Picture;
I get no errors until I build my project. When I build the project, I get an error that each of the packages I tried to import don't exist. Does anyone know what the problem is?
Thanks!
I did not really understand how linked answer helped you to add library because it is for Eclipse and you are using Android Studio and Gradle.
In build.gradle you should add:
dependencies {
...
compile 'org.jcodec:jcodec:0.1.9'
...
}
I figured out my problem. The issue was that I added the library under libraries but it wasn't a jar file, it was an android project. What I did to solve the problem was adding it as a module and then adding the module as a dependency to my project.
I'm trying to follow the tutorials for using google calendar api in here
https://developers.google.com/google-apps/calendar/quickstart/java
I tried it in eclipse but I have errors in
import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;
The import com.google.api.client.extensions.java6 cannot be resolved
where it says they cannot be resolved and a
The declared package "" does not match the expected package
"main.java"
in the first line
I think the problem lies in the structure of my files but I have no idea how to structure it , I installed gradle plugin as pre-requisite of using google calendar api stated in the link but I'm not sure how to add in build.gradle so I just add a new file and name it build.gradle
I solved it by changing JDK compliance to 1.7 in project properties > java compiler
I'm trying to use the 'mik3y/usb-serial-for-android' library in order to read a serial connection. When trying to use the example code, I get errors because of certain things that will not import.
Here are the import statements that I'm having issues with(I've replaced my name and project info with dummy data):
import com.mycompany.johnsmith.driver.UsbSerialPort;
import com.mycompany.johnsmith.util.HexDump;
import com.mycompany.johnsmith.util.SerialInputOutputManager;
I receive the error: Cannot resolve symbol 'driver' for the first import, and Cannot resolve symbol 'util' for the other two.
I've installed the library as a dependency and all of my other imports work fine, but I'm still not sure if the issue is because of the library.