0

I have a problem following this tutorial. It's a tutorial to make a Soundboard in Android Studio 3.6.3

The problem is in this line of code:

import androidx.appcompat.app.AlertController;

And this is the error:

error: AlertController is not public in androidx.appcompat.app; cannot be accessed from outside package 
import androidx.appcompat.app.AlertController;

Perhaps the problem is here: At 6:27, the creator of the tutorial adds the recyclerview support library using this old code:

compile: 'com.android.support:recyclerview-v7:23.4.0'

I used this code instead:

    implementation "androidx.recyclerview:recyclerview:1.1.0"

Can somebody help me solve the error, please?

  • You really shouldn't need to use `AlertController` directly. How is it being used in the code? Are you sure that's the right class? – Mike M. May 22 '20 at 05:02
  • Do you mean that I can delete it? Because I did try to delete it, but the app "keeps stopping". I noticed that it "keeps stopping" even if I don't delete the 'Alert Controller'. Also, I don't know if it's the right class. Edit: I did the Java Class all over again to see when the AlertController was going to appear, but it didn't appear, and it even got deleted from the old JavaClass... I must have done something wrong in the process. Running the app doesn't give any errors, but when I try to open it, it "keeps stopping". Any ideas why? – Apeiros Perfection May 22 '20 at 19:56
  • If it compiles without that import, then you don't need it. Beyond that, the "keeps stopping" message means it's crashing. You'll need to look at [the stack trace](https://stackoverflow.com/a/23353174) to determine the cause of the crash. – Mike M. May 23 '20 at 01:36
  • I looked at the stack trace: the beginning of the list of "at" says `(ActivityThread.java:3270)`... But I can't find ActivityThread.java in my project :| Also, after closing and re-opening the project, the stack trace seems different: Unlike before, I have an Exception, and a Caused. Now, I can click links, that show me where there could be an error. Meantime, I did the project all over again, and now it's working. In the old prjct, it seems there is a problem in the line `SoundView = (RecyclerView) findViewById(R.id.soundboardRecyclerView);`, but in the working project is written identically. – Apeiros Perfection May 23 '20 at 11:41
  • A stack trace will usually have many lines that point to code that is not your own, which is to be expected. The ones of interest are usually those lines that do point to your code, and the last `Caused by` Exception and message. Aside from that, I'm not really sure what you mean. If the new project is running acceptably, then it seems like you're good to go. Otherwise, if you want to know why the original project isn't working, we'd need to see a [mcve], and that complete stack trace. – Mike M. May 23 '20 at 11:51
  • Should we figure out why the original project isn't working? Maybe that could benefit somebody that has difficulty in starting the project all over again... – Apeiros Perfection May 23 '20 at 20:25
  • It is very unlikely to be a new, unique issue. Indeed, from your description, it's likely something rather common – e.g., mixed-up IDs, wrong variable initialization, etc. – or even something that's not really reproducible – e.g., an IDE glitch, stale build files, etc. Also, whatever the issue is, it's completely different than what this question is asking, so I'm not sure how useful it would be to pin that down, ultimately. – Mike M. May 23 '20 at 20:32
  • You're right, I haven't solved how the AlertController appeared... And I don't know how, and if, I should do it. – Apeiros Perfection May 24 '20 at 02:54
  • I'm not sure why that `AlertController` import was there, but if it's not used in any of your code directly, then you just don't need it. And since your code compiles without it, it's not being used in your code, which it shouldn't be, anyway. `AlertController` is basically a helper class for `AlertDialog`, which it uses internally. You don't need to have access to it, so you don't need the import. If that was actually in the tutorial, then I would guess that it was a typo, or maybe something leftover from some of their old code. – Mike M. May 24 '20 at 03:04

0 Answers0