Answer the question
In order to leave comments, you need to log in
Why are there errors in Java code?
I study Android studio according to manuals from the Internet, in one of the articles, by the way, quite fresh, Android and 10 and 11 are considered there.
An example of writing your own Java code is considered, to add it to any existing APK, parsed using apktools, and then compiling it using the native Javac compiler javac.
Here is a piece of code:
package com.example.test;
import android.content.Context;
import android.widget.Toast;
public class Payload {
public static void run(Activity activity) {
Toast.makeText(context, "Hello world!", Toast.LENGTH_LONG).show();
}
}
javac -classpath "c:\Program Files\Android\Android Studio\plugins\android
\lib\android.jar" c:\Users\User\AndroidStudioProjects\Test\app\src\main\java\com\example\test\test.java
c:\Users\User\AndroidStudioProjects\Test\app\src\main\java\com\example
\test\payload.java:4: error: package android.widget does not exist
import android.widget.Toast;
^
c:\Users\User\AndroidStudioProjects\Test\app\src\main\java\com\example
\test\test.java:6: error: cannot find symbol
public static void run(Activity activity) {
^
symbol: class Activity
location: class Payload
c:\Users\User\AndroidStudioProjects\Test\app\src\main\java\com\example
\test\payload.java:7: error: cannot find symbol
Toast.makeText(Context, "Hello World!", Toast.LENGTH_LONG).show();
^
symbol: variable Context
location: class Payload
c:\Users\User\AndroidStudioProjects\Test\app\src\main\java\com\example
\test\payload.java:7: error: cannot find symbol
Toast.makeText(Context, "Hello World!", Toast.LENGTH_LONG).show();
^
symbol: variable Toast
location: class Payload
c:\Users\User\AndroidStudioProjects\Test\app\src\main\java\com\example
\test\test.java:7: error: cannot find symbol
Toast.makeText(Context, "Hello World!", Toast.LENGTH_LONG).show();
^
symbol: variable Toast
location: class Test
6 errors
Answer the question
In order to leave comments, you need to log in
If you have just started, then forget about this perversion:
to add it to any already existing APK parsed with apktools
You have just started training and are already trying to do something that many have not done in a long career, you better start with the basics.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question