I have same jar lib for android where I need change class. I opened .jar find and decompile class, do same changes. I need add updated file to jar. As I understand I need compile .java to .class, and then repack jar.
I try convert to classes with javac.exe MyClass.java and I get a lot of errors like
import android.annotation.SuppressLint;
.java:8: error: package android.content does not exist
import android.content.Context;
.java:9: error: package android.graphics does not exist
import android.graphics.Color;
in total 149 errors
Do you have any ideas?
These error messages are the java compiler telling you that there's some android dependencies that he can't figure out how or where to find.
I don't think it's possible to achieve this, because it seems your class relies on Android framework resources.
Take a look at:
compile android app with javac
Did you consider inheritance ? I mean, the desired different behaviour for android maybe can be achieved by inheriting the class then overriding the specific method with new behaviour, I'm just guessing, since I don't have enough info about your problem.
Related
So, i am running a java project which have many library that are available in the current working directory but VS code seems to not recognize these library and giving out error "The import ###### cannot be resolved" ex: The import org.apache.pdfbox.pdmodel.PDDocument cannot be resolved"
here is the image that might help you to know more about it
This is the package that i am working on :
Here the org/apache is the library contain the class file that are need to be imported and FileArrangement.java is the file having the import statements
Error i have been receiving
this is what VS code is been showing
i really need your help because i really don't have any idea how to correct this
I have checked other projects and they are also showing the same result although the import statements for java classes like . java.util.ArrayList doesn't show any kind of error and i have tried to clean java in VS code it also didn't work
i just need to correct this error of VS code to import the classes that i need
No error on java.util package
Putting the libraries in your current working directory does not work for Java, you need to add them to the classpath.
If you're using maven, that manages the classpath for you.
If not, you can manage it in VS Code by executing the Java: Configure Classpath command from the Command Palette (Ctrl+Shift+P).
You can add dependencies via Referenced libraries under the JAVA PROJECTS panel.
Or use java.project.referencedLibraries setting in settings.json.
For example:
"java.project.referencedLibraries": [
"library/**/*.jar",
"/home/username/lib/foo.jar"
]
Details can be found in configure-classpath and manage-dependencies.
I have just started learning java, so struggling in very basics. The problem i am facing currently is "cannot find symbol : class Ques". I have resolved this issue when i was accessing package from parent directory through CLASSPATH export. Now problem is i am trying to access sub-directory from sub-driectroy like this:
family.of.adam(has)/
father.java
WifeOne(sub-direc)/wifeone.java,ChildFromWifeOne.java
WifeTwo(sub-direc)/wifetwo.java,ChildFromWifeTwo.java
Now what i am trying to do is from wifetwo.java i am accessing wifeone.java. I have tried importing (wifeone)like this:
import family.of.adam.WifeOne.*;
import WifeOne.*;
In both cases it failed to import and same error occured which i mentioned above.
I have also tried solution provided in this Question but this effects classpath of WifeOne this is what i think because when i -cp method it starts showing errors related to wifeone.
I am using normal texteditor, compiling through terminal and using mac. Kindly brief me what mistake i am doing.
Assume src is your base folder(place you compile and run the program).
src/family/of/adam/FirstWife.java
if so you need to define the package startmetn the fist line of the FirstWife.java file.
package family.of.adam;
Then,If the second java file in the,
src/Main.java
In Main.java file you need to define the import statement for user the FirstWife.java class.
import family.of.adam.FirstWife;
I've jdk1.8.0_25 installed on my system but at the time of maven compiling there is always package com.sun.security.ntlm does not exist error occur on ** import com.sun.istack.internal.NotNull;** line. I've found same problem on web but no one can help me to skip this problem.Once again there is a guva.jar used on the project
Although your error is on the NotNull class import, if you really want to work directly with the NTLM classes instead of the Authenticator facilities, you could import anything from the com.sun.security.ntlm package as long as you have the corresponding compiled classes in your classpath (files which are not easy to find).
I learn development for android, I would like to see how certain application is built, I also would like to adjust its UI controls positions for sole use.
So, I decompiled the application and try to build it with Eclipse bundle. I got an apk file built, but when I start it it produces the exception "java.lang.RuntimeException: Unable to get provider iching.android.contentprovider.DivinationProvider"
But I see the file src/iching/android/contentprovider/DivinationProvider.java which contains missing class definition:
package iching.android.contentprovider;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.Context;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import iching.android.persistence.IChingSQLiteDBHelper;
public class DivinationProvider extends ContentProvider
{
How can I get compiled apk which can't find a class, used in it?
Why does not it find the class declared in properly placed source file?
UPDATE:
I found java compiler was disabled, so bin/classes remain empty on build finish
UPDATE2:
Yep there was a lot of errors when I enabled javac.
I give it a shot to answer your questions but i have to admit its half guessing since i dont see actual results of your decompiling/ running attempts:
0.) Make sure the app (.apk) you have runs as it is (e.g. "it works" as delivered from its producer)
1.) Since decompiling (even in Java) is not trivial as soon as there is complex (or "obfuscated") input data it is very likely the decompiled source will not compile.
=> In 99% of the cases decompiling is used to understand how something work using static code analysis rather than "just run it".
So "the lack of skills" of decompilers CAN lead to what you call "compiled apk which can't find a class, used in it". Mostly however because Class-dependencys were not decompiled correctly.
2.) Because it is not there. It is that simple. Assumed the decompiling worked properly (it looks as it would since you dont have any compile time issues) you are just missing the dependency iching.android.contentprovider. Recheck all of the 3th party librarys are getting attached to your final build-output (i assume a .apk file) correctly. Unfortunately i dont know how you are building your project.
I am trying to call a python method in java, similar functionality as Unresolved import org.python / working with jython and java?
However, I am using ant to compile and run my files. using import org.python.util will give me this error
package org.python.util does not exist
I can see that python.org.util exists in jython-2.5.0.jar.
So, here is the class path I have in my build.xml ant file:
classpath="${java.class.path}:./jgrapht/lib/jgrapht-jdk1.5.jar:\
./jgrapht/lib/jgraph.jar:./jgraphx/lib/jgraphx.jar:\
./jython/lib/jython-2.5.0.jar:./colt/lib/colt.jar:."
and I also I added the path to jython jar files to my class path. i.e. looks like echo $path gives me all the required paths. Is there anything missing here that I am not aware of?
Try this to make all classes in the package available:
import org.python.util.*;
Or this to include a particular class:
import org.python.util.TemplateAntTask;
EDIT: Also, looks like there is an extra slash after jython-2.5.0.jar in your classpath.