TVKILL icon indicating copy to clipboard operation
TVKILL copied to clipboard

Android-Studio and "Unsupported Modules Detected" message

Open glaukon-ariston opened this issue 5 years ago • 21 comments

First, I need to preface this with that I am not familiar with building applications in Android-Studio.

I installed Android Studio. When I open the TVKILL project in it I am getting this message in the Event Log:

Unsupported Modules Detected: Compilation is not supported for following modules: TVKILL. Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project.

When I try to run it I get the following in the Run tab:

21:24:03: Executing task...

21:24:04: Task execution finished.

This is the version of Android Studio I am running:

Android Studio 3.5 Build #AI-191.8026.42.35.5791312, built on August 9, 2019 JRE: 1.8.0_202-release-1483-b03 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0

Any idea what I am doing wrong?

glaukon-ariston avatar Sep 24 '19 19:09 glaukon-ariston

Android Studio can be a bit confusing at times. The most plausible solutions that I can find when googling your error message is probably deleting the .idea directory and .iml files. I hope this helps.

42SK avatar Sep 25 '19 13:09 42SK

@glaukon-ariston Also it helps to click on File > Invalidate Caches / Restart. Let us know if it helped!

nm17 avatar Sep 25 '19 14:09 nm17

I had to do both -- File > Invalidate Caches / Restart and delete .idea directory and .iml files. I got some messages in the Sync tab implying the sync (or build) has been successful. It is still mysterious to me how to actually select the project (TVKILL), build it and run it in Android Studio. And what does syncing mean? It seems that only when I select build.gradle in the project tree I am able to select Run | Run 'TVKILL'. And then I only get this in the Run tab (nothing happens):

18:44:02: Executing task... 18:44:02: Task execution finished.

I am attaching the screenshot of my Android Studio environment:

image

I would appreciate if someone could walk me through the steps required to run the TVKILL app inside the Android Studio. I am finding the lack of detailed feedback of what is going on when I initiate some action in the Studio quite disquieting.

Thanks in advance.

glaukon-ariston avatar Sep 25 '19 16:09 glaukon-ariston

OK, I might be able to help you with this one. The problem is that Android Studio doesn't know that it's supposed to run the Project as an Android App (it sound's ironic, but that's more or less what's happening). To build (and execute) the Project, you simply have to create a new run configuration (don't worry, it's easier than it sounds):

  1. In Android Studio got Run->Edit Configurations… (Alt+u+r)
  2. A new window opens. In the new window, click on the plus symbol in the top left corner and select "Android App".
  3. Give the new profile an appropriate name (e.g. "TVKILL app") and select "app" in the drop-down menu next to "Module:", then hit "OK".
  4. Android Studio should now automatically use your new configuration when you hit the "Run" button.

I hope this helps, let me know if you run into any more problems.

42SK avatar Sep 26 '19 10:09 42SK

I still seem to be doing something wrong. I cannot select anything but <no module> in the Run/Debug Configurations window -- there's nothing else in the Module drop-down box. There is the Module not specified error at the bottom of the window.

image

Any idea what next to try out?

glaukon-ariston avatar Sep 26 '19 17:09 glaukon-ariston

Deleted iml and .idea folder again. This what I get after loading in the project again:

image

image

Still cannot choose a module in the Run/Debug Config window.

glaukon-ariston avatar Sep 26 '19 17:09 glaukon-ariston

After a failed Gradle Plugin update I am getting this message

image

glaukon-ariston avatar Sep 26 '19 19:09 glaukon-ariston

Try clicking on the "Install Build Tools 28.0.3, update version in build file and sync project" line in the message. Hopefully, that should make the project compatible with your version of Android Studio.

42SK avatar Sep 27 '19 10:09 42SK

It seems I am getting closer. After doing a few recommended updates and refactorings I can now get the window of the emulated phone, but without the app installed on the phone because of the following error:

image

glaukon-ariston avatar Sep 28 '19 18:09 glaukon-ariston

Sorry for the delay, I think I might have found a way to solve your problem with the error message. Try deleting the kapt "com.android.databinding:compiler:$gradle_version" line in the project's /app/buid.gradle file. That should fix it.

42SK avatar Oct 10 '19 10:10 42SK

Now I get the following error:

e: java.lang.IllegalStateException: Backend Internal error: Exception during code generation

image

glaukon-ariston avatar Oct 10 '19 19:10 glaukon-ariston

Try also deleting the apply plugin: 'kotlin-kapt' line in the /app/buid.gradle file (line 3).

42SK avatar Oct 10 '19 22:10 42SK

Still getting the same error:

image

glaukon-ariston avatar Oct 11 '19 22:10 glaukon-ariston

OK, I'm afraid I might be starting to run out of ideas here. As a last resort, you could always simply try to delete the entire project and start start form scratch, maybe that somehow fixes it.

42SK avatar Oct 15 '19 18:10 42SK

Can you please verify that you can build my fork of the TVKILL? What is your setup (version of Android Studio)? Mine says

Android Studio 3.5.1 Build #AI-191.8026.42.35.5900203, built on September 25, 2019 JRE: 1.8.0_202-release-1483-b03 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0

glaukon-ariston avatar Oct 16 '19 20:10 glaukon-ariston

@42SK Can you at least try to compile your project with the BrandContainer.kt from my fork. That is the only real change in my fork. It adds the IR database from the TV-B-Gone project.

glaukon-ariston avatar Nov 14 '19 08:11 glaukon-ariston

I tried to compile your fork of TVKILL on my setup, but it also failes with the "Could not find com.android.databinding:compiler:3.5.1." error. Whatever causes this error must therefore be inherent to your Project. When I tried to compile my version of TVKILL with your version of the BrandContainer.kt file, I at first got an internal compiler error. However, since your version introduces a few very large arrays to the BrandContainer class, I conjectured that this might be the cause of the compiler error. After deleting a few of the patterns from your new brands, the compiler error did indeed disappear, and I finally managed to build the app. (I did notice a few bugs when running it---i.e. the app crashed in some situations---but it worked for the most part.) I would recommend that you reset your fork and try to get the normal version of TVKILL working on your setup first, then you can subsequently start incorporating your changes to the BrandContainer.kt file.

42SK avatar Nov 14 '19 20:11 42SK

Seems like this is the cause of the problem: https://stackoverflow.com/a/36797616

Error is thrown because there is a 64K byte-code size limit on a method in Java.

I guess the only way to fix it is to store all codes in some format like json in the res directory and read them from the code.

nm17 avatar Nov 15 '19 16:11 nm17

I have managed to compile and run the original TVKILL app. When I replace the BrandContainer.kt with the expanded one I get the Method code too large error:

e: java.lang.RuntimeException: Error generating class file com/redirectapps/tvkill/BrandContainer.class (compiled from [C:\app\dev\hp\projects\infrared\42SK\TVKILL\app\src\main\java\com\redirectapps\tvkill\BrandContainer.kt]): Method code too large!

@nm17 Can you provide me with a sketch code how this res directory/json files solution would be put into code (I'm new to this Android/Kotlin programming)? I know how to put code into JSON files, but I don't know how to read them from the res directory from within the app. What other files do I need to change?

glaukon-ariston avatar Nov 18 '19 19:11 glaukon-ariston

@glaukon-ariston You can use a library like Klaxon, which is used to parse json. From there you can iterate over a list and add brands from code.

I have made an example data.json file for sony: https://gist.github.com/nm17/d328de019a62503f2c4ca33b4df8e3b1

You can probably get away with using Klaxon().parse<Array<Brand>>

nm17 avatar Nov 19 '19 10:11 nm17

Hello the problems in this issue (among others) should be fixed with my proposed changes currently in PRs. These are big improvements for the app; I hope the maintainer will take the time to merge them.

JSON patterns are implemented but I couldn't successfully use a library using JSON as a binding for Java classes (Klaxon, Gson, etc.). However I hope that my implementations remain acceptable ...

@glaukon-ariston: Maybe you could modify your TV-B-Gone codes converter program to generate the new format in JSON...


These are my first patches for the android platform. I come from the Python world and I see that I have done well not to touch Java for years> < The Java / Kotlin chimerism appears to be... erk.. As well as the multiplicity of concurrent and similar projects (JSON binding) accompanied by their API changes. It's a JavaScript way of doing things :p

Special mention to Android Studio (same base as PyCharm for Python) ... up to 8GB of ram for a few opened files, not to mention the CPU cost and slowdowns after a few hours, requiring it to be restarted.

People who work with these tools should be paid more for having to endure them :D

ysard avatar Mar 06 '21 17:03 ysard