When I opened an Android sketch was asked to download or locate the SDK. Download automatically didn’t work. So I did the manual download using: https://android.processing.org/tutorials/getting_started/
and I ran the sdkmanager:
Now I have directories like:
cmdline-tools
licenses
platform-tools
platforms
I’ve tried to point the SDK to different directories without luck. Any advice would be appreciated.
@bigboss97, what you are referring to is just the language Gradle uses for the build scripts. Gradle (Android’s build tool) will only use Kotlin or Groovy. Android projects can use Java or Kotlin. It’s confusing, but you shouldn’t have to interact with your build scripts very much. To use Java create a new java file by right-clicking on the …/src/main/java folder and select New → Java Class. I hope that helps get you started.
You can find old releases of Android mode here, Releases · processing/processing-android · GitHub
You can download the files under “Assets” and manually install it by placing the folder in your “modes” folder.
Android mode 4.5.1 doesn’t have the Windows issue with installing or locating the SDK so it may work. But I still had issues with Gradle and couldn’t build a sketch, which is probably a compatibility issue with Gradle 7 and 8. But I gave up and used Android Studio instead.
Hi @bigboss97. Check the LogCat (the cat image on left) to see if there are any errors or warnings. If so post those here. Also, do you have public void onRequestPermissionsResult() in your MainActivity?
I don’t know if this is the problem but you don’t need the public void settings() method at all. It should default to full screen.
Also, it wasn’t entirely clear, are running on an emulator or the device?
FATAL EXCEPTION: main
Process: androidstudio.tutorials, PID: 7579
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{androidstudio.tutorials/androidstudio.tutorials.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "androidstudio.tutorials.MainActivity" on path: DexPathList[[dex file "/data/data/androidstudio.tutorials/code_cache/.overlay/base.apk/classes3.dex", zip file "/data/app/~~or4zcKFQnuNshzrxOJgdeg==/androidstudio.tutorials-4RSLdCus4fJDrbNtaXq9SA==/base.apk"],nativeLibraryDirectories=[/data/app/~~or4zcKFQnuNshzrxOJgdeg==/androidstudio.tutorials-4RSLdCus4fJDrbNtaXq9SA==/lib/arm64, /system/lib64, /system/system_ext/lib64]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4066)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4340)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2584)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidstudio.tutorials.MainActivity" on path: DexPathList[[dex file "/data/data/androidstudio.tutorials/code_cache/.overlay/base.apk/classes3.dex", zip file "/data/app/~~or4zcKFQnuNshzrxOJgdeg==/androidstudio.tutorials-4RSLdCus4fJDrbNtaXq9SA==/base.apk"],nativeLibraryDirectories=[/data/app/~~or4zcKFQnuNshzrxOJgdeg==/androidstudio.tutorials-4RSLdCus4fJDrbNtaXq9SA==/lib/arm64, /system/lib64, /system/system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:44)
at android.app.Instrumentation.newActivity(Instrumentation.java:1339)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4053)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4340)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2584)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
MainActivity.java
public class MainActivity extends AppCompatActivity {
private PApplet sketch;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FrameLayout frame = new FrameLayout(this);
frame.setId(CompatUtils.getUniqueViewId());
setContentView(frame, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
sketch = new Sketch();
PFragment fragment = new PFragment(sketch);
fragment.setView(frame, this);
}
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
if (sketch != null) {
sketch.onRequestPermissionsResult(
requestCode, permissions, grantResults);
}
super.onRequestPermissionsResult( requestCode, permissions, grantResults);
}
@Override
public void onNewIntent(Intent intent) {
if (sketch != null) {
sketch.onNewIntent(intent);
}
super.onNewIntent( intent);
}
}
I’ve added super.xyz() because the compiler was complaining.
I’m launching via USB to my Galaxy z flip (Android 13).
@robertesler, thank you so much for your help I placed the two *.java files in the right location and updated package accordingly. Now it’s working, hooray!
I’ve written a note for myself and thought that might be useful for someone else, too.
Following steps are based on the instruction and using Android Studio Koala 2024.1.1
New project: Empty Views Activity
Package name: androidstudio.audiotest
Language: Java